Skip to content

Commit

Permalink
chore: make FuncIRInfo generation private (#3437)
Browse files Browse the repository at this point in the history
this moves generation of `func_t._ir_info` to be closer to where it is
used (and where FuncIRInfo is defined!). since FuncIRInfo is no longer
imported anywhere, it can be changed to a private member of the
function_definitions/common.py module.
  • Loading branch information
charles-cooper committed May 19, 2023
1 parent 11e1ae9 commit 8a28372
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion vyper/codegen/function_definitions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .common import FuncIRInfo, generate_ir_for_function # noqa
from .common import generate_ir_for_function # noqa
5 changes: 4 additions & 1 deletion vyper/codegen/function_definitions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mem_used(self):


@dataclass
class FuncIRInfo:
class _FuncIRInfo:
func_t: ContractFunctionT
gas_estimate: Optional[int] = None
frame_info: Optional[FrameInfo] = None
Expand Down Expand Up @@ -78,6 +78,9 @@ def generate_ir_for_function(
"""
func_t = code._metadata["type"]

# generate _FuncIRInfo
func_t._ir_info = _FuncIRInfo(func_t)

# Validate return statements.
check_single_exit(code)

Expand Down
7 changes: 1 addition & 6 deletions vyper/codegen/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from vyper import ast as vy_ast
from vyper.codegen.core import shr
from vyper.codegen.function_definitions import FuncIRInfo, generate_ir_for_function
from vyper.codegen.function_definitions import generate_ir_for_function
from vyper.codegen.global_context import GlobalContext
from vyper.codegen.ir_node import IRnode
from vyper.exceptions import CompilerPanic
Expand Down Expand Up @@ -136,11 +136,6 @@ def generate_ir_for_module(global_ctx: GlobalContext) -> tuple[IRnode, IRnode]:

init_function: Optional[vy_ast.FunctionDef] = None

# generate all FuncIRInfos
for f in function_defs:
func_t = f._metadata["type"]
func_t._ir_info = FuncIRInfo(func_t)

runtime_functions = [f for f in function_defs if not _is_constructor(f)]
init_function = next((f for f in function_defs if _is_constructor(f)), None)

Expand Down

0 comments on commit 8a28372

Please sign in to comment.