|
|
@ -182,29 +182,50 @@ class Registrar { |
|
|
|
* @param {Object} expression AST node |
|
|
|
* @param {Object} expression AST node |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
addNewLogicalORBranch(contract, expression) { |
|
|
|
addNewLogicalORBranch(contract, expression) { |
|
|
|
const startContract = contract.instrumented.slice(0, expression.range[0]); |
|
|
|
let start; |
|
|
|
const startline = ( startContract.match(/\n/g) || [] ).length + 1; |
|
|
|
|
|
|
|
|
|
|
|
// Instabul HTML highlighting location data...
|
|
|
|
|
|
|
|
const leftZero = expression.left.range[0]; |
|
|
|
|
|
|
|
const leftOne = expression.left.range[1]; |
|
|
|
|
|
|
|
const rightZero = expression.right.range[0]; |
|
|
|
|
|
|
|
const rightOne = expression.right.range[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start = contract.instrumented.slice(0, leftZero); |
|
|
|
|
|
|
|
const leftStartLine = ( start.match(/\n/g) || [] ).length + 1; |
|
|
|
|
|
|
|
const leftStartCol = leftZero - start.lastIndexOf('\n') - 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start = contract.instrumented.slice(0, leftOne); |
|
|
|
|
|
|
|
const leftEndLine = ( start.match(/\n/g) || [] ).length + 1; |
|
|
|
|
|
|
|
const leftEndCol = leftOne - start.lastIndexOf('\n') - 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start = contract.instrumented.slice(0, rightZero); |
|
|
|
|
|
|
|
const rightStartLine = ( start.match(/\n/g) || [] ).length + 1; |
|
|
|
|
|
|
|
const rightStartCol = rightZero - start.lastIndexOf('\n') - 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start = contract.instrumented.slice(0, rightOne); |
|
|
|
|
|
|
|
const rightEndLine = ( start.match(/\n/g) || [] ).length + 1; |
|
|
|
|
|
|
|
const rightEndCol = rightOne - start.lastIndexOf('\n') - 1; |
|
|
|
|
|
|
|
|
|
|
|
contract.branchId += 1; |
|
|
|
contract.branchId += 1; |
|
|
|
|
|
|
|
|
|
|
|
// NB locations for if branches in istanbul are zero
|
|
|
|
// NB locations for if branches in istanbul are zero
|
|
|
|
// length and associated with the start of the if.
|
|
|
|
// length and associated with the start of the if.
|
|
|
|
contract.branchMap[contract.branchId] = { |
|
|
|
contract.branchMap[contract.branchId] = { |
|
|
|
line: startline, |
|
|
|
line: leftStartLine, |
|
|
|
type: 'cond-expr', |
|
|
|
type: 'cond-expr', |
|
|
|
locations: [{ |
|
|
|
locations: [{ |
|
|
|
start: { |
|
|
|
start: { |
|
|
|
line: startline, column: expression.left.range[0], |
|
|
|
line: leftStartLine, column: leftStartCol, |
|
|
|
}, |
|
|
|
}, |
|
|
|
end: { |
|
|
|
end: { |
|
|
|
line: startline, column: expression.left.range[1], |
|
|
|
line: leftEndLine, column: leftEndCol, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
start: { |
|
|
|
start: { |
|
|
|
line: startline, column: expression.right.range[0], |
|
|
|
line: rightStartLine, column: rightStartCol, |
|
|
|
}, |
|
|
|
}, |
|
|
|
end: { |
|
|
|
end: { |
|
|
|
line: startline, column: expression.right.range[1], |
|
|
|
line: rightEndLine, column: rightEndCol, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}], |
|
|
|
}], |
|
|
|
}; |
|
|
|
}; |
|
|
|