Skip to content

Commit

Permalink
Pass-by-Ref / Dynamic Scratch Variables via the loads and stores
Browse files Browse the repository at this point in the history
…opcodes (#198)

* Pass-by-Reference Semantics
* Use a Dynamic ScratchVar to "iterate" over other ScratchVar's
* Another approach for E2E testing
  • Loading branch information
tzaffi authored Mar 1, 2022
1 parent 262ffc7 commit cf95165
Show file tree
Hide file tree
Showing 23 changed files with 1,327 additions and 183 deletions.
250 changes: 126 additions & 124 deletions pyteal/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,156 +17,158 @@ from .errors import TealInternalError, TealTypeError, TealInputError, TealCompil
from .config import MAX_GROUP_SIZE, NUM_SLOTS

__all__ = [
"Expr",
"LeafExpr",
"AccountParam",
"Add",
"Addr",
"Bytes",
"Int",
"EnumInt",
"MethodSignature",
"Arg",
"TxnType",
"TxnField",
"TxnExpr",
"TxnaExpr",
"TxnArray",
"TxnObject",
"Txn",
"GtxnExpr",
"GtxnaExpr",
"TxnGroup",
"Gtxn",
"GeneratedID",
"ImportScratchValue",
"Global",
"GlobalField",
"And",
"App",
"AppField",
"OnComplete",
"AppParam",
"Approve",
"Arg",
"Array",
"Assert",
"AssetHolding",
"AssetParam",
"AccountParam",
"InnerTxnBuilder",
"InnerTxn",
"InnerTxnAction",
"Gitxn",
"GitxnExpr",
"GitxnaExpr",
"InnerTxnGroup",
"Array",
"Tmpl",
"Nonce",
"UnaryExpr",
"Btoi",
"Itob",
"Len",
"BitLen",
"Sha256",
"Sha512_256",
"Keccak256",
"Not",
"BitwiseNot",
"Sqrt",
"Pop",
"Balance",
"MinBalance",
"BinaryExpr",
"Add",
"Minus",
"Mul",
"Div",
"Mod",
"Exp",
"Divw",
"BitLen",
"BitwiseAnd",
"BitwiseNot",
"BitwiseOr",
"BitwiseXor",
"ShiftLeft",
"ShiftRight",
"Eq",
"Neq",
"Lt",
"Le",
"Gt",
"Ge",
"GetBit",
"GetByte",
"Ed25519Verify",
"Substring",
"Extract",
"Suffix",
"SetBit",
"SetByte",
"NaryExpr",
"And",
"Or",
"Concat",
"WideRatio",
"If",
"Cond",
"Seq",
"Assert",
"Err",
"Return",
"Approve",
"Reject",
"Subroutine",
"SubroutineDefinition",
"SubroutineDeclaration",
"SubroutineCall",
"SubroutineFnWrapper",
"ScratchSlot",
"ScratchLoad",
"ScratchStore",
"ScratchStackStore",
"ScratchVar",
"MaybeValue",
"MultiValue",
"Break",
"Btoi",
"Bytes",
"BytesAdd",
"BytesMinus",
"BytesDiv",
"BytesMul",
"BytesMod",
"BytesAnd",
"BytesOr",
"BytesXor",
"BytesDiv",
"BytesEq",
"BytesNeq",
"BytesLt",
"BytesLe",
"BytesGt",
"BytesGe",
"BytesGt",
"BytesLe",
"BytesLt",
"BytesMinus",
"BytesMod",
"BytesMul",
"BytesNeq",
"BytesNot",
"BytesOr",
"BytesSqrt",
"BytesXor",
"BytesZero",
"CompileOptions",
"Concat",
"Cond",
"Continue",
"DEFAULT_TEAL_VERSION",
"Div",
"Divw",
"DynamicScratchVar",
"Ed25519Verify",
"EnumInt",
"Eq",
"Err",
"Exp",
"Expr",
"Extract",
"ExtractUint16",
"ExtractUint32",
"ExtractUint64",
"Log",
"While",
"For",
"Break",
"Continue",
"Op",
"Ge",
"GeneratedID",
"GetBit",
"GetByte",
"Gitxn",
"GitxnExpr",
"GitxnaExpr",
"Global",
"GlobalField",
"Gt",
"Gtxn",
"GtxnExpr",
"GtxnaExpr",
"If",
"ImportScratchValue",
"InnerTxn",
"InnerTxnAction",
"InnerTxnBuilder",
"InnerTxnGroup",
"Int",
"Itob",
"Keccak256",
"LabelReference",
"Le",
"LeafExpr",
"Len",
"Log",
"Lt",
"MAX_GROUP_SIZE",
"MAX_TEAL_VERSION",
"MIN_TEAL_VERSION",
"MaybeValue",
"MethodSignature",
"MinBalance",
"Minus",
"Mod",
"Mode",
"Mul",
"MultiValue",
"NUM_SLOTS",
"NaryExpr",
"Neq",
"Nonce",
"Not",
"OnComplete",
"Op",
"Or",
"Pop",
"Reject",
"Return",
"ScratchIndex",
"ScratchLoad",
"ScratchSlot",
"ScratchStackStore",
"ScratchStore",
"ScratchVar",
"Seq",
"SetBit",
"SetByte",
"Sha256",
"Sha512_256",
"ShiftLeft",
"ShiftRight",
"Sqrt",
"Subroutine",
"SubroutineCall",
"SubroutineDeclaration",
"SubroutineDefinition",
"SubroutineFnWrapper",
"Substring",
"Suffix",
"TealBlock",
"TealCompileError",
"TealComponent",
"TealOp",
"TealConditionalBlock",
"TealInputError",
"TealInternalError",
"TealLabel",
"TealBlock",
"TealOp",
"TealSimpleBlock",
"TealConditionalBlock",
"LabelReference",
"MAX_TEAL_VERSION",
"MIN_TEAL_VERSION",
"DEFAULT_TEAL_VERSION",
"CompileOptions",
"compileTeal",
"TealType",
"TealInternalError",
"TealTypeError",
"TealInputError",
"TealCompileError",
"MAX_GROUP_SIZE",
"NUM_SLOTS",
"Tmpl",
"Txn",
"TxnArray",
"TxnExpr",
"TxnField",
"TxnGroup",
"TxnObject",
"TxnType",
"TxnaExpr",
"UnaryExpr",
"While",
"WideRatio",
"compileTeal",
]
16 changes: 12 additions & 4 deletions pyteal/ast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@


# misc
from .scratch import ScratchSlot, ScratchLoad, ScratchStore, ScratchStackStore
from .scratchvar import ScratchVar
from .scratch import (
ScratchIndex,
ScratchLoad,
ScratchSlot,
ScratchStackStore,
ScratchStore,
)
from .scratchvar import DynamicScratchVar, ScratchVar
from .maybe import MaybeValue
from .multi import MultiValue

Expand Down Expand Up @@ -225,10 +231,12 @@
"SubroutineDeclaration",
"SubroutineCall",
"SubroutineFnWrapper",
"ScratchSlot",
"ScratchIndex",
"ScratchLoad",
"ScratchStore",
"ScratchSlot",
"ScratchStackStore",
"ScratchStore",
"DynamicScratchVar",
"ScratchVar",
"MaybeValue",
"MultiValue",
Expand Down
6 changes: 1 addition & 5 deletions pyteal/ast/multi_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import pytest

from .. import *
from typing import List

# this is not necessary but mypy complains if it's not included
from .. import CompileOptions
from .. import *

options = CompileOptions()

Expand Down
Loading

0 comments on commit cf95165

Please sign in to comment.