in lib/generator.js [1053:1103]
getStmtsVars(stmts) {
let args = [];
let declare = [];
for (var i = 0; i < stmts.length; i++) {
const ast = stmts[i];
if (ast.type === 'return') {
args = args.concat(this.getExprVars(ast.expr));
} else if (ast.type === 'if') {
args = args.concat(this.getExprVars(ast.condition));
args = args.concat(this.getStmtsVars(ast.stmts.stmts));
if(ast.elseIfs && ast.elseIfs.length > 0) {
ast.elseIfs.map(elseIf => {
args = args.concat(this.getExprVars(elseIf.condition));
args = args.concat(this.getStmtsVars(elseIf.stmts.stmts));
});
}
if(ast.elseStmts) {
args = args.concat(this.getStmtsVars(ast.elseStmts.stmts));
}
} else if (ast.type === 'throw') {
args = args.concat(this.getExprVars(ast.expr));
} else if (ast.type === 'assign') {
args = args.concat(this.getExprVars(ast.left));
args = args.concat(this.getExprVars(ast.expr));
} else if (ast.type === 'declare') {
declare.push(_name(ast.id));
args = args.concat(this.getExprVars(ast.expr));
} else if (ast.type === 'while') {
args = args.concat(this.getExprVars(ast.condition));
args = args.concat(this.getStmtsVars(ast.stmts.stmts));
} else if (ast.type === 'for') {
args = args.concat(this.getExprVars(ast.list));
args = args.concat(this.getStmtsVars(ast.stmts.stmts));
} else if (ast.type === 'try') {
args = args.concat(this.getStmtsVars(ast.stmts.stmts));
} else if (ast.type === 'call') {
args = args.concat(this.getExprVars(ast));
} else {
args = args.concat(this.getExprVars(ast));
}
}
return args.filter(arg => {
if(!arg) {
return false;
}
if(declare.includes(arg.name)) {
return false;
}
return true;
});
}