Skip to content

Commit 3210308

Browse files
committed
Create tag nodes for all the tags beforehand
1 parent 9dac49b commit 3210308

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/boot/me/type.ml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -984,19 +984,23 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
984984
in
985985
check_stmt
986986

987-
let create_tag_graph_node (cx:Semant.ctxt) (id:Common.opaque_id) (n:int) =
987+
let create_tag_graph_nodes (cx:Semant.ctxt) =
988+
let make_graph_node id _ =
989+
Hashtbl.add cx.Semant.ctxt_tag_containment id {
990+
Semant.tgn_index = None;
991+
Semant.tgn_children = Queue.create ()
992+
}
993+
in
994+
Hashtbl.iter make_graph_node cx.Semant.ctxt_all_tag_info
995+
996+
let populate_tag_graph_node (cx:Semant.ctxt) (id:Common.opaque_id) (n:int) =
988997
let tag_info = Hashtbl.find cx.Semant.ctxt_all_tag_info id in
989998
let (_, _, ty_tup) = Hashtbl.find tag_info.Semant.tag_nums n in
990999
let rec add_ty =
9911000
function
9921001
Ast.TY_tag { Ast.tag_id = id'; Ast.tag_args = tys } ->
993-
let make_graph_node () = {
994-
Semant.tgn_index = None;
995-
Semant.tgn_children = Queue.create ()
996-
} in
9971002
let tag_graph_node =
998-
Common.htab_search_or_add cx.Semant.ctxt_tag_containment id
999-
make_graph_node
1003+
Hashtbl.find cx.Semant.ctxt_tag_containment id'
10001004
in
10011005
Queue.add id' tag_graph_node.Semant.tgn_children;
10021006
Array.iter add_ty tys
@@ -1088,7 +1092,7 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
10881092
Ast.MOD_ITEM_fn _ when
10891093
not (Hashtbl.mem cx.Semant.ctxt_required_items item_id) ->
10901094
finish_function item_id
1091-
| Ast.MOD_ITEM_tag (_, id, n) -> create_tag_graph_node cx id n
1095+
| Ast.MOD_ITEM_tag (_, id, n) -> populate_tag_graph_node cx id n
10921096
| _ -> ()
10931097
in
10941098

@@ -1127,6 +1131,8 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
11271131
raise (Common.Semant_err ((Some stmt.Common.id), msg))
11281132
in
11291133

1134+
let visit_crate_pre _ : unit = create_tag_graph_nodes cx in
1135+
11301136
let visit_crate_post _ : unit =
11311137
(* Fill in the autoderef info for any lvals we didn't get to. *)
11321138
let fill lval_id _ =
@@ -1145,6 +1151,7 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
11451151
Walk.visit_obj_fn_post = visit_obj_fn_post;
11461152
Walk.visit_obj_drop_pre = visit_obj_drop_pre;
11471153
Walk.visit_obj_drop_post = visit_obj_drop_post;
1154+
Walk.visit_crate_pre = visit_crate_pre;
11481155
Walk.visit_crate_post = visit_crate_post
11491156
}
11501157
in

0 commit comments

Comments
 (0)