Commit 662549ce authored by yann300's avatar yann300

fix issue with source location

parent 0bfcb2b8
...@@ -249,11 +249,12 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId, ...@@ -249,11 +249,12 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId,
const contractObj = await tree.solidityProxy.contractObjectAt(step) const contractObj = await tree.solidityProxy.contractObjectAt(step)
let states = null let states = null
const generatedSources = getGeneratedSources(tree, scopeId, contractObj) const generatedSources = getGeneratedSources(tree, scopeId, contractObj)
const variableDeclarations = resolveVariableDeclaration(tree, sourceLocation, generatedSources)
const variableDeclaration = resolveVariableDeclaration(tree, sourceLocation, generatedSources)
// using the vm trace step, the current source location and the ast, // using the vm trace step, the current source location and the ast,
// we check if the current vm trace step target a new ast node of type VariableDeclaration // we check if the current vm trace step target a new ast node of type VariableDeclaration
// that way we know that there is a new local variable from here. // that way we know that there is a new local variable from here.
if (variableDeclarations && variableDeclarations.length) {
for (const variableDeclaration of variableDeclarations) {
if (variableDeclaration && !tree.scopes[scopeId].locals[variableDeclaration.name]) { if (variableDeclaration && !tree.scopes[scopeId].locals[variableDeclaration.name]) {
try { try {
const stack = tree.traceManager.getStackAt(step) const stack = tree.traceManager.getStackAt(step)
...@@ -275,6 +276,9 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId, ...@@ -275,6 +276,9 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId,
console.log(error) console.log(error)
} }
} }
}
}
// we check here if we are at the beginning inside a new function. // we check here if we are at the beginning inside a new function.
// if that is the case, we have to add to locals tree the inputs and output params // if that is the case, we have to add to locals tree the inputs and output params
const functionDefinition = resolveFunctionDefinition(tree, previousSourceLocation, generatedSources) const functionDefinition = resolveFunctionDefinition(tree, previousSourceLocation, generatedSources)
...@@ -351,7 +355,10 @@ function extractVariableDeclarations (ast, astWalker) { ...@@ -351,7 +355,10 @@ function extractVariableDeclarations (ast, astWalker) {
const ret = {} const ret = {}
astWalker.walkFull(ast, (node) => { astWalker.walkFull(ast, (node) => {
if (node.nodeType === 'VariableDeclaration' || node.nodeType === 'YulVariableDeclaration') { if (node.nodeType === 'VariableDeclaration' || node.nodeType === 'YulVariableDeclaration') {
ret[node.src] = node ret[node.src] = [node]
}
if (node.nodeType === 'VariableDeclarationStatement' || node.nodeType === 'YulVariableDeclarationStatement') {
ret[node.initialValue.src] = node.declarations
} }
}) })
return ret return ret
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment