variable getter util

pull/7/head
aniket-engg 5 years ago
parent ad4ba658d8
commit 95f68f04af
  1. 4
      remix-analyzer/src/solidity-analyzer/modules/gasCosts.ts
  2. 10
      remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.ts

@ -1,6 +1,6 @@
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)
}

@ -641,6 +641,15 @@ function isConstantFunction (node: FunctionDefinitionAstNode): boolean {
return node.stateMutability === 'view' || node.stateMutability === 'pure'
}
/**
* 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
@ -1109,6 +1118,7 @@ export {
isDeleteFromDynamicArray,
isAbiNamespaceCall,
isSpecialVariableAccess,
isVariableTurnedIntoGetter,
isDynamicArrayAccess,
isDynamicArrayLengthAccess,
isMappingIndexAccess,

Loading…
Cancel
Save