aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeffrey Yasskin <[email protected]>2010-07-23 19:27:55 -0700
committerGraydon Hoare <[email protected]>2010-08-06 17:14:59 -0700
commitfdb842f9e6d28b51fa51935d66c77011f27a436b (patch)
treed07902b5ccd28828d8939116995aba8e2598fee9 /src
parentRedo yesterday's buf_writer-wrapper in a less silly and convoluted way. Add ... (diff)
downloadrust-fdb842f9e6d28b51fa51935d66c77011f27a436b.tar.xz
rust-fdb842f9e6d28b51fa51935d66c77011f27a436b.zip
Fix LLVM translation of modules.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile4
-rw-r--r--src/boot/llvm/lltrans.ml39
2 files changed, 29 insertions, 14 deletions
diff --git a/src/Makefile b/src/Makefile
index 0476240c..280ccc6c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -418,7 +418,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
alt-tag.rs \
arithmetic-interference.rs \
argv.rs \
- auto-deref.rs \
autoderef-full-lval.rs \
autoderef-objfn.rs \
basic.rs \
@@ -452,7 +451,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
generic-drop-glue.rs \
generic-exterior-box.rs \
generic-fn-infer.rs \
- generic-fn-twice.rs \
generic-fn.rs \
generic-obj-with-derived-type.rs \
generic-obj.rs \
@@ -482,8 +480,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
mutable-alias-vec.rs \
mutable-vec-drop.rs \
mutual-recursion-group.rs \
- native-mod.rc \
- native.rc \
obj-as.rs \
obj-drop.rs \
obj-dtor.rs \
diff --git a/src/boot/llvm/lltrans.ml b/src/boot/llvm/lltrans.ml
index ee192725..c1ef49af 100644
--- a/src/boot/llvm/lltrans.ml
+++ b/src/boot/llvm/lltrans.ml
@@ -588,7 +588,7 @@ let trans_crate
(* Maps a fn's or block's id to an LLVM metadata node (subprogram or
lexical block) representing it. *)
let (dbg_llscopes:(node_id, Llvm.llvalue) Hashtbl.t) = Hashtbl.create 0 in
- let declare_mod_item
+ let rec declare_mod_item
(name:Ast.ident)
mod_item
: unit =
@@ -616,9 +616,8 @@ let trans_crate
| Ast.MOD_ITEM_type _ ->
() (* Types get translated with their terms. *)
- | Ast.MOD_ITEM_mod _ ->
- () (* Modules simply contain other items that are translated
- on their own. *)
+ | Ast.MOD_ITEM_mod (_, items) ->
+ Hashtbl.iter declare_mod_item items
| _ ->
Common.unimpl (Some id)
@@ -807,6 +806,17 @@ let trans_crate
Ast.sprintf_lval lval)
in
+ let trans_callee (fn:Ast.lval) : (Llvm.llvalue * Ast.ty) =
+ let fty = Hashtbl.find sem_cx.ctxt_all_lval_types (lval_base_id fn) in
+ if lval_base_is_item sem_cx fn then
+ let fn_item = lval_item sem_cx fn in
+ let llfn = Hashtbl.find llitems (fn_item.id) in
+ (llfn, fty)
+ else
+ (* indirect call to computed slot *)
+ trans_lval fn
+ in
+
let trans_atom (atom:Ast.atom) : Llvm.llvalue =
iflog (fun _ -> log sem_cx "trans_atom: %a" Ast.sprintf_atom atom);
match atom with
@@ -959,7 +969,7 @@ let trans_crate
| Ast.STMT_call (dest, fn, args) ->
let llargs = Array.map trans_atom args in
let (lldest, _) = trans_lval dest in
- let (llfn, _) = trans_lval fn in
+ let (llfn, _) = trans_callee fn in
let llallargs = Array.append [| lldest; lltask |] llargs in
let llrv = build_call llfn llallargs "" llbuilder in
Llvm.set_instruction_call_conv Llvm.CallConv.c llrv;
@@ -1072,13 +1082,22 @@ let trans_crate
ignore (Llvm.build_br llbodyblock llinitbuilder)
in
- let trans_mod_item
- (_:Ast.ident)
- { node = { Ast.decl_item = (item:Ast.mod_item') }; id = id }
+ let rec trans_mod_item
+ (name:Ast.ident)
+ mod_item
: unit =
+ let { node = { Ast.decl_item = (item:Ast.mod_item') }; id = id } =
+ mod_item in
match item with
- Ast.MOD_ITEM_fn fn -> trans_fn fn id
- | _ -> ()
+ Ast.MOD_ITEM_type _ ->
+ () (* Types get translated with their terms. *)
+ | Ast.MOD_ITEM_mod (_, items) ->
+ Hashtbl.iter trans_mod_item items
+ | Ast.MOD_ITEM_fn fn -> trans_fn fn id
+ | _ -> Common.unimpl (Some id)
+ "LLVM module declaration for: %a"
+ Ast.sprintf_mod_item (name, mod_item)
+
in
let exit_task_glue =