|
@@ -13,7 +13,7 @@ let analyse_context node =
|
|
|
scope := StrMap.add name (decl, depth) !scope
|
|
scope := StrMap.add name (decl, depth) !scope
|
|
|
in
|
|
in
|
|
|
let rec analyse depth = function
|
|
let rec analyse depth = function
|
|
|
- (* add node reference for this varname to vars map *)
|
|
|
|
|
|
|
+ (* Add node reference for this varname to vars map *)
|
|
|
| VarDec (ctype, name, init, loc) as node ->
|
|
| VarDec (ctype, name, init, loc) as node ->
|
|
|
let node = match init with
|
|
let node = match init with
|
|
|
| Some value ->
|
|
| Some value ->
|
|
@@ -24,7 +24,7 @@ let analyse_context node =
|
|
|
add_to_scope name (ref node) depth "variable";
|
|
add_to_scope name (ref node) depth "variable";
|
|
|
node
|
|
node
|
|
|
|
|
|
|
|
- (* for a variable, look for its declaration in the current scope and
|
|
|
|
|
|
|
+ (* For a variable, look for its declaration in the current scope and
|
|
|
* save a reference with the relative nesting depth *)
|
|
* save a reference with the relative nesting depth *)
|
|
|
| Var (name, _) as node ->
|
|
| Var (name, _) as node ->
|
|
|
if StrMap.mem name !scope then
|
|
if StrMap.mem name !scope then
|
|
@@ -34,7 +34,7 @@ let analyse_context node =
|
|
|
raise (NodeError (node, (sprintf "undefined variable \"%s\"" name)))
|
|
raise (NodeError (node, (sprintf "undefined variable \"%s\"" name)))
|
|
|
|
|
|
|
|
(*
|
|
(*
|
|
|
- (* increase nesting level when entering function *)
|
|
|
|
|
|
|
+ (* Increase nesting level when entering function *)
|
|
|
| FunDef (export, ret_type, name, params, body, loc) as node ->
|
|
| FunDef (export, ret_type, name, params, body, loc) as node ->
|
|
|
let vars = StrMap.add name (ref node) vars in
|
|
let vars = StrMap.add name (ref node) vars in
|
|
|
let inctrav vars = function
|
|
let inctrav vars = function
|