@@ -141,7 +141,7 @@ struct
141141 let equal_node_context _ _ = failwith " StackNode: equal_node_context"
142142end
143143
144- module Stack (Cfg : CfgForward ) ( Arg : S ):
144+ module Stack (Arg : S with module Edge = InlineEdge ):
145145 S with module Node = StackNode (Arg. Node ) and module Edge = Arg. Edge =
146146struct
147147 module Node = StackNode (Arg. Node )
@@ -156,45 +156,30 @@ struct
156156 | n :: stack ->
157157 let cfgnode = Arg.Node. cfgnode n in
158158 match cfgnode with
159- | Function _ -> (* TODO: can this be done without Cfg ? *)
159+ | Function _ -> (* TODO: can this be done without cfgnode ? *)
160160 begin match stack with
161161 (* | [] -> failwith "StackArg.next: return stack empty" * )
162162 | [] -> [] (* main return *)
163163 | call_n :: call_stack ->
164- let call_cfgnode = Arg.Node. cfgnode call_n in
165164 let call_next =
166- Cfg . next call_cfgnode
165+ Arg . next call_n
167166 (* filter because infinite loops starting with function call
168167 will have another Neg(1) edge from the head *)
169- |> List. filter (fun (locedges , to_node ) ->
170- List. exists (function
171- | (_ , Proc _ ) -> true
172- | (_ , _ ) -> false
173- ) locedges
168+ |> List. filter_map (fun (edge , to_n ) ->
169+ match edge with
170+ | InlinedEdge _ -> Some to_n
171+ | _ -> None
174172 )
175173 in
176- begin match call_next with
177- | [] -> failwith " StackArg.next: call next empty"
178- | [(_, return_node)] ->
179- begin match Arg.Node. move_opt call_n return_node with
180- (* TODO: Is it possible to have a calling node without a returning node? * )
181- (* | None -> [] * )
182- | None -> failwith " StackArg.next: no return node"
183- | Some return_n ->
184- (* TODO: Instead of next & filter, construct unique return_n directly. Currently edge missing. *)
185- Arg. next n
186- |> List. filter (fun (edge , to_n ) ->
187- (* let to_cfgnode = Arg.Node.cfgnode to_n in
188- MyCFG.Node.equal to_cfgnode return_node *)
189- Arg.Node. equal_node_context to_n return_n
190- )
191- |> List. map (fun (edge , to_n ) ->
192- let to_n' = to_n :: call_stack in
193- (edge, to_n')
194- )
195- end
196- | _ :: _ :: _ -> failwith " StackArg.next: call next ambiguous"
197- end
174+ Arg. next n
175+ |> List. filter_map (fun (edge , to_n ) ->
176+ if BatList. mem_cmp Arg.Node. compare to_n call_next then (
177+ let to_n' = to_n :: call_stack in
178+ Some (edge, to_n')
179+ )
180+ else
181+ None
182+ )
198183 end
199184 | _ ->
200185 let + (edge, to_n) = Arg. next n in
0 commit comments