Skip to content

Commit

Permalink
remove popn exposure, seems not useful here
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangsu committed Nov 21, 2022
1 parent 845b6eb commit 19406de
Show file tree
Hide file tree
Showing 46 changed files with 6 additions and 91 deletions.
40 changes: 0 additions & 40 deletions pyteal/ast/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,46 +353,6 @@ def has_return(self) -> bool:
DupN.__module__ = "pyteal"


class PopN(Expr):
def __init__(self, pop_num: int):
super(PopN, self).__init__()
if pop_num < 0:
raise TealInputError("pop number should be non negative")
self.pop_num = pop_num

def __teal__(self, options: "CompileOptions") -> tuple[TealBlock, TealSimpleBlock]:
if self.pop_num == 0:
srt = TealSimpleBlock([])
end = srt
return srt, end
elif self.pop_num == 1:
verifyProgramVersion(
Op.pop.min_version,
options.version,
"Program version too low to use pop",
)
return TealBlock.FromOp(options, TealOp(self, Op.pop))
else:
verifyProgramVersion(
Op.popn.min_version,
options.version,
"Program version too low to use popn",
)
return TealBlock.FromOp(options, TealOp(self, Op.popn, self.pop_num))

def __str__(self):
return f"(Pop {self.pop_num})"

def has_return(self) -> bool:
return False

def type_of(self) -> TealType:
return TealType.none


PopN.__module__ = "pyteal"


class Bury(Expr):
def __init__(self, depth: int):
super(Bury, self).__init__()
Expand Down
13 changes: 6 additions & 7 deletions pyteal/ast/subroutine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pyteal.ast.expr import Expr
from pyteal.ast.seq import Seq
from pyteal.ast.scratchvar import DynamicScratchVar, ScratchVar, ScratchSlot
from pyteal.ast.frame import PopN, Bury, Proto, FrameVar, ProtoStackLayout
from pyteal.ast.frame import Bury, Proto, FrameVar, ProtoStackLayout
from pyteal.errors import TealInputError, TealInternalError, verifyProgramVersion
from pyteal.ir import TealOp, Op, TealBlock
from pyteal.types import TealType
Expand Down Expand Up @@ -1038,12 +1038,11 @@ def __call__(self, subroutine: SubroutineDefinition) -> SubroutineDeclaration:

if self.use_frame_pt:
assert proto.mem_layout
pop_num = len(proto.mem_layout.local_stack_types)
if output_carrying_abi:
pop_num -= proto.num_returns
deferred_expr = PopN(pop_num)
elif 0 < proto.num_returns < pop_num:
deferred_expr = Seq(Bury(pop_num), PopN(pop_num - 1))
depth = len(proto.mem_layout.local_stack_types)
# only when we have 1 return, and with other local variables
# we use bury to bury the result to 0 index against frame pointer
if not abi_output_kwargs and 0 < proto.num_returns < depth:
deferred_expr = Bury(depth)

# Arg usage "A" to be pick up and store in scratch parameters that have been placed on the stack
# need to reverse order of argumentVars because the last argument will be on top of the stack
Expand Down
1 change: 0 additions & 1 deletion tests/integration/teal/roundtrip/app_roundtrip_()_v8.teal
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ concat
load 8
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ concat
load 9
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ concat
load 9
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// bool_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ concat
load 8
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub

// numerical_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,5 +696,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -496,5 +496,4 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -467,5 +467,4 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -605,5 +605,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ int 2
frame_dig 2
setbit
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,4 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -678,5 +678,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ frame_dig 2
setbyte
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ itob
extract 6 0
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ itob
extract 4 0
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,4 @@ concat
frame_dig 2
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -686,5 +686,4 @@ concat
load 4
concat
frame_bury 0
popn 2
retsub
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ frame_dig 2
itob
concat
frame_bury 0
popn 2
retsub
Loading

0 comments on commit 19406de

Please sign in to comment.