Skip to content

Commit

Permalink
add annotated ast output
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Nov 14, 2023
1 parent 93c2e31 commit 02af165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion vyper/compiler/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def build_ast_dict(compiler_data: CompilerData) -> dict:
ast_dict = {
"contract_name": str(compiler_data.contract_path),
"ast": ast_to_dict(compiler_data.vyper_module),
"ast": ast_to_dict(compiler_data.vyper_module_annotated),
}
return ast_dict

Expand Down
16 changes: 7 additions & 9 deletions vyper/compiler/phases.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class CompilerData:
----------
vyper_module : vy_ast.Module
Top-level Vyper AST node
vyper_module_annotated : vy_ast.Module
Annotated but unfolded Vyper AST
vyper_module_folded : vy_ast.Module
Folded Vyper AST
Annotated and folded Vyper AST
global_ctx : GlobalContext
Sorted, contextualized representation of the Vyper AST
ir_nodes : IRnode
Expand Down Expand Up @@ -131,16 +133,13 @@ def vyper_module(self):
return self._generate_ast

@cached_property
def vyper_module_unfolded(self) -> vy_ast.Module:
# This phase is intended to generate an AST for tooling use, and is not
# used in the compilation process.

return generate_unfolded_ast(self.contract_path, self.vyper_module, self.input_bundle)
def vyper_module_annotated(self) -> vy_ast.Module:
return generate_annotated_ast(self.contract_path, self.vyper_module, self.input_bundle)

@cached_property
def _folded_module(self):
return generate_folded_ast(
self.contract_path, self.vyper_module, self.input_bundle, self.storage_layout_override
self.contract_path, self.vyper_module_annotated, self.input_bundle, self.storage_layout_override
)

@property
Expand Down Expand Up @@ -234,11 +233,10 @@ def generate_ast(


# destructive -- mutates module in place!
def generate_unfolded_ast(
def generate_annotated_ast(
contract_path: Path | PurePath, vyper_module: vy_ast.Module, input_bundle: InputBundle
) -> vy_ast.Module:
vy_ast.validation.validate_literal_nodes(vyper_module)
vy_ast.folding.replace_builtin_functions(vyper_module)

with input_bundle.search_path(contract_path.parent):
# note: validate_semantics does type inference on the AST
Expand Down

0 comments on commit 02af165

Please sign in to comment.