Merge branch 'dev' into dev-refactor-reentrancy

pull/311/head
Josselin 5 years ago
commit c25aa4fc2e
  1. 2
      slither/core/slither_core.py
  2. 2
      slither/solc_parsing/declarations/contract.py
  3. 5
      slither/solc_parsing/slitherSolc.py
  4. 7
      slither/visitors/expression/constants_folding.py

@ -77,6 +77,8 @@ class Slither(Context):
@property @property
def solc_version(self): def solc_version(self):
"""str: Solidity version.""" """str: Solidity version."""
if self.crytic_compile:
return self.crytic_compile.compiler_version.version
return self._solc_version return self._solc_version
@property @property

@ -20,7 +20,7 @@ class ContractSolc04(Contract):
def __init__(self, slitherSolc, data): def __init__(self, slitherSolc, data):
assert slitherSolc.solc_version.startswith('0.4') #assert slitherSolc.solc_version.startswith('0.4')
super(ContractSolc04, self).__init__() super(ContractSolc04, self).__init__()
self.set_slither(slitherSolc) self.set_slither(slitherSolc)

@ -104,10 +104,7 @@ class SlitherSolc(Slither):
return return
for contract_data in data_loaded[self.get_children()]: for contract_data in data_loaded[self.get_children()]:
# if self.solc_version == '0.3':
# assert contract_data[self.get_key()] == 'Contract'
# contract = ContractSolc03(self, contract_data)
if self.solc_version == '0.4':
assert contract_data[self.get_key()] in ['ContractDefinition', 'PragmaDirective', 'ImportDirective'] assert contract_data[self.get_key()] in ['ContractDefinition', 'PragmaDirective', 'ImportDirective']
if contract_data[self.get_key()] == 'ContractDefinition': if contract_data[self.get_key()] == 'ContractDefinition':
contract = ContractSolc04(self, contract_data) contract = ContractSolc04(self, contract_data)

@ -99,6 +99,13 @@ class ConstantFolding(ExpressionVisitor):
raise NotConstant raise NotConstant
def _post_tuple_expression(self, expression): def _post_tuple_expression(self, expression):
if expression.expressions:
if len(expression.expressions) == 1:
cf = ConstantFolding(expression.expressions[0], self._type)
expr = cf.result()
assert isinstance(expr, Literal)
set_val(expression, int(expr.value))
return
raise NotConstant raise NotConstant
def _post_type_conversion(self, expression): def _post_type_conversion(self, expression):

Loading…
Cancel
Save