def remove_constant_declarations(vyper_module: vy_ast.Module) -> None: """ Remove constant declaration nodes. Values for constants are subsituted within the AST during folding. Once type checking is complete their declarations are removed to simplify the AST prior to IR generation. Arguments --------- vyper_module : Module Top-level Vyper AST node. """ for node in vyper_module.get_children(vy_ast.AnnAssign, {"annotation.func.id": "constant"}): vyper_module.remove_from_body(node)
def remove_unused_statements(vyper_module: vy_ast.Module) -> None: """ Remove statement nodes that are unused after type checking. Once type checking is complete, we can remove now-meaningless statements to simplify the AST prior to IR generation. Arguments --------- vyper_module : Module Top-level Vyper AST node. """ # constant declarations - values were substituted within the AST during folding for node in vyper_module.get_children(vy_ast.AnnAssign, {"annotation.func.id": "constant"}): vyper_module.remove_from_body(node) # `implements: interface` statements - validated during type checking for node in vyper_module.get_children(vy_ast.AnnAssign, {"target.id": "implements"}): vyper_module.remove_from_body(node)