|
@@ -78,7 +78,7 @@ let rec analyse scope depth args node =
|
|
|
| FunCall (name, args, loc) ->
|
|
| FunCall (name, args, loc) ->
|
|
|
let (decl, dec_depth) = check_in_scope (Funcname name) node scope in
|
|
let (decl, dec_depth) = check_in_scope (Funcname name) node scope in
|
|
|
let node = FunCall (name, transform_all collect args, loc) in
|
|
let node = FunCall (name, transform_all collect args, loc) in
|
|
|
- FunUse (node, ctypeof decl, depth - dec_depth)
|
|
|
|
|
|
|
+ FunUse (node, decl, depth - dec_depth)
|
|
|
|
|
|
|
|
(* Assign statements are wrapped in VarLet nodes, which stores the type
|
|
(* Assign statements are wrapped in VarLet nodes, which stores the type
|
|
|
* and depth of the assigned variable are *)
|
|
* and depth of the assigned variable are *)
|
|
@@ -104,8 +104,10 @@ let rec analyse scope depth args node =
|
|
|
match node with
|
|
match node with
|
|
|
(* Increase nesting level when entering function *)
|
|
(* Increase nesting level when entering function *)
|
|
|
| FunDef (export, ret_type, name, params, body, loc) ->
|
|
| FunDef (export, ret_type, name, params, body, loc) ->
|
|
|
- let params = List.map (traverse scope depth) params in
|
|
|
|
|
- let body = analyse scope depth args body in
|
|
|
|
|
|
|
+ let (vars, funs) = scope in
|
|
|
|
|
+ let local_scope = (Hashtbl.copy vars, Hashtbl.copy funs) in
|
|
|
|
|
+ let params = List.map (traverse local_scope (depth + 1)) params in
|
|
|
|
|
+ let body = analyse local_scope (depth + 1) args body in
|
|
|
FunDef (export, ret_type, name, params, body, loc)
|
|
FunDef (export, ret_type, name, params, body, loc)
|
|
|
|
|
|
|
|
| Param (ArrayDec (_, dims), name, _) as node ->
|
|
| Param (ArrayDec (_, dims), name, _) as node ->
|
|
@@ -148,10 +150,7 @@ let rec analyse scope depth args node =
|
|
|
print_scope ();
|
|
print_scope ();
|
|
|
prerr_endline "\ntraversing";*)
|
|
prerr_endline "\ntraversing";*)
|
|
|
|
|
|
|
|
- let (vars, funs) = scope in
|
|
|
|
|
- let local_scope = (Hashtbl.copy vars, Hashtbl.copy funs) in
|
|
|
|
|
-
|
|
|
|
|
- let node = traverse local_scope (depth + 1) node in
|
|
|
|
|
|
|
+ let node = traverse scope depth node in
|
|
|
(*prerr_endline "traversed";
|
|
(*prerr_endline "traversed";
|
|
|
print_scope ();
|
|
print_scope ();
|
|
|
prerr_endline "";*)
|
|
prerr_endline "";*)
|