Merge pull request #11 from cgewecke/handle-empty-function-body

Handle empty function body edge case
uport
area 8 years ago committed by GitHub
commit cd4d457945
  1. 5
      instrumentSolidity.js

@ -132,11 +132,16 @@ module.exports = function(contract, fileName, instrumentingActive){
var startcol = expression.start - contract.slice(0,expression.start).lastIndexOf('\n') -1;
var endlineDelta = contract.slice(expression.start).indexOf('{')+1;
var functionDefinition = contract.slice(expression.start, expression.start + endlineDelta);
var lastChar = contract.slice(expression.start, expression.start + endlineDelta + 1).slice(-1);
var endline = startline + (functionDefinition.match(/\n/g)||[]).length;
var endcol = functionDefinition.length - functionDefinition.lastIndexOf('\n')
fnMap[fnId] = {name: expression.name, line: linecount, loc:{start:{line: startline, column:startcol},end:{line:endline, column:endcol}}}
if (lastChar === '}'){
createOrAppendInjectionPoint(expression.start + endlineDelta,{type: "callFunctionEvent", fnId: fnId} );
} else {
createOrAppendInjectionPoint(expression.start + endlineDelta+1,{type: "callFunctionEvent", fnId: fnId} );
}
}
function instrumentIfStatement(expression){
branchId +=1;

Loading…
Cancel
Save