From 5be55b3f24068ce9e7956d3ddb77f405642b70ca Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 14 Sep 2020 19:29:29 +0530 Subject: [PATCH] astwalker improved --- libs/remix-debug/src/source/astWalker.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libs/remix-debug/src/source/astWalker.js b/libs/remix-debug/src/source/astWalker.js index 227cc780b1..e410f0bce2 100644 --- a/libs/remix-debug/src/source/astWalker.js +++ b/libs/remix-debug/src/source/astWalker.js @@ -21,13 +21,15 @@ AstWalker.prototype.walk = function (ast, callback) { if (!('*' in callback)) { callback['*'] = function () { return true } } - const nodes = ast.nodes || (ast.body && ast.body.statements) || ast.declarations - if(ast.body && ast.initializationExpression) // 'for' loop handling - nodes.push(ast.initializationExpression) - if (manageCallBack(ast, callback) && nodes && nodes.length > 0) { - for (let k in nodes) { - const child = nodes[k] - this.walk(child, callback) + if(ast){ + const nodes = ast.nodes || (ast.body && ast.body.statements) || ast.declarations || [] + if(ast.body && ast.initializationExpression) // 'for' loop handling + nodes.push(ast.initializationExpression) + if (manageCallBack(ast, callback) && nodes && nodes.length > 0) { + for (let k in nodes) { + const child = nodes[k] + this.walk(child, callback) + } } } }