Commit 355bb700 authored by app's avatar app

ether transfer in loop tracked

parent e714aaac
...@@ -8,8 +8,12 @@ function etherTransferInLoop () { ...@@ -8,8 +8,12 @@ function etherTransferInLoop () {
} }
etherTransferInLoop.prototype.visit = function (node) { etherTransferInLoop.prototype.visit = function (node) {
if (common.isLoop(node) && common.isTransfer(node)) { if (common.isLoop(node)) {
this.relevantNodes.push(node) var loopBlockStartIndex = common.getLoopBlockStartIndex()
var transferNodes = node.children[loopBlockStartIndex].children.filter(node => (common.isExpressionStatement(node) && common.isTransfer(node)))
if (transferNodes.length > 0) {
this.relevantNodes.push(...transferNodes)
}
} }
} }
......
...@@ -410,6 +410,16 @@ function getUnAssignedTopLevelBinOps (subScope) { ...@@ -410,6 +410,16 @@ function getUnAssignedTopLevelBinOps (subScope) {
return subScope.children.filter(isBinaryOpInExpression) return subScope.children.filter(isBinaryOpInExpression)
} }
function getLoopBlockStartIndex (node) {
if (isLoop(node)) {
if (nodeType(node, exactMatch(nodeTypes.FORSTATEMENT))) {
return 3 // For 'for' loop
} else {
return 1 // For 'while' and 'do-while' loop
}
}
}
// #################### Trivial Node Identification // #################### Trivial Node Identification
function isFunctionDefinition (node) { function isFunctionDefinition (node) {
...@@ -1084,6 +1094,7 @@ module.exports = { ...@@ -1084,6 +1094,7 @@ module.exports = {
getFunctionOrModifierDefinitionParameterPart: getFunctionOrModifierDefinitionParameterPart, getFunctionOrModifierDefinitionParameterPart: getFunctionOrModifierDefinitionParameterPart,
getFunctionOrModifierDefinitionReturnParameterPart: getFunctionOrModifierDefinitionReturnParameterPart, getFunctionOrModifierDefinitionReturnParameterPart: getFunctionOrModifierDefinitionReturnParameterPart,
getUnAssignedTopLevelBinOps: getUnAssignedTopLevelBinOps, getUnAssignedTopLevelBinOps: getUnAssignedTopLevelBinOps,
getLoopBlockStartIndex: getLoopBlockStartIndex,
// #################### Complex Node Identification // #################### Complex Node Identification
isDeleteOfDynamicArray: isDeleteOfDynamicArray, isDeleteOfDynamicArray: isDeleteOfDynamicArray,
......
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