Use gvars for vtbls rather than returning const immediates.

This commit is contained in:
Graydon Hoare 2010-12-20 11:41:22 -08:00
parent 6a8518c97b
commit 490da3564b

View File

@ -2355,7 +2355,13 @@ impure fn trans_vtbl(@crate_ctxt cx, &ast._obj ob) -> ValueRef {
trans_fn(cx, m.node.meth, m.node.id, m.node.ann);
methods += llfn;
}
ret C_struct(methods);
auto vtbl = C_struct(methods);
auto gvar = llvm.LLVMAddGlobal(cx.llmod,
val_ty(vtbl),
_str.buf("_rust_vtbl" + "." + cx.path));
llvm.LLVMSetInitializer(gvar, vtbl);
llvm.LLVMSetGlobalConstant(gvar, True);
ret gvar;
}
impure fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,