aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-09-16 15:03:28 -0700
committerGraydon Hoare <[email protected]>2010-09-16 15:04:40 -0700
commit9dac49bcd613213347e1a6beba25d64bea2596b7 (patch)
treec0235b9f89b23a1c7a250afc307fcdc12e2b37e4 /src/boot
parentPopulate the tag containment relation (diff)
downloadrust-9dac49bcd613213347e1a6beba25d64bea2596b7.tar.xz
rust-9dac49bcd613213347e1a6beba25d64bea2596b7.zip
Resolve plvals to their defns.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/me/resolve.ml38
-rw-r--r--src/boot/me/semant.ml11
2 files changed, 48 insertions, 1 deletions
diff --git a/src/boot/me/resolve.ml b/src/boot/me/resolve.ml
index 7cb11d1f..3c355c1c 100644
--- a/src/boot/me/resolve.ml
+++ b/src/boot/me/resolve.ml
@@ -489,6 +489,7 @@ let type_resolving_visitor
in
let visit_pexp_post p =
+ inner.Walk.visit_pexp_post p;
let rebuild_plval pl =
match pl with
Ast.PLVAL_ident _ -> pl
@@ -626,6 +627,7 @@ let lval_base_resolving_visitor
lookup_lval base;
match ext with
Ast.COMP_atom (Ast.ATOM_lval lv') -> lookup_lval lv'
+
| _ -> ()
end
| Ast.LVAL_base nb ->
@@ -659,8 +661,42 @@ let lval_base_resolving_visitor
reference_any_name lv;
inner.Walk.visit_lval_pre lv
in
+
+ let visit_pexp_pre p =
+ begin
+ match p.node with
+ Ast.PEXP_lval pl ->
+ begin
+ match pl with
+ (Ast.PLVAL_ident ident)
+ | (Ast.PLVAL_app (ident, _)) ->
+ let id = lookup_defn_by_ident p.id ident in
+
+ iflog cx
+ (fun _ ->
+ log cx "resolved plval %a = #%d to defn #%d"
+ Ast.sprintf_plval pl
+ (int_of_node p.id) (int_of_node id));
+
+ (* Record the pexp -> defn mapping. *)
+ htab_put cx.ctxt_lval_base_id_to_defn_base_id p.id id;
+
+ (* Tickle the referenced-ness table if it's an item. *)
+ if defn_id_is_item cx id
+ then ignore (lookup_by_name cx [] (!scopes)
+ (plval_to_name pl))
+ | _ -> ()
+ end
+
+ | _ -> ()
+ end;
+ inner.Walk.visit_pexp_pre p
+ in
+
{ inner with
- Walk.visit_lval_pre = visit_lval_pre };
+ Walk.visit_lval_pre = visit_lval_pre;
+ Walk.visit_pexp_pre = visit_pexp_pre
+ };
;;
diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml
index cde590c9..01457454 100644
--- a/src/boot/me/semant.ml
+++ b/src/boot/me/semant.ml
@@ -577,6 +577,17 @@ let rec lval_to_name (lv:Ast.lval) : Ast.name =
Ast.NAME_ext (lval_to_name lv, comp)
;;
+let rec plval_to_name (pl:Ast.plval) : Ast.name =
+ match pl with
+ Ast.PLVAL_ident ident ->
+ Ast.NAME_base (Ast.BASE_ident ident)
+ | Ast.PLVAL_app (ident, tys) ->
+ Ast.NAME_base (Ast.BASE_app (ident, tys))
+ | Ast.PLVAL_ext_name ({node = Ast.PEXP_lval pl}, nc) ->
+ Ast.NAME_ext (plval_to_name pl, nc)
+ | _ -> bug () "plval_to_name with plval that contains non-name components"
+;;
+
(* Type extraction. *)