elif isinstance(item, ast.AnnAssign): _custom_units, _contracts, _events, _globals, _getters = add_globals_and_events(_custom_units, _contracts, _defs, _events, _getters, _globals, item) # Function definitions elif isinstance(item, ast.FunctionDef): if item.name in _globals: raise FunctionDeclarationException("Function name shadowing a variable name: %s" % item.name) _defs.append(item) else: raise StructureException("Invalid top-level statement", item) return _contracts, _events, _defs + _getters, _globals, _custom_units # Header code initializer_list = ['seq', ['mstore', 28, ['calldataload', 0]]] # Store limit constants at fixed addresses in memory. initializer_list += [['mstore', pos, limit_size] for pos, limit_size in LOADED_LIMIT_MAP.items()] initializer_lll = LLLnode.from_list(initializer_list, typ=None) # Is a function the initializer? def is_initializer(code): return code.name == '__init__' # Is a function the default function? def is_default_func(code): return code.name == '__default__' # Get ABI signature def mk_full_signature(code):
def parse_to_ast(code): class_names, code = pre_parse(code) if '\x00' in code: raise ParserException( 'No null bytes (\\x00) allowed in the source code.') o = ast.parse(code) # python ast decorate_ast(o, code, class_names) # decorated python ast o = resolve_negative_literals(o) return o.body # Header code initializer_list = ['seq', ['mstore', 28, ['calldataload', 0]]] # Store limit constants at fixed addresses in memory. initializer_list += [['mstore', pos, limit_size] for pos, limit_size in LOADED_LIMIT_MAP.items()] initializer_lll = LLLnode.from_list(initializer_list, typ=None) # Is a function the initializer? def is_initializer(code): return code.name == '__init__' # Is a function the default function? def is_default_func(code): return code.name == '__default__' # Generate default argument function signatures. def generate_default_arg_sigs(code, contracts, global_ctx):
) from vyper.signatures.interface import ( check_valid_contract_interface, ) from vyper.utils import ( LOADED_LIMIT_MAP, ) if not hasattr(ast, 'AnnAssign'): raise Exception("Requires python 3.6 or higher for annotation support") # Header code INITIALIZER_LIST = ['seq', ['mstore', 28, ['calldataload', 0]]] # Store limit constants at fixed addresses in memory. INITIALIZER_LIST += [['mstore', pos, limit_size] for pos, limit_size in LOADED_LIMIT_MAP.items()] INITIALIZER_LLL = LLLnode.from_list(INITIALIZER_LIST, typ=None) def parse_to_ast(source_code: str) -> List[ast.stmt]: """ Parses the given vyper source code and returns a list of python AST objects for all statements in the source. Performs pre-processing of source code before parsing as well as post-processing of the resulting AST. :param source_code: The vyper source code to be parsed. :return: The post-processed list of python AST objects for each statement in ``source_code``. """ class_types, reformatted_code = pre_parse(source_code)