log error if ast not found

pull/7/head
yann300 8 years ago
parent 87d2227a41
commit 0061b3b997
  1. 17
      src/util/internalCallTree.js

@ -91,7 +91,7 @@ async function buildTree (tree, step, scopeId) {
try { try {
sourceLocation = await extractSourceLocation(tree, step) sourceLocation = await extractSourceLocation(tree, step)
} catch (e) { } catch (e) {
return { outStep: step, error: 'InternalCallTree - Error resolving source location. ' + step + ' ' + e.messager } return { outStep: step, error: 'InternalCallTree - Error resolving source location. ' + step + ' ' + e.message }
} }
if (!sourceLocation) { if (!sourceLocation) {
return { outStep: step, error: 'InternalCallTree - No source Location. ' + step } return { outStep: step, error: 'InternalCallTree - No source Location. ' + step }
@ -149,11 +149,11 @@ function extractSourceLocation (tree, step) {
if (!error) { if (!error) {
return resolve(sourceLocation) return resolve(sourceLocation)
} else { } else {
return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step) return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step + ' ' + error)
} }
}) })
} else { } else {
return reject('InternalCallTree - Cannot retrieve address for step ' + step) return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error)
} }
}) })
}) })
@ -161,10 +161,15 @@ function extractSourceLocation (tree, step) {
function resolveVariableDeclaration (tree, step, sourceLocation) { function resolveVariableDeclaration (tree, step, sourceLocation) {
if (!tree.variableDeclarationByFile[sourceLocation.file]) { if (!tree.variableDeclarationByFile[sourceLocation.file]) {
tree.variableDeclarationByFile[sourceLocation.file] = extractVariableDeclarations(tree.solidityProxy.ast(sourceLocation), tree.astWalker) var ast = tree.solidityProxy.ast(sourceLocation)
if (ast) {
tree.variableDeclarationByFile[sourceLocation.file] = extractVariableDeclarations(ast, tree.astWalker)
} else {
console.log('Ast not found for step ' + step + '. file ' + sourceLocation.file)
return null
}
} }
var variableDeclarations = tree.variableDeclarationByFile[sourceLocation.file] return tree.variableDeclarationByFile[sourceLocation.file][sourceLocation.start + ':' + sourceLocation.length + ':' + sourceLocation.file]
return variableDeclarations[sourceLocation.start + ':' + sourceLocation.length + ':' + sourceLocation.file]
} }
function extractVariableDeclarations (ast, astWalker) { function extractVariableDeclarations (ast, astWalker) {

Loading…
Cancel
Save