Skip to content

Commit

Permalink
[analyzer] make new record to replace terror tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Feb 22, 2021
1 parent 8569fc2 commit 74c15f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/optimization/analyzerTexprTransformer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,9 +1018,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;
Expand Down Expand Up @@ -1072,7 +1075,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
15 changes: 11 additions & 4 deletions src/optimization/analyzerTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 74c15f4

Please sign in to comment.