@@ -16,7 +16,9 @@ function visitAst(ast, previsit, postvisit, data)
1616 data = data or {};
1717 data .scopeStack = {};
1818 data .functionData = {
19+ depth = 0 ;
1920 scope = ast .body .scope ;
21+ node = ast ;
2022 };
2123 data .scope = ast .globalScope ;
2224 data .globalScope = ast .globalScope ;
@@ -103,7 +105,9 @@ function visitStatement(statement, previsit, postvisit, data)
103105 elseif (statement .kind == AstKind .FunctionDeclaration or statement .kind == AstKind .LocalFunctionDeclaration ) then
104106 local parentFunctionData = data .functionData ;
105107 data .functionData = {
108+ depth = parentFunctionData .depth + 1 ;
106109 scope = statement .body .scope ;
110+ node = statement ;
107111 };
108112 statement .body = visitBlock (statement .body , previsit , postvisit , data , true );
109113 data .functionData = parentFunctionData ;
@@ -197,7 +201,9 @@ function visitExpression(expression, previsit, postvisit, data)
197201 if (expression .kind == AstKind .FunctionLiteralExpression ) then
198202 local parentFunctionData = data .functionData ;
199203 data .functionData = {
204+ depth = parentFunctionData .depth + 1 ;
200205 scope = expression .body .scope ;
206+ node = expression ;
201207 };
202208 expression .body = visitBlock (expression .body , previsit , postvisit , data , true );
203209 data .functionData = parentFunctionData ;
0 commit comments