@@ -984,19 +984,23 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
984
984
in
985
985
check_stmt
986
986
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 ) =
988
997
let tag_info = Hashtbl. find cx.Semant. ctxt_all_tag_info id in
989
998
let (_, _, ty_tup) = Hashtbl. find tag_info.Semant. tag_nums n in
990
999
let rec add_ty =
991
1000
function
992
1001
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
997
1002
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'
1000
1004
in
1001
1005
Queue. add id' tag_graph_node.Semant. tgn_children;
1002
1006
Array. iter add_ty tys
@@ -1088,7 +1092,7 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
1088
1092
Ast. MOD_ITEM_fn _ when
1089
1093
not (Hashtbl. mem cx.Semant. ctxt_required_items item_id) ->
1090
1094
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
1092
1096
| _ -> ()
1093
1097
in
1094
1098
@@ -1127,6 +1131,8 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
1127
1131
raise (Common. Semant_err ((Some stmt.Common. id), msg))
1128
1132
in
1129
1133
1134
+ let visit_crate_pre _ : unit = create_tag_graph_nodes cx in
1135
+
1130
1136
let visit_crate_post _ : unit =
1131
1137
(* Fill in the autoderef info for any lvals we didn't get to. *)
1132
1138
let fill lval_id _ =
@@ -1145,6 +1151,7 @@ let process_crate (cx:Semant.ctxt) (crate:Ast.crate) : unit =
1145
1151
Walk. visit_obj_fn_post = visit_obj_fn_post;
1146
1152
Walk. visit_obj_drop_pre = visit_obj_drop_pre;
1147
1153
Walk. visit_obj_drop_post = visit_obj_drop_post;
1154
+ Walk. visit_crate_pre = visit_crate_pre;
1148
1155
Walk. visit_crate_post = visit_crate_post
1149
1156
}
1150
1157
in
0 commit comments