|
|
@ -186,7 +186,7 @@ instrumenter.instrumentFunctionDeclaration = function instrumentFunctionDeclarat |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
instrumenter.instrumentAssertOrRequire = function instrumentAssertOrRequire(contract, expression){ |
|
|
|
instrumenter.addNewBranch = function addNewBranch(contract, expression) { |
|
|
|
contract.branchId += 1; |
|
|
|
contract.branchId += 1; |
|
|
|
const startline = (contract.instrumented.slice(0, expression.start).match(/\n/g) || []).length + 1; |
|
|
|
const startline = (contract.instrumented.slice(0, expression.start).match(/\n/g) || []).length + 1; |
|
|
|
const startcol = expression.start - contract.instrumented.slice(0, expression.start).lastIndexOf('\n') - 1; |
|
|
|
const startcol = expression.start - contract.instrumented.slice(0, expression.start).lastIndexOf('\n') - 1; |
|
|
@ -210,38 +210,20 @@ instrumenter.instrumentAssertOrRequire = function instrumentAssertOrRequire(cont |
|
|
|
}, |
|
|
|
}, |
|
|
|
}], |
|
|
|
}], |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
instrumenter.instrumentAssertOrRequire = function instrumentAssertOrRequire(contract, expression) { |
|
|
|
|
|
|
|
instrumenter.addNewBranch(contract, expression); |
|
|
|
createOrAppendInjectionPoint(contract, expression.start, { |
|
|
|
createOrAppendInjectionPoint(contract, expression.start, { |
|
|
|
type: 'callAssertPreEvent', branchId: contract.branchId, |
|
|
|
type: 'callAssertPreEvent', branchId: contract.branchId, |
|
|
|
}); |
|
|
|
}); |
|
|
|
createOrAppendInjectionPoint(contract, expression.end + 1, { |
|
|
|
createOrAppendInjectionPoint(contract, expression.end + 1, { |
|
|
|
type: 'callAssertPostEvent', branchId: contract.branchId, |
|
|
|
type: 'callAssertPostEvent', branchId: contract.branchId, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
instrumenter.instrumentIfStatement = function instrumentIfStatement(contract, expression) { |
|
|
|
instrumenter.instrumentIfStatement = function instrumentIfStatement(contract, expression) { |
|
|
|
contract.branchId += 1; |
|
|
|
instrumenter.addNewBranch(contract, expression); |
|
|
|
const startline = (contract.instrumented.slice(0, expression.start).match(/\n/g) || []).length + 1; |
|
|
|
|
|
|
|
const startcol = expression.start - contract.instrumented.slice(0, expression.start).lastIndexOf('\n') - 1; |
|
|
|
|
|
|
|
// NB locations for if branches in istanbul are zero length and associated with the start of the if.
|
|
|
|
|
|
|
|
contract.branchMap[contract.branchId] = { |
|
|
|
|
|
|
|
line: startline, |
|
|
|
|
|
|
|
type: 'if', |
|
|
|
|
|
|
|
locations: [{ |
|
|
|
|
|
|
|
start: { |
|
|
|
|
|
|
|
line: startline, column: startcol, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
end: { |
|
|
|
|
|
|
|
line: startline, column: startcol, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
start: { |
|
|
|
|
|
|
|
line: startline, column: startcol, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
end: { |
|
|
|
|
|
|
|
line: startline, column: startcol, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if (expression.consequent.type === 'BlockStatement') { |
|
|
|
if (expression.consequent.type === 'BlockStatement') { |
|
|
|
createOrAppendInjectionPoint(contract, expression.consequent.start + 1, { |
|
|
|
createOrAppendInjectionPoint(contract, expression.consequent.start + 1, { |
|
|
|
type: 'callBranchEvent', branchId: contract.branchId, locationIdx: 0, |
|
|
|
type: 'callBranchEvent', branchId: contract.branchId, locationIdx: 0, |
|
|
|