Commit e07c3a51 authored by ninabreznik's avatar ninabreznik

Include internal functions

parent 4fbebfca
...@@ -92,31 +92,39 @@ class ContextualListener { ...@@ -92,31 +92,39 @@ class ContextualListener {
} }
_getGasEstimation (results) { _getGasEstimation (results) {
this.results = results
this.contractName = Object.keys(results.data.contracts[results.source.target])[0] this.contractName = Object.keys(results.data.contracts[results.source.target])[0]
this.target = results.data.contracts[results.source.target] this.target = results.data.contracts[results.source.target]
this.functions = Object.keys(this.target[this.contractName].evm.gasEstimates.external) this.contract = this.target[this.contractName]
this.creationCost = this.target[this.contractName].evm.gasEstimates.creation.totalCost this.estimationObj = this.contract.evm.gasEstimates
if (this.estimationObj.external) this.externalFunctions = Object.keys(this.estimationObj.external)
if (this.estimationObj.internal) this.internalFunctions = Object.keys(this.estimationObj.internal)
this.creationCost = this.estimationObj.creation.totalCost
} }
gasEstimation (node) { gasEstimation (node) {
if (node.name === 'FunctionDefinition') { if (node.name === 'FunctionDefinition') {
var estimation
if (!node.attributes.isConstructor) { if (!node.attributes.isConstructor) {
var functionName = node.attributes.name var functionName = node.attributes.name
var fn if (this.externalFunctions) {
for (var x in this.functions) { return this.estimationObj.external[this._getFn(this.externalFunctions, functionName)]
if (!!~this.functions[x].indexOf(functionName)) { }
fn = this.functions[x] if (this.internalFunctions) {
break return this.estimationObj.internal[this._getFn(this.internalFunctions, functionName)]
}
} }
estimation = this.target[this.contractName].evm.gasEstimates.external[fn]
} else { } else {
estimation = this.creationCost return this.creationCost
}
}
}
_getFn (functions, name) {
for (var x in functions) {
if (!!~functions[x].indexOf(name)) {
var fn = functions[x]
break
} }
} }
return estimation return fn
} }
_highlight (node, compilationResult) { _highlight (node, compilationResult) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment