diff --git a/src/puya/codegen/builder.py b/src/puya/codegen/builder.py index a787495151..7b2ce95e6a 100644 --- a/src/puya/codegen/builder.py +++ b/src/puya/codegen/builder.py @@ -5,7 +5,6 @@ import structlog from puya.codegen import ops -from puya.codegen.callgraph import CallGraph from puya.codegen.context import ProgramCodeGenContext from puya.codegen.emitprogram import CompiledContract, CompiledProgram from puya.codegen.stack_assignment import ( @@ -410,13 +409,11 @@ def lower_program_ir_to_memory_ir( def compile_program_to_teal( context: CompileContext, contract: models.Contract, program: models.Program ) -> CompiledProgram: - call_graph = CallGraph.build(program) cg_context = attrs_extend( ProgramCodeGenContext, context, contract=contract, program=program, - call_graph=call_graph, ) subroutines = list(lower_program_ir_to_memory_ir(cg_context)) global_stack_assignment(cg_context, subroutines) diff --git a/src/puya/codegen/callgraph.py b/src/puya/codegen/callgraph.py deleted file mode 100644 index 3250f384e3..0000000000 --- a/src/puya/codegen/callgraph.py +++ /dev/null @@ -1,35 +0,0 @@ -import typing - -import networkx as nx # type: ignore[import-untyped] - -from puya.ir import models as ir - - -class CallGraph: - def __init__(self, graph: nx.DiGraph) -> None: - self._graph = graph - - @classmethod - def build(cls, program: ir.Program) -> typing.Self: - graph = nx.DiGraph() - for sub in program.all_subroutines: - for block in sub.body: - for op in block.ops: - match op: - case ( - ir.InvokeSubroutine(target=target) - | ir.Assignment(source=ir.InvokeSubroutine(target=target)) - ): - graph.add_edge(sub.full_name, target.full_name) - return cls(graph) - - def has_path(self, from_: ir.Subroutine, to: ir.Subroutine) -> bool: - from_name = from_.full_name - to_name = to.full_name - if from_name == to_name: - return True - # TODO: TEST THIS - for _, target in nx.dfs_edges(self._graph, source=from_name): # noqa: SIM110 - if target == to_name: - return True - return False diff --git a/src/puya/codegen/context.py b/src/puya/codegen/context.py index 94e7bd9d5b..cb7469abb0 100644 --- a/src/puya/codegen/context.py +++ b/src/puya/codegen/context.py @@ -1,6 +1,5 @@ import attrs -from puya.codegen.callgraph import CallGraph from puya.context import CompileContext from puya.ir import models as ir @@ -9,4 +8,3 @@ class ProgramCodeGenContext(CompileContext): contract: ir.Contract program: ir.Program - call_graph: CallGraph