Commit 95f68f04 authored by aniket-engg's avatar aniket-engg

variable getter util

parent ad4ba658
import { default as category } from './categories'
import { default as algorithm } from './algorithmCategories'
import { getFunctionDefinitionName, helpers } from './staticAnalysisCommon'
import { getFunctionDefinitionName, helpers, isVariableTurnedIntoGetter } from './staticAnalysisCommon'
import { ModuleAlgorithm, ModuleCategory, ReportObj, CompilationResult, CompiledContract, AnalyzerModule,
FunctionDefinitionAstNode, VariableDeclarationAstNode } from './../../types'
......@@ -13,7 +13,7 @@ export default class gasCosts implements AnalyzerModule {
warningNodes: any[] = []
visit (node: FunctionDefinitionAstNode | VariableDeclarationAstNode): void {
if ((node.nodeType === 'FunctionDefinition' && node.kind !== 'constructor' && node.implemented) ||
(node.nodeType === 'VariableDeclaration' && node.stateVariable && node.visibility === 'public'))
(node.nodeType === 'VariableDeclaration' && isVariableTurnedIntoGetter(node)))
this.warningNodes.push(node)
}
......
......@@ -642,6 +642,15 @@ function isConstantFunction (node: FunctionDefinitionAstNode): boolean {
}
/**
* True if variable decalaration is converted into a getter method
* @node {ASTNode} variable declaration AstNode
* @return {bool}
*/
function isVariableTurnedIntoGetter (varDeclNode: VariableDeclarationAstNode): boolean {
return varDeclNode.stateVariable && varDeclNode.visibility === 'public';
}
/**
* True if is function defintion has payable modifier
* @node {ASTNode} some AstNode
* @return {bool}
......@@ -1109,6 +1118,7 @@ export {
isDeleteFromDynamicArray,
isAbiNamespaceCall,
isSpecialVariableAccess,
isVariableTurnedIntoGetter,
isDynamicArrayAccess,
isDynamicArrayLengthAccess,
isMappingIndexAccess,
......
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