|
|
|
@ -186,7 +186,7 @@ instrumenter.instrumentFunctionDeclaration = function instrumentFunctionDeclarat |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
instrumenter.instrumentAssertOrRequire = function instrumentAssertOrRequire(contract, expression){ |
|
|
|
|
instrumenter.addNewBranch = function addNewBranch(contract, expression) { |
|
|
|
|
contract.branchId += 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; |
|
|
|
@ -210,38 +210,20 @@ instrumenter.instrumentAssertOrRequire = function instrumentAssertOrRequire(cont |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
instrumenter.instrumentAssertOrRequire = function instrumentAssertOrRequire(contract, expression) { |
|
|
|
|
instrumenter.addNewBranch(contract, expression); |
|
|
|
|
createOrAppendInjectionPoint(contract, expression.start, { |
|
|
|
|
type: 'callAssertPreEvent', branchId: contract.branchId, |
|
|
|
|
}); |
|
|
|
|
createOrAppendInjectionPoint(contract, expression.end + 1, { |
|
|
|
|
type: 'callAssertPostEvent', branchId: contract.branchId, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
instrumenter.instrumentIfStatement = function instrumentIfStatement(contract, expression) { |
|
|
|
|
contract.branchId += 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; |
|
|
|
|
// 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, |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
}; |
|
|
|
|
instrumenter.addNewBranch(contract, expression); |
|
|
|
|
if (expression.consequent.type === 'BlockStatement') { |
|
|
|
|
createOrAppendInjectionPoint(contract, expression.consequent.start + 1, { |
|
|
|
|
type: 'callBranchEvent', branchId: contract.branchId, locationIdx: 0, |
|
|
|
|