Commit 446d9ff5 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #808 from ethereum/fixRelevantNode

Fix analysis (fn call at contract scope)
parents ef8592dd b9fec81c
...@@ -49,6 +49,7 @@ abstractAstView.prototype.build_visit = function (relevantNodeFilter) { ...@@ -49,6 +49,7 @@ abstractAstView.prototype.build_visit = function (relevantNodeFilter) {
setCurrentContract(that, { setCurrentContract(that, {
node: node, node: node,
functions: [], functions: [],
relevantNodes: [],
modifiers: [], modifiers: [],
inheritsFrom: [], inheritsFrom: [],
stateVariables: common.getStateVariableDeclarationsFormContractNode(node) stateVariables: common.getStateVariableDeclarationsFormContractNode(node)
...@@ -65,6 +66,12 @@ abstractAstView.prototype.build_visit = function (relevantNodeFilter) { ...@@ -65,6 +66,12 @@ abstractAstView.prototype.build_visit = function (relevantNodeFilter) {
localVariables: getLocalVariables(node), localVariables: getLocalVariables(node),
parameters: getLocalParameters(node) parameters: getLocalParameters(node)
}) })
// push back relevant nodes to their the current fn if any
getCurrentContract(that).relevantNodes.map((item) => {
if (item.referencedDeclaration === node.id) {
getCurrentFunction(that).relevantNodes.push(item.node)
}
})
} else if (common.isModifierDefinition(node)) { } else if (common.isModifierDefinition(node)) {
setCurrentModifier(that, { setCurrentModifier(that, {
node: node, node: node,
...@@ -76,7 +83,15 @@ abstractAstView.prototype.build_visit = function (relevantNodeFilter) { ...@@ -76,7 +83,15 @@ abstractAstView.prototype.build_visit = function (relevantNodeFilter) {
if (!that.isFunctionNotModifier) throw new Error('abstractAstView.js: Found modifier invocation outside of function scope.') if (!that.isFunctionNotModifier) throw new Error('abstractAstView.js: Found modifier invocation outside of function scope.')
getCurrentFunction(that).modifierInvocations.push(node) getCurrentFunction(that).modifierInvocations.push(node)
} else if (relevantNodeFilter(node)) { } else if (relevantNodeFilter(node)) {
((that.isFunctionNotModifier) ? getCurrentFunction(that) : getCurrentModifier(that)).relevantNodes.push(node) var scope = (that.isFunctionNotModifier) ? getCurrentFunction(that) : getCurrentModifier(that)
if (scope) {
scope.relevantNodes.push(node)
} else {
scope = getCurrentContract(that) // if we are not in a function scope, add the node to the contract scope
if (scope && node.children[0] && node.children[0].attributes && node.children[0].attributes.referencedDeclaration) {
scope.relevantNodes.push({ referencedDeclaration: node.children[0].attributes.referencedDeclaration, node: node })
}
}
} }
} }
} }
......
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