|
|
@ -94,14 +94,28 @@ class Registrar { |
|
|
|
* @param {Object} expression AST node |
|
|
|
* @param {Object} expression AST node |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
functionDeclaration(contract, expression) { |
|
|
|
functionDeclaration(contract, expression) { |
|
|
|
const startContract = contract.instrumented.slice(0, expression.range[0]); |
|
|
|
let start = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// It's possible functions will have modifiers that take string args
|
|
|
|
|
|
|
|
// which contains an open curly brace. Skip ahead...
|
|
|
|
|
|
|
|
if (expression.modifiers && expression.modifiers.length){ |
|
|
|
|
|
|
|
for (let modifier of expression.modifiers ){ |
|
|
|
|
|
|
|
if (modifier.range[1] > start){ |
|
|
|
|
|
|
|
start = modifier.range[1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
start = expression.range[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const startContract = contract.instrumented.slice(0, start); |
|
|
|
const startline = ( startContract.match(/\n/g) || [] ).length + 1; |
|
|
|
const startline = ( startContract.match(/\n/g) || [] ).length + 1; |
|
|
|
const startcol = expression.range[0] - startContract.lastIndexOf('\n') - 1; |
|
|
|
const startcol = start - startContract.lastIndexOf('\n') - 1; |
|
|
|
|
|
|
|
|
|
|
|
const endlineDelta = contract.instrumented.slice(expression.range[0]).indexOf('{'); |
|
|
|
const endlineDelta = contract.instrumented.slice(start).indexOf('{'); |
|
|
|
const functionDefinition = contract.instrumented.slice( |
|
|
|
const functionDefinition = contract.instrumented.slice( |
|
|
|
expression.range[0], |
|
|
|
start, |
|
|
|
expression.range[0] + endlineDelta |
|
|
|
start + endlineDelta |
|
|
|
); |
|
|
|
); |
|
|
|
const endline = startline + (functionDefinition.match(/\n/g) || []).length; |
|
|
|
const endline = startline + (functionDefinition.match(/\n/g) || []).length; |
|
|
|
const endcol = functionDefinition.length - functionDefinition.lastIndexOf('\n'); |
|
|
|
const endcol = functionDefinition.length - functionDefinition.lastIndexOf('\n'); |
|
|
@ -118,7 +132,7 @@ class Registrar { |
|
|
|
|
|
|
|
|
|
|
|
this._createInjectionPoint( |
|
|
|
this._createInjectionPoint( |
|
|
|
contract, |
|
|
|
contract, |
|
|
|
expression.range[0] + endlineDelta + 1, |
|
|
|
start + endlineDelta + 1, |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: 'injectFunction', |
|
|
|
type: 'injectFunction', |
|
|
|
fnId: contract.fnId, |
|
|
|
fnId: contract.fnId, |
|
|
|