Przeglądaj źródła

[analyzer] make new record to replace terror tuple

Simon Krajewski 4 lat temu
rodzic
commit
4c076da9a2

+ 6 - 3
src/optimization/analyzerTexprTransformer.ml

@@ -1020,9 +1020,12 @@ and block_to_texpr_coroutine ctx bb vcontinuation vresult verror p =
 	])) com.basic.tvoid p
 
 and func ctx i =
-	let bb,t,p,tf,coroutine = Hashtbl.find ctx.graph.g_functions i in
+	let tfi = Hashtbl.find ctx.graph.g_functions i in
+	let tf = tfi.tf_tf in
+	let bb = tfi.tf_bb in
+	let p = tfi.tf_pos in
 	let e,tf_args,tf_type =
-		match coroutine with
+		match tfi.tf_coroutine with
 		| Some (vresult,verror) ->
 			let vcontinuation = alloc_var VGenerated "_hx_continuation" (tfun [t_dynamic] ctx.com.basic.tvoid) p in
 			declare_var ctx.graph vcontinuation bb;
@@ -1074,7 +1077,7 @@ and func ctx i =
 			Type.map_expr loop e
 	in
 	let e = loop e in
-	mk (TFunction {tf with tf_args = tf_args; tf_type = tf_type; tf_expr = e}) t p
+	mk (TFunction {tf with tf_args = tf_args; tf_type = tf_type; tf_expr = e}) tfi.tf_t p
 
 let to_texpr ctx =
 	func ctx ctx.entry.bb_id

+ 11 - 4
src/optimization/analyzerTypes.ml

@@ -246,7 +246,14 @@ end
 module Graph = struct
 	open BasicBlock
 
-	type tfunc_info = BasicBlock.t * Type.t * pos * tfunc * (tvar * tvar) option
+	type tfunc_info = {
+		tf_bb : BasicBlock.t;
+		tf_t : Type.t;
+		tf_pos : pos;
+		tf_tf : tfunc;
+		tf_coroutine : (tvar * tvar) option;
+	}
+
 	type texpr_lookup = BasicBlock.t * texpr_lookup_target
 	type var_write = BasicBlock.t list
 	type 'a itbl = (int,'a) Hashtbl.t
@@ -332,8 +339,8 @@ module Graph = struct
 
 	(* nodes *)
 
-	let add_function g tf t p bb coroutine =
-		Hashtbl.add g.g_functions bb.bb_id (bb,t,p,tf,coroutine)
+	let add_function g tf_tf tf_t tf_pos tf_bb tf_coroutine =
+		Hashtbl.add g.g_functions tf_bb.bb_id ({tf_bb;tf_t;tf_pos;tf_tf;tf_coroutine})
 
 	let alloc_id =
 		let r = ref 1 in
@@ -589,7 +596,7 @@ module Graph = struct
 					()
 			end
 		in
-		Hashtbl.iter (fun _ (bb,_,_,_,_) -> loop [0] bb) g.g_functions
+		Hashtbl.iter (fun _ tfi -> loop [0] tfi.tf_bb) g.g_functions
 end
 
 type analyzer_context = {