Skip to content

Commit 2b124a8

Browse files
author
Eric Holk
committed
Started working on translating spawn. It correctly generates the task name in the case that it is not provided.
1 parent 51e1ce2 commit 2b124a8

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5543,6 +5543,10 @@ fn trans_expr(&@block_ctxt cx, &@ast::expr e) -> result {
55435543
ret trans_recv(cx, lhs, rhs, ann);
55445544
}
55455545

5546+
case (ast::expr_spawn(?dom, ?name, ?func, ?args, ?ann)) {
5547+
ret trans_spawn(dom, name, func, args, ann);
5548+
}
5549+
55465550
case (_) {
55475551
// The expression is an lvalue. Fall through.
55485552
}
@@ -5879,9 +5883,45 @@ fn trans_chan(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
58795883
ret res(bcx, chan_val);
58805884
}
58815885

5886+
fn trans_spawn(&ast::spawn_dom dom, &option::t[str] name,
5887+
&@ast::expr func, &vec[@ast::expr] args,
5888+
&ast::ann ann) -> result {
5889+
// Make the task name
5890+
auto tname = alt(name) {
5891+
case(none) {
5892+
auto argss = vec::map(common::expr_to_str, args);
5893+
#fmt("%s(%s)",
5894+
common::expr_to_str(func),
5895+
str::connect(argss, ", "))
5896+
}
5897+
case(some[str](?n)) {
5898+
n
5899+
}
5900+
};
5901+
5902+
// dump a bunch of information
5903+
log_err "Spawn";
5904+
//log_err dom;
5905+
log_err #fmt("task name: %s", tname);
5906+
5907+
// Generate code
5908+
alt(dom) {
5909+
case(ast::dom_implicit) {
5910+
// TODO
5911+
log_err "Spawning implicit domain tasks is not implemented.";
5912+
fail;
5913+
}
5914+
5915+
case(ast::dom_thread) {
5916+
// TODO
5917+
log_err "Spawining new thread tasks is not implemented.";
5918+
fail;
5919+
}
5920+
}
5921+
}
5922+
58825923
fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
58835924
&ast::ann ann) -> result {
5884-
58855925
auto bcx = cx;
58865926
auto chn = trans_expr(bcx, lhs);
58875927
bcx = chn.bcx;

0 commit comments

Comments
 (0)