@@ -2310,14 +2310,20 @@ impure fn trans_fn(@crate_ctxt cx, &ast._fn f, ast.def_id fid,
2310
2310
impure fn trans_vtbl ( @crate_ctxt cx , & ast. _obj ob ) -> ValueRef {
2311
2311
let vec[ ValueRef ] methods = vec ( ) ;
2312
2312
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
+
2313
2319
trans_fn( cx, m. node. meth, m. node. id, m. node. ann) ;
2314
- methods += cx . item_ids . get ( m . node . id ) ;
2320
+ methods += llfn ;
2315
2321
}
2316
2322
ret C_struct ( methods) ;
2317
2323
}
2318
2324
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) {
2321
2327
2322
2328
auto llctor_decl = cx. item_ids. get( oid) ;
2323
2329
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,
2339
2345
copy_args_to_allocas( bcx, fn_args, arg_tys_of_fn( ann) ) ;
2340
2346
2341
2347
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) ;
2343
2353
bcx. build. Ret ( pair) ;
2344
2354
}
2345
2355
0 commit comments