remove solc imports from vyper parsing

pull/2099/head
alpharush 1 year ago
parent 929c2af088
commit eadcd462c3
  1. 8
      slither/vyper_parsing/expressions/expression_parsing.py
  2. 10
      slither/vyper_parsing/expressions/find_variable.py
  3. 13
      slither/vyper_parsing/variables/function_type_variable.py

@ -40,8 +40,6 @@ from slither.core.solidity_types import (
UserDefinedType,
)
from slither.core.declarations.contract import Contract
from slither.solc_parsing.declarations.caller_context import CallerContextExpression
from slither.solc_parsing.exceptions import ParsingError, VariableNotFound
from slither.vyper_parsing.expressions.find_variable import find_variable
from slither.vyper_parsing.type_parsing import parse_type
@ -107,6 +105,8 @@ def parse_expression(expression: Dict, caller_context) -> "Expression":
return literal
if isinstance(expression, Call):
print("Call")
print(expression)
called = parse_expression(expression.func, caller_context)
if isinstance(called, Identifier) and isinstance(called.value, SolidityFunction):
if called.value.name == "empty()":
@ -227,7 +227,7 @@ def parse_expression(expression: Dict, caller_context) -> "Expression":
if len(rets) == 1
else f"tuple({','.join(map(get_type_str, rets))})"
)
print(arguments)
parsed_expr = CallExpression(called, arguments, type_str)
parsed_expr.set_offset(expression.src, caller_context.compilation_unit)
return parsed_expr
@ -235,7 +235,7 @@ def parse_expression(expression: Dict, caller_context) -> "Expression":
if isinstance(expression, Attribute):
member_name = expression.attr
if isinstance(expression.value, Name):
print(expression)
if expression.value.id == "self" and member_name != "balance":
var, was_created = find_variable(member_name, caller_context)
# TODO replace with self

@ -20,20 +20,18 @@ from slither.core.solidity_types import (
MappingType,
TypeAlias,
)
from slither.core.variables.top_level_variable import TopLevelVariable
from slither.core.variables.variable import Variable
from slither.exceptions import SlitherError
from slither.solc_parsing.declarations.caller_context import CallerContextExpression
from slither.solc_parsing.exceptions import VariableNotFound
if TYPE_CHECKING:
from slither.solc_parsing.declarations.function import FunctionSolc
from slither.solc_parsing.declarations.contract import ContractSolc
from slither.vyper_parsing.declarations.function import FunctionVyper
def _find_variable_in_function_parser(
var_name: str,
function_parser: Optional["FunctionSolc"],
function_parser: Optional["FunctionVyper"],
) -> Optional[Variable]:
if function_parser is None:
return None
@ -87,7 +85,7 @@ def _find_in_contract(
def find_variable(
var_name: str,
caller_context: CallerContextExpression,
caller_context,
) -> Tuple[
Union[
Variable,

@ -1,13 +0,0 @@
from typing import Dict
from slither.solc_parsing.variables.variable_declaration import VariableDeclarationSolc
from slither.core.variables.function_type_variable import FunctionTypeVariable
class FunctionTypeVariableSolc(VariableDeclarationSolc):
def __init__(self, variable: FunctionTypeVariable, variable_data: Dict):
super().__init__(variable, variable_data)
@property
def underlying_variable(self) -> FunctionTypeVariable:
return self._variable
Loading…
Cancel
Save