-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--------- Co-authored-by: Adam Chidlow <achidlow@users.noreply.github.com>
- Loading branch information
1 parent
3f180ec
commit 4c2ed03
Showing
15 changed files
with
378 additions
and
373 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
examples/everything/out/contract.approval_unoptimized.debug.teal
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
import attrs | ||
|
||
from puya.codegen import ops as mir | ||
from puya.codegen.vla import VariableLifetimeAnalysis | ||
from puya.context import CompileContext | ||
from puya.ir import models as ir | ||
from puya.utils import attrs_extend | ||
|
||
|
||
@attrs.frozen | ||
@attrs.define | ||
class ProgramCodeGenContext(CompileContext): | ||
contract: ir.Contract | ||
program: ir.Program | ||
|
||
def for_subroutine(self, subroutine: mir.MemorySubroutine) -> "SubroutineCodeGenContext": | ||
return attrs_extend(SubroutineCodeGenContext, self, subroutine=subroutine) | ||
|
||
|
||
@attrs.define(frozen=False) | ||
class SubroutineCodeGenContext(ProgramCodeGenContext): | ||
subroutine: mir.MemorySubroutine | ||
_vla: VariableLifetimeAnalysis | None = attrs.field(default=None) | ||
|
||
@property | ||
def vla(self) -> VariableLifetimeAnalysis: | ||
if self._vla is None: | ||
self._vla = VariableLifetimeAnalysis.analyze(self.subroutine) | ||
return self._vla | ||
|
||
def invalidate_vla(self) -> None: | ||
self._vla = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.