Skip to content

Commit c3fbfb6

Browse files
committed
---
yaml --- r: 1110 b: refs/heads/master c: 56e040e h: refs/heads/master v: v3
1 parent ec77adc commit c3fbfb6

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
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: 62d62ce4da7b719c9ea1c65e916f1702c820f7d6
2+
refs/heads/master: 56e040e61a382a831faa5c563c46ffee2f4d7333

trunk/src/comp/middle/trans.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,14 +2310,20 @@ impure fn trans_fn(@crate_ctxt cx, &ast._fn f, ast.def_id fid,
23102310
impure fn trans_vtbl(@crate_ctxt cx, &ast._obj ob) -> ValueRef {
23112311
let vec[ValueRef] methods = vec();
23122312
for (@ast.method m in ob.methods) {
2313+
2314+
auto llfnty = node_type(cx, m.node.ann);
2315+
let str s = cx.names.next("_rust_method") + "." + cx.path;
2316+
let ValueRef llfn = decl_fastcall_fn(cx.llmod, s, llfnty);
2317+
cx.item_ids.insert(m.node.id, llfn);
2318+
23132319
trans_fn(cx, m.node.meth, m.node.id, m.node.ann);
2314-
methods += cx.item_ids.get(m.node.id);
2320+
methods += llfn;
23152321
}
23162322
ret C_struct(methods);
23172323
}
23182324

2319-
fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
2320-
&ast.ann ann) {
2325+
impure fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
2326+
&ast.ann ann) {
23212327

23222328
auto llctor_decl = cx.item_ids.get(oid);
23232329
cx.item_names.insert(cx.path, llctor_decl);
@@ -2339,7 +2345,11 @@ fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
23392345
copy_args_to_allocas(bcx, fn_args, arg_tys_of_fn(ann));
23402346

23412347
auto pair = bcx.build.Alloca(type_of(cx, ret_ty_of_fn(ann)));
2342-
2348+
auto vtbl = trans_vtbl(cx, ob);
2349+
auto pair_vtbl = bcx.build.GEP(pair,
2350+
vec(C_int(0),
2351+
C_int(abi.obj_field_vtbl)));
2352+
bcx.build.Store(vtbl, pair_vtbl);
23432353
bcx.build.Ret(pair);
23442354
}
23452355

0 commit comments

Comments
 (0)