Commit ffbd855c authored by yann300's avatar yann300

put includion of variable declaration in a separate function

parent f51b56d8
...@@ -109,23 +109,7 @@ async function buildTree (tree, step, scopeId) { ...@@ -109,23 +109,7 @@ async function buildTree (tree, step, scopeId) {
return { outStep: step + 1 } return { outStep: step + 1 }
} else { } else {
if (tree.includeLocalVariables) { if (tree.includeLocalVariables) {
var variableDeclaration = resolveVariableDeclaration(tree, step, sourceLocation) includeVariableDeclaration(tree, step, sourceLocation, scopeId)
if (variableDeclaration && !tree.scopes[scopeId].locals[variableDeclaration.attributes.name]) {
tree.traceManager.getStackAt(step, (error, stack) => {
if (!error) {
tree.solidityProxy.contractNameAt(step, (error, contractName) => { // cached
if (!error) {
var states = tree.solidityProxy.extractStatesDefinitions()
tree.scopes[scopeId].locals[variableDeclaration.attributes.name] = {
name: variableDeclaration.attributes.name,
type: decodeInfo.parseType(variableDeclaration.attributes.type, states, contractName),
stackHeight: stack.length
}
}
})
}
})
}
} }
step++ step++
} }
...@@ -133,6 +117,26 @@ async function buildTree (tree, step, scopeId) { ...@@ -133,6 +117,26 @@ async function buildTree (tree, step, scopeId) {
return { outStep: step } return { outStep: step }
} }
function includeVariableDeclaration (tree, step, sourceLocation, scopeId) {
var variableDeclaration = resolveVariableDeclaration(tree, step, sourceLocation)
if (variableDeclaration && !tree.scopes[scopeId].locals[variableDeclaration.attributes.name]) {
tree.traceManager.getStackAt(step, (error, stack) => {
if (!error) {
tree.solidityProxy.contractNameAt(step, (error, contractName) => { // cached
if (!error) {
var states = tree.solidityProxy.extractStatesDefinitions()
tree.scopes[scopeId].locals[variableDeclaration.attributes.name] = {
name: variableDeclaration.attributes.name,
type: decodeInfo.parseType(variableDeclaration.attributes.type, states, contractName),
stackHeight: stack.length
}
}
})
}
})
}
}
function extractSourceLocation (tree, step) { function extractSourceLocation (tree, step) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
tree.traceManager.getCurrentCalledAddressAt(step, (error, address) => { tree.traceManager.getCurrentCalledAddressAt(step, (error, address) => {
......
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