Skip to content

Commit b8c4df9

Browse files
committed
---
yaml --- r: 1242 b: refs/heads/master c: b039be1 h: refs/heads/master v: v3
1 parent f8c234e commit b8c4df9

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: fe1a4ab23c6493d72e41b5ed8d87e7741e847154
2+
refs/heads/master: b039be1e5ca039747b2c8a65b8cb4df14d27b476

trunk/src/comp/middle/trans.rs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ fn type_of(@crate_ctxt cx, @ty.t t) -> TypeRef {
311311
ret llty;
312312
}
313313

314+
// NB: this function must match the ABI assumptions of trans_args exactly.
314315
fn type_of_fn_full(@crate_ctxt cx,
315316
option.t[TypeRef] obj_self,
316317
vec[ty.arg] inputs,
@@ -1758,17 +1759,20 @@ impure fn trans_alt(@block_ctxt cx, @ast.expr expr, vec[ast.arm] arms)
17581759

17591760
type lval_result = rec(result res,
17601761
bool is_mem,
1762+
option.t[vec[ValueRef]] lltys,
17611763
option.t[ValueRef] llobj);
17621764

17631765
fn lval_mem(@block_ctxt cx, ValueRef val) -> lval_result {
17641766
ret rec(res=res(cx, val),
17651767
is_mem=true,
1768+
lltys=none[vec[ValueRef]],
17661769
llobj=none[ValueRef]);
17671770
}
17681771

17691772
fn lval_val(@block_ctxt cx, ValueRef val) -> lval_result {
17701773
ret rec(res=res(cx, val),
17711774
is_mem=false,
1775+
lltys=none[vec[ValueRef]],
17721776
llobj=none[ValueRef]);
17731777
}
17741778

@@ -1800,11 +1804,19 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
18001804
auto fn_item = cx.fcx.ccx.items.get(did);
18011805
auto monoty = node_ann_type(cx.fcx.ccx, ann);
18021806
auto tys = ty.resolve_ty_params(fn_item, monoty);
1807+
auto vt = none[vec[ValueRef]];
18031808

1804-
// TODO: build a closure with the type parameters that
1805-
// result
1809+
if (_vec.len[@ty.t](tys) != 0u) {
1810+
let vec[ValueRef] tydescs = vec();
1811+
for (@ty.t t in tys) {
1812+
append[ValueRef](tydescs,
1813+
get_tydesc(cx, t));
1814+
}
1815+
vt = some[vec[ValueRef]](tydescs);
1816+
}
18061817

1807-
ret lval_val(cx, cx.fcx.ccx.fn_pairs.get(did));
1818+
auto lv = lval_val(cx, cx.fcx.ccx.fn_pairs.get(did));
1819+
ret rec(lltys = vt with lv);
18081820
}
18091821
case (ast.def_obj(?did)) {
18101822
check (cx.fcx.ccx.fn_pairs.contains_key(did));
@@ -1952,9 +1964,13 @@ impure fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
19521964
}
19531965

19541966

1955-
impure fn trans_args(@block_ctxt cx, ValueRef llclosure,
1967+
// NB: this function must match the ABI assumptions of type_of_fn_full exactly.
1968+
impure fn trans_args(@block_ctxt cx,
1969+
ValueRef llclosure,
19561970
option.t[ValueRef] llobj,
1957-
&vec[@ast.expr] es, @ty.t fn_ty)
1971+
option.t[vec[ValueRef]] lltydescs,
1972+
&vec[@ast.expr] es,
1973+
@ty.t fn_ty)
19581974
-> tup(@block_ctxt, vec[ValueRef]) {
19591975
let vec[ValueRef] vs = vec(cx.fcx.lltaskptr);
19601976
let @block_ctxt bcx = cx;
@@ -1965,6 +1981,15 @@ impure fn trans_args(@block_ctxt cx, ValueRef llclosure,
19651981
case (_) { fail; }
19661982
}
19671983

1984+
alt (lltydescs) {
1985+
case (some[vec[ValueRef]](?tys)) {
1986+
for (ValueRef t in tys) {
1987+
vs += t;
1988+
}
1989+
}
1990+
case (_) { }
1991+
}
1992+
19681993
alt (llobj) {
19691994
case (some[ValueRef](?ob)) {
19701995
// Every object is always found in memory,
@@ -2250,7 +2275,9 @@ impure fn trans_call(@block_ctxt cx, @ast.expr f,
22502275
}
22512276
auto fn_ty = ty.expr_ty(f);
22522277
auto ret_ty = ty.ann_to_type(ann);
2253-
auto args_res = trans_args(f_res.res.bcx, llclosure, f_res.llobj,
2278+
auto args_res = trans_args(f_res.res.bcx,
2279+
llclosure, f_res.llobj,
2280+
f_res.lltys,
22542281
args, fn_ty);
22552282

22562283
auto real_retval = args_res._0.build.FastCall(faddr, args_res._1);

0 commit comments

Comments
 (0)