Improve slithir conversion

pull/87/head
Josselin 6 years ago
parent b92694b985
commit 0e6e0cb176
  1. 36
      slither/slithir/variables/state_variable.py
  2. 4
      slither/visitors/slithir/expression_to_slithir.py

@ -0,0 +1,36 @@
from .variable import SlithIRVariable
from slither.core.variables.state_variable import StateVariable
from slither.core.children.child_node import ChildNode
class StateIRVariable(StateVariable, SlithIRVariable):
def __init__(self, state_variable):
assert isinstance(state_variable, StateVariable)
super(StateVariable, self).__init__()
# initiate ChildContract
self.set_contract(state_variable.contract)
# initiate Variable
self._name = state_variable.name
self._initial_expression = state_variable.expression
self._type = state_variable.type
self._initialized = state_variable.initialized
self._visibility = state_variable.visibility
self._is_constant = state_variable.is_constant
self._index = 0
@property
def index(self):
return self._index
@index.setter
def index(self, idx):
self._index = idx
@property
def ssa_name(self):
return '{}_{}'.format(self._name, self.index)

@ -1,6 +1,6 @@
import logging
from slither.core.declarations import Function, Structure, SolidityVariable, SolidityFunction
from slither.core.declarations import Function, Structure, SolidityVariable, SolidityFunction, Contract, Enum, Structure
from slither.core.expressions import (AssignmentOperationType,
UnaryOperationType)
from slither.core.solidity_types.array_type import ArrayType
@ -161,7 +161,7 @@ class ExpressionToSlithIR(ExpressionVisitor):
elif isinstance(expression.value, LocalVariable):
set_val(expression, LocalIRVariable(expression.value))
else:
assert isinstance(expression.value, (SolidityVariable, SolidityFunction))
assert isinstance(expression.value, (SolidityVariable, SolidityFunction, Function, Contract, Enum, Structure))
set_val(expression, expression.value)
def _post_index_access(self, expression):

Loading…
Cancel
Save