Type.is_dynamic
@ -29,6 +29,10 @@ class ArrayType(Type):
def type(self) -> Type:
return self._type
@property
def is_dynamic(self) -> bool:
return self.length is None
def length(self) -> Optional[Expression]:
return self._length
@ -163,6 +163,10 @@ class ElementaryType(Type):
t = "bytes1"
self._type = t
return self._type in ("bytes", "string")
def type(self) -> str:
@ -32,6 +32,10 @@ class FunctionType(Type):
def storage_size(self) -> Tuple[int, bool]:
return 24, False
return False
def __str__(self):
# Use x.type
# x.name may be empty
@ -23,6 +23,10 @@ class MappingType(Type):
return 32, True
return True
return f"mapping({str(self._from)} => {str(self._to)})"
@ -14,3 +14,8 @@ class Type(SourceMapping, metaclass=abc.ABCMeta):
:return: (int, bool) - the number of bytes this type will require, and whether it must start in
a new slot regardless of whether the current slot can still fit it
"""
@abc.abstractmethod
"""True if the size of the type is dynamic"""
@ -22,6 +22,10 @@ class TypeAlias(Type):
def __hash__(self):
return hash(str(self))
return self.underlying_type.is_dynamic
class TypeAliasTopLevel(TypeAlias, TopLevel):
def __init__(self, underlying_type: Type, name: str, scope: "FileScope"):
@ -35,6 +35,10 @@ class TypeInformation(Type):
raise NotImplementedError
return f"type({self.type.name})"
@ -20,6 +20,10 @@ class UserDefinedType(Type):
super().__init__()
def type(self) -> Union["Contract", "Enum", "Structure"]: