diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-05-17 17:24:55 -0700 |
|---|---|---|
| committer | Eric Holk <eholk@mozilla.com> | 2011-05-20 16:51:08 -0700 |
| commit | 2b124a81409a00e9e00a4fdb02c16ff4e1f9b534 (patch) | |
| tree | a575de7ffc0dee526384f714cb5be374e7fe6b9d /src | |
| parent | 51e1ce292d0a64630df1764bb3f71b885aff7116 (diff) | |
| download | rust-2b124a81409a00e9e00a4fdb02c16ff4e1f9b534.tar.gz rust-2b124a81409a00e9e00a4fdb02c16ff4e1f9b534.zip | |
Started working on translating spawn. It correctly generates the task name in the case that it is not provided.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/middle/trans.rs | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index e1b0332a607..cc8ec47829e 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5543,6 +5543,10 @@ fn trans_expr(&@block_ctxt cx, &@ast::expr e) -> result { ret trans_recv(cx, lhs, rhs, ann); } + case (ast::expr_spawn(?dom, ?name, ?func, ?args, ?ann)) { + ret trans_spawn(dom, name, func, args, ann); + } + case (_) { // The expression is an lvalue. Fall through. } @@ -5879,9 +5883,45 @@ fn trans_chan(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result { ret res(bcx, chan_val); } +fn trans_spawn(&ast::spawn_dom dom, &option::t[str] name, + &@ast::expr func, &vec[@ast::expr] args, + &ast::ann ann) -> result { + // Make the task name + auto tname = alt(name) { + case(none) { + auto argss = vec::map(common::expr_to_str, args); + #fmt("%s(%s)", + common::expr_to_str(func), + str::connect(argss, ", ")) + } + case(some[str](?n)) { + n + } + }; + + // dump a bunch of information + log_err "Spawn"; + //log_err dom; + log_err #fmt("task name: %s", tname); + + // Generate code + alt(dom) { + case(ast::dom_implicit) { + // TODO + log_err "Spawning implicit domain tasks is not implemented."; + fail; + } + + case(ast::dom_thread) { + // TODO + log_err "Spawining new thread tasks is not implemented."; + fail; + } + } +} + fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs, &ast::ann ann) -> result { - auto bcx = cx; auto chn = trans_expr(bcx, lhs); bcx = chn.bcx; |
