def __init__(self): super().__init__() self._scopes = [] # NOTE cyclic imports! from vyper.builtin_functions.functions import get_builtin_functions from vyper.semantics import environment from vyper.semantics.types import get_types self.update(get_types()) self.update(environment.get_constant_vars()) self.update(get_builtin_functions())
def types_from_List(self, node): # literal array if not node.elements: # empty list literal `[]` # subtype can be anything types_list = types.get_types() # 1 is minimum possible length for dynarray, assignable to anything ret = [DynamicArrayDefinition(t, 1) for t in types_list] return ret types_list = get_common_types(*node.elements) if len(types_list) > 0: count = len(node.elements) ret = [] ret.extend([ArrayDefinition(t, count) for t in types_list]) ret.extend([DynamicArrayDefinition(t, count) for t in types_list]) return ret raise InvalidLiteral("Array contains multiple, incompatible types", node)
def test_builtin_types_persist_after_clear(namespace): namespace.clear() for key, value in get_types().items(): assert namespace[key] == value
def test_builtin_types(namespace): for key, value in get_types().items(): assert namespace[key] == value