Translate trivial bindings. Un-XFAIL bind-trivial.rs.

This commit is contained in:
Graydon Hoare 2011-01-05 16:06:01 -08:00
parent 5d2a6c73ca
commit f3f63da7c8
2 changed files with 21 additions and 8 deletions

View file

@ -418,6 +418,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
arith-0.rs \
arith-1.rs \
arith-2.rs \
bind-trivial.rs \
bitwise.rs \
bool-not.rs \
box.rs \

View file

@ -1952,18 +1952,30 @@ impure fn trans_bind(@block_ctxt cx, @ast.expr f,
vec[option.t[@ast.expr]] args,
&ast.ann ann) -> result {
auto f_res = trans_lval(cx, f);
auto bcx = f_res.res.bcx;
auto pair_t = node_type(cx.fcx.ccx, ann);
auto pair_v = bcx.build.Alloca(pair_t);
if (f_res.is_mem) {
cx.fcx.ccx.sess.unimpl("re-binding existing function");
} else {
auto code_cell =
bcx.build.GEP(pair_v, vec(C_int(0),
C_int(abi.fn_field_code)));
bcx.build.Store(f_res.res.val, code_cell);
let vec[@ty.t] bound = vec();
for (option.t[@ast.expr] argopt in args) {
alt (argopt) {
case (none[@ast.expr]) {
}
case (some[@ast.expr](?e)) {
append[@ty.t](bound, ty.expr_ty(e));
}
}
}
if (_vec.len[@ty.t](bound) == 0u) {
// Trivial 'binding': just return the static pair-ptr.
ret f_res.res;
} else {
auto bcx = f_res.res.bcx;
auto pair_t = node_type(cx.fcx.ccx, ann);
auto pair_v = bcx.build.Alloca(pair_t);
cx.fcx.ccx.sess.unimpl("nontrivial binding");
ret res(bcx, pair_v);
}
}
}
impure fn trans_call(@block_ctxt cx, @ast.expr f,