aboutsummaryrefslogtreecommitdiff
path: root/src/boot/me
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-09-16 12:17:56 -0700
committerGraydon Hoare <[email protected]>2010-09-16 12:34:07 -0700
commitc4c73e09f1a25c8a9d9c69a3243d9342037fed73 (patch)
tree9d0a0af1e32298d4a4cd47eb1ab03edf594f9303 /src/boot/me
parentBetter representation of tag containment, which will allow us to discern back... (diff)
downloadrust-c4c73e09f1a25c8a9d9c69a3243d9342037fed73.tar.xz
rust-c4c73e09f1a25c8a9d9c69a3243d9342037fed73.zip
Add a pexp-rebuild phase to the type resolution pass in resolve.ml.
Diffstat (limited to 'src/boot/me')
-rw-r--r--src/boot/me/resolve.ml44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/boot/me/resolve.ml b/src/boot/me/resolve.ml
index 1be2e3b9..7cb11d1f 100644
--- a/src/boot/me/resolve.ml
+++ b/src/boot/me/resolve.ml
@@ -483,6 +483,49 @@ let type_resolving_visitor
inner.Walk.visit_stmt_pre stmt
in
+ let rebuilt_pexps = Hashtbl.create 0 in
+ let get_rebuilt_pexp p =
+ Hashtbl.find rebuilt_pexps p.id
+ in
+
+ let visit_pexp_post p =
+ let rebuild_plval pl =
+ match pl with
+ Ast.PLVAL_ident _ -> pl
+ | Ast.PLVAL_app (id, tys) ->
+ Ast.PLVAL_app (id, Array.map resolve_ty tys)
+ | Ast.PLVAL_ext_name (pexp, nc) ->
+ let pexp = get_rebuilt_pexp pexp in
+ let nc =
+ match nc with
+ Ast.COMP_ident _
+ | Ast.COMP_idx _ -> nc
+ | Ast.COMP_app (id, tys) ->
+ Ast.COMP_app (id, Array.map resolve_ty tys)
+ in
+ Ast.PLVAL_ext_name (pexp, nc)
+
+ | Ast.PLVAL_ext_pexp (a, b) ->
+ Ast.PLVAL_ext_pexp (get_rebuilt_pexp a,
+ get_rebuilt_pexp b)
+ | Ast.PLVAL_ext_deref p ->
+ Ast.PLVAL_ext_deref (get_rebuilt_pexp p)
+ in
+ let p =
+ match p.node with
+ Ast.PEXP_lval pl ->
+ let pl' = rebuild_plval pl in
+ iflog cx (fun _ -> log cx "rebuilt plval %a as %a (#%d)"
+ Ast.sprintf_plval pl Ast.sprintf_plval pl'
+ (int_of_node p.id));
+ { p with node = Ast.PEXP_lval pl' }
+
+ | _ -> p
+ in
+ htab_put rebuilt_pexps p.id p
+ in
+
+
let visit_lval_pre lv =
let rec rebuild_lval' lv =
match lv with
@@ -539,6 +582,7 @@ let type_resolving_visitor
Walk.visit_obj_drop_pre = visit_obj_drop_pre;
Walk.visit_stmt_pre = visit_stmt_pre;
Walk.visit_lval_pre = visit_lval_pre;
+ Walk.visit_pexp_post = visit_pexp_post;
Walk.visit_crate_post = visit_crate_post }
;;