diff --git a/examples/sizes.txt b/examples/sizes.txt index 23cb4f4676..839b4604ed 100644 --- a/examples/sizes.txt +++ b/examples/sizes.txt @@ -9,7 +9,7 @@ arc4_types/Arc4Address 91 62 29 62 0 arc4_types/Arc4Arrays 670 376 294 376 0 arc4_types/Arc4BoolEval 761 14 747 14 0 - arc4_types/Arc4BoolType 376 76 300 76 0 + arc4_types/Arc4BoolType 412 76 336 76 0 arc4_types/Arc4DynamicBytes 389 190 199 190 0 arc4_types/Arc4DynamicStringArray 285 112 173 112 0 arc4_types/Arc4MutableParams 418 233 185 230 3 diff --git a/src/puya/awst_build/eb/arc4/bool.py b/src/puya/awst_build/eb/arc4/bool.py index 0108f57510..be84f68b69 100644 --- a/src/puya/awst_build/eb/arc4/bool.py +++ b/src/puya/awst_build/eb/arc4/bool.py @@ -18,6 +18,7 @@ LiteralBuilder, NodeBuilder, ) +from puya.awst_build.utils import require_instance_builder from puya.parse import SourceLocation logger = log.get_logger(__name__) @@ -92,5 +93,11 @@ def member_access(self, name: str, location: SourceLocation) -> NodeBuilder: def compare( self, other: InstanceBuilder, op: BuilderComparisonOp, location: SourceLocation ) -> InstanceBuilder: - # TODO(first): support comparisons with native bool - return compare_bytes(lhs=self, op=op, rhs=other, source_location=location) + match other: + case InstanceBuilder(pytype=pytypes.BoolType): + lhs = require_instance_builder(self.member_access("native", location)) + return lhs.compare(other, op, location) + case InstanceBuilder(pytype=pytypes.ARC4BoolType): + return compare_bytes(lhs=self, op=op, rhs=other, source_location=location) + case _: + return NotImplemented diff --git a/stubs/algopy-stubs/arc4.pyi b/stubs/algopy-stubs/arc4.pyi index d282ad6877..ba75f72d44 100644 --- a/stubs/algopy-stubs/arc4.pyi +++ b/stubs/algopy-stubs/arc4.pyi @@ -224,6 +224,8 @@ class Bool(_ABIEncoded): """An ARC4 encoded bool""" def __init__(self, value: bool = False, /) -> None: ... # noqa: FBT001, FBT002 + def __eq__(self, other: Bool | bool) -> bool: ... # type: ignore[override] + def __ne__(self, other: Bool | bool) -> bool: ... # type: ignore[override] @property def native(self) -> bool: """Return the bool representation of the value after ARC4 decoding""" diff --git a/test_cases/arc4_types/bool.py b/test_cases/arc4_types/bool.py index b6d516cd3c..14c8bbeb33 100644 --- a/test_cases/arc4_types/bool.py +++ b/test_cases/arc4_types/bool.py @@ -41,6 +41,11 @@ def approval_program(self) -> bool: assert dynamic_boolean_array.bytes == Bytes.from_hex("0003A0") + assert ARC4Bool(True) == True # noqa: E712 + assert ARC4Bool(False) != True # noqa: E712 + assert False == ARC4Bool(False) # noqa: E712, SIM300 + assert False != ARC4Bool(True) # noqa: E712, SIM300 + return True def clear_state_program(self) -> bool: diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.mir b/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.mir index a0096ec5e9..3126b962e5 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.mir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.mir @@ -36,52 +36,52 @@ main_ternary_merge@3: // virtual: store tmp%0#0 to l-stack (no copy) tmp%0#0 ARC4Bool(\nFalse if Txn.num_app_args else True # noqa: SIM211\n).native arc4_types/bool.py:14-16 // virtual: load tmp%0#0 from l-stack (no copy) tmp%0#0 assert ARC4Bool(\nFalse if Txn.num_app_args else True # noqa: SIM211\n).native, "conditional expr" arc4_types/bool.py:14-16 assert // conditional expr // assert ARC4Bool(\nFalse if Txn.num_app_args else True # noqa: SIM211\n).native, "conditional expr" arc4_types/bool.py:14-16 - int 1 // 1 True arc4_types/bool.py:44 - return // return True arc4_types/bool.py:44 + int 1 // 1 True arc4_types/bool.py:49 + return // return True arc4_types/bool.py:49 // test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> uint64: test_stuff: - proto 2 1 // (𝕡) true#0,false#0 | @subroutine\ndef test_stuff(self, true: ARC4Bool, false: ARC4Bool) -> bool: arc4_types/bool.py:49-50 + proto 2 1 // (𝕡) true#0,false#0 | @subroutine\ndef test_stuff(self, true: ARC4Bool, false: ARC4Bool) -> bool: arc4_types/bool.py:54-55 test_stuff_block@0: - frame_dig -2 // load true#0 from parameters (𝕡) true#0,false#0 | true#0 true.native arc4_types/bool.py:51 + frame_dig -2 // load true#0 from parameters (𝕡) true#0,false#0 | true#0 true.native arc4_types/bool.py:56 int 0 // (𝕡) true#0,false#0 | true#0,0 - getbit // (𝕡) true#0,false#0 | {getbit} true.native arc4_types/bool.py:51 - // virtual: store tmp%0#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0 true.native arc4_types/bool.py:51 - dup // load tmp%0#0 from l-stack (copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%0#0 assert true.native arc4_types/bool.py:51 - assert // (𝕡) true#0,false#0 | tmp%0#0 assert true.native arc4_types/bool.py:51 - frame_dig -1 // load false#0 from parameters (𝕡) true#0,false#0 | tmp%0#0,false#0 false.native arc4_types/bool.py:53 + getbit // (𝕡) true#0,false#0 | {getbit} true.native arc4_types/bool.py:56 + // virtual: store tmp%0#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0 true.native arc4_types/bool.py:56 + dup // load tmp%0#0 from l-stack (copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%0#0 assert true.native arc4_types/bool.py:56 + assert // (𝕡) true#0,false#0 | tmp%0#0 assert true.native arc4_types/bool.py:56 + frame_dig -1 // load false#0 from parameters (𝕡) true#0,false#0 | tmp%0#0,false#0 false.native arc4_types/bool.py:58 int 0 // (𝕡) true#0,false#0 | tmp%0#0,false#0,0 - getbit // (𝕡) true#0,false#0 | tmp%0#0,{getbit} false.native arc4_types/bool.py:53 - // virtual: store tmp%1#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0 false.native arc4_types/bool.py:53 - dup // load tmp%1#0 from l-stack (copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%1#0 not false.native arc4_types/bool.py:53 - ! // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,{!} not false.native arc4_types/bool.py:53 - // virtual: store tmp%2#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%2#0 not false.native arc4_types/bool.py:53 - // virtual: load tmp%2#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%2#0 assert not false.native arc4_types/bool.py:53 - assert // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0 assert not false.native arc4_types/bool.py:53 - byte 0x00 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00 ARC4Bool(true.native) arc4_types/bool.py:55 - int 0 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00,0 ARC4Bool(true.native) arc4_types/bool.py:55 - dig 3 // load tmp%0#0 from l-stack (copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00,0,tmp%0#0 ARC4Bool(true.native) arc4_types/bool.py:55 - setbit // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,{setbit} ARC4Bool(true.native) arc4_types/bool.py:55 - // virtual: store encoded_bool%0#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,encoded_bool%0#0 ARC4Bool(true.native) arc4_types/bool.py:55 - frame_dig -2 // load true#0 from parameters (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,encoded_bool%0#0,true#0 true == ARC4Bool(true.native) arc4_types/bool.py:55 - uncover 1 // load encoded_bool%0#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,true#0,encoded_bool%0#0 true == ARC4Bool(true.native) arc4_types/bool.py:55 - == // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,{==} true == ARC4Bool(true.native) arc4_types/bool.py:55 - // virtual: store tmp%4#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%4#0 true == ARC4Bool(true.native) arc4_types/bool.py:55 - // virtual: load tmp%4#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%4#0 assert true == ARC4Bool(true.native) arc4_types/bool.py:55 - assert // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0 assert true == ARC4Bool(true.native) arc4_types/bool.py:55 - byte 0x00 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00 ARC4Bool(false.native) arc4_types/bool.py:56 - int 0 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00,0 ARC4Bool(false.native) arc4_types/bool.py:56 - uncover 2 // load tmp%1#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,0x00,0,tmp%1#0 ARC4Bool(false.native) arc4_types/bool.py:56 - setbit // (𝕡) true#0,false#0 | tmp%0#0,{setbit} ARC4Bool(false.native) arc4_types/bool.py:56 - // virtual: store encoded_bool%1#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,encoded_bool%1#0 ARC4Bool(false.native) arc4_types/bool.py:56 - frame_dig -1 // load false#0 from parameters (𝕡) true#0,false#0 | tmp%0#0,encoded_bool%1#0,false#0 false == ARC4Bool(false.native) arc4_types/bool.py:56 - uncover 1 // load encoded_bool%1#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,false#0,encoded_bool%1#0 false == ARC4Bool(false.native) arc4_types/bool.py:56 - == // (𝕡) true#0,false#0 | tmp%0#0,{==} false == ARC4Bool(false.native) arc4_types/bool.py:56 - // virtual: store tmp%6#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%6#0 false == ARC4Bool(false.native) arc4_types/bool.py:56 - // virtual: load tmp%6#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%6#0 assert false == ARC4Bool(false.native) arc4_types/bool.py:56 - assert // (𝕡) true#0,false#0 | tmp%0#0 assert false == ARC4Bool(false.native) arc4_types/bool.py:56 - // virtual: load tmp%0#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0 return true.native arc4_types/bool.py:58 - retsub // tmp%0#0 return true.native arc4_types/bool.py:58 + getbit // (𝕡) true#0,false#0 | tmp%0#0,{getbit} false.native arc4_types/bool.py:58 + // virtual: store tmp%1#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0 false.native arc4_types/bool.py:58 + dup // load tmp%1#0 from l-stack (copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%1#0 not false.native arc4_types/bool.py:58 + ! // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,{!} not false.native arc4_types/bool.py:58 + // virtual: store tmp%2#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%2#0 not false.native arc4_types/bool.py:58 + // virtual: load tmp%2#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%2#0 assert not false.native arc4_types/bool.py:58 + assert // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0 assert not false.native arc4_types/bool.py:58 + byte 0x00 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00 ARC4Bool(true.native) arc4_types/bool.py:60 + int 0 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00,0 ARC4Bool(true.native) arc4_types/bool.py:60 + dig 3 // load tmp%0#0 from l-stack (copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00,0,tmp%0#0 ARC4Bool(true.native) arc4_types/bool.py:60 + setbit // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,{setbit} ARC4Bool(true.native) arc4_types/bool.py:60 + // virtual: store encoded_bool%0#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,encoded_bool%0#0 ARC4Bool(true.native) arc4_types/bool.py:60 + frame_dig -2 // load true#0 from parameters (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,encoded_bool%0#0,true#0 true == ARC4Bool(true.native) arc4_types/bool.py:60 + uncover 1 // load encoded_bool%0#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,true#0,encoded_bool%0#0 true == ARC4Bool(true.native) arc4_types/bool.py:60 + == // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,{==} true == ARC4Bool(true.native) arc4_types/bool.py:60 + // virtual: store tmp%4#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%4#0 true == ARC4Bool(true.native) arc4_types/bool.py:60 + // virtual: load tmp%4#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,tmp%4#0 assert true == ARC4Bool(true.native) arc4_types/bool.py:60 + assert // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0 assert true == ARC4Bool(true.native) arc4_types/bool.py:60 + byte 0x00 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00 ARC4Bool(false.native) arc4_types/bool.py:61 + int 0 // (𝕡) true#0,false#0 | tmp%0#0,tmp%1#0,0x00,0 ARC4Bool(false.native) arc4_types/bool.py:61 + uncover 2 // load tmp%1#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,0x00,0,tmp%1#0 ARC4Bool(false.native) arc4_types/bool.py:61 + setbit // (𝕡) true#0,false#0 | tmp%0#0,{setbit} ARC4Bool(false.native) arc4_types/bool.py:61 + // virtual: store encoded_bool%1#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,encoded_bool%1#0 ARC4Bool(false.native) arc4_types/bool.py:61 + frame_dig -1 // load false#0 from parameters (𝕡) true#0,false#0 | tmp%0#0,encoded_bool%1#0,false#0 false == ARC4Bool(false.native) arc4_types/bool.py:61 + uncover 1 // load encoded_bool%1#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,false#0,encoded_bool%1#0 false == ARC4Bool(false.native) arc4_types/bool.py:61 + == // (𝕡) true#0,false#0 | tmp%0#0,{==} false == ARC4Bool(false.native) arc4_types/bool.py:61 + // virtual: store tmp%6#0 to l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%6#0 false == ARC4Bool(false.native) arc4_types/bool.py:61 + // virtual: load tmp%6#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0,tmp%6#0 assert false == ARC4Bool(false.native) arc4_types/bool.py:61 + assert // (𝕡) true#0,false#0 | tmp%0#0 assert false == ARC4Bool(false.native) arc4_types/bool.py:61 + // virtual: load tmp%0#0 from l-stack (no copy) (𝕡) true#0,false#0 | tmp%0#0 return true.native arc4_types/bool.py:63 + retsub // tmp%0#0 return true.native arc4_types/bool.py:63 diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.teal b/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.teal index 5bbe727532..ab86bc1584 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.teal +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.approval.teal @@ -31,7 +31,7 @@ main_ternary_merge@3: int 0 getbit assert // conditional expr - // arc4_types/bool.py:44 + // arc4_types/bool.py:49 // return True int 1 return @@ -39,18 +39,18 @@ main_ternary_merge@3: // test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> uint64: test_stuff: - // arc4_types/bool.py:49-50 + // arc4_types/bool.py:54-55 // @subroutine // def test_stuff(self, true: ARC4Bool, false: ARC4Bool) -> bool: proto 2 1 - // arc4_types/bool.py:51 + // arc4_types/bool.py:56 // assert true.native frame_dig -2 int 0 getbit dup assert - // arc4_types/bool.py:53 + // arc4_types/bool.py:58 // assert not false.native frame_dig -1 int 0 @@ -58,7 +58,7 @@ test_stuff: dup ! assert - // arc4_types/bool.py:55 + // arc4_types/bool.py:60 // assert true == ARC4Bool(true.native) byte 0x00 int 0 @@ -67,7 +67,7 @@ test_stuff: frame_dig -2 == assert - // arc4_types/bool.py:56 + // arc4_types/bool.py:61 // assert false == ARC4Bool(false.native) byte 0x00 int 0 @@ -76,6 +76,6 @@ test_stuff: frame_dig -1 == assert - // arc4_types/bool.py:58 + // arc4_types/bool.py:63 // return true.native retsub diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.mir b/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.mir index 79efce9e5e..0fa3abc06c 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.mir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.mir @@ -4,6 +4,6 @@ // test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> uint64: main_block@0: - int 1 // 1 True arc4_types/bool.py:47 - return // return True arc4_types/bool.py:47 + int 1 // 1 True arc4_types/bool.py:52 + return // return True arc4_types/bool.py:52 diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.teal b/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.teal index 415feaebae..e420dd0805 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.teal +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.clear.teal @@ -1,7 +1,7 @@ #pragma version 10 test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program: - // arc4_types/bool.py:47 + // arc4_types/bool.py:52 // return True int 1 return diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.destructured.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.destructured.ir index 533f71f453..7816c038b3 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.destructured.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.destructured.ir @@ -18,7 +18,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -34,5 +34,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.ir index df2413794b..3ef9cf272b 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.ir @@ -84,10 +84,26 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: let dynamic_boolean_array#0: bytes = array_data%1#0 let tmp%5#0: bool = (== dynamic_boolean_array#0 0x0003a0) (assert tmp%5#0) + let encoded_bool%22#0: bytes = (setbit 0x00 0u 1u) + let tmp%6#0: bool = (getbit encoded_bool%22#0 0u) + let tmp%7#0: bool = (== tmp%6#0 1u) + (assert tmp%7#0) + let encoded_bool%23#0: bytes = (setbit 0x00 0u 0u) + let tmp%8#0: bool = (getbit encoded_bool%23#0 0u) + let tmp%9#0: bool = (!= tmp%8#0 1u) + (assert tmp%9#0) + let encoded_bool%24#0: bytes = (setbit 0x00 0u 0u) + let tmp%10#0: bool = (getbit encoded_bool%24#0 0u) + let tmp%11#0: bool = (== tmp%10#0 0u) + (assert tmp%11#0) + let encoded_bool%25#0: bytes = (setbit 0x00 0u 1u) + let tmp%12#0: bool = (getbit encoded_bool%25#0 0u) + let tmp%13#0: bool = (!= tmp%12#0 0u) + (assert tmp%13#0) return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -106,5 +122,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_1.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_1.ir index f39c66ba03..8add89aeb6 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_1.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_1.ir @@ -79,10 +79,25 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: let dynamic_boolean_array#0: bytes = (concat 0x0003 array_head_and_tail%16#0) let tmp%5#0: bool = (== dynamic_boolean_array#0 0x0003a0) (assert tmp%5#0) + let encoded_bool%22#0: bytes = 0x80 + let tmp%6#0: bool = (getbit encoded_bool%22#0 0u) + let tmp%7#0: bool = (== tmp%6#0 1u) + (assert tmp%7#0) + let encoded_bool%23#0: bytes = 0x00 + let tmp%8#0: bool = (getbit encoded_bool%23#0 0u) + let tmp%9#0: bool = (!= tmp%8#0 1u) + (assert tmp%9#0) + let encoded_bool%24#0: bytes = 0x00 + let tmp%10#0: bool = (getbit encoded_bool%24#0 0u) + let tmp%11#0: bool = (! tmp%10#0) + (assert tmp%11#0) + let encoded_bool%25#0: bytes = 0x80 + let tmp%12#0: bool = (getbit encoded_bool%25#0 0u) + (assert tmp%12#0) return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -98,5 +113,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_10.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_10.ir index 765900bed5..941ec3a815 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_10.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_10.ir @@ -33,7 +33,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -49,5 +49,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_11.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_11.ir index 08b030e9f7..7e6d36131b 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_11.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_11.ir @@ -32,7 +32,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -48,5 +48,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_12.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_12.ir index b707fac57c..9b811b6211 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_12.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_12.ir @@ -31,7 +31,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -47,5 +47,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_13.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_13.ir index cb36b1fc3a..c204a1d42e 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_13.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_13.ir @@ -30,7 +30,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -46,5 +46,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_14.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_14.ir index fe0f205e77..0d73d110da 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_14.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_14.ir @@ -29,7 +29,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -45,5 +45,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_15.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_15.ir index 4c2f9911ed..0359fcc0c8 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_15.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_15.ir @@ -25,7 +25,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -41,5 +41,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_16.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_16.ir index 432cea6ce7..82fc09c670 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_16.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_16.ir @@ -23,7 +23,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -39,5 +39,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_17.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_17.ir index 819ca96a0c..ec5a9aca33 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_17.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_17.ir @@ -19,7 +19,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -35,5 +35,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_2.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_2.ir index 56bf51720a..74ffc3254d 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_2.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_2.ir @@ -56,10 +56,21 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: let dynamic_boolean_array#0: bytes = (concat 0x0003 array_head_and_tail%16#0) let tmp%5#0: bool = (== dynamic_boolean_array#0 0x0003a0) (assert tmp%5#0) + let tmp%6#0: bool = 1u + let tmp%7#0: bool = (== tmp%6#0 1u) + (assert tmp%7#0) + let tmp%8#0: bool = 0u + let tmp%9#0: bool = (!= tmp%8#0 1u) + (assert tmp%9#0) + let tmp%10#0: bool = 0u + let tmp%11#0: bool = (! tmp%10#0) + (assert tmp%11#0) + let tmp%12#0: bool = 1u + (assert tmp%12#0) return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -75,5 +86,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_3.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_3.ir index ab01c185f9..e22bdab0e1 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_3.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_3.ir @@ -42,10 +42,16 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: let dynamic_boolean_array#0: bytes = (concat 0x0003 array_head_and_tail%16#0) let tmp%5#0: bool = (== dynamic_boolean_array#0 0x0003a0) (assert tmp%5#0) + let tmp%7#0: bool = 1u + (assert tmp%7#0) + let tmp%9#0: bool = 1u + (assert tmp%9#0) + let tmp%11#0: bool = 1u + (assert tmp%11#0) return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -61,5 +67,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_4.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_4.ir index 89e59f08b8..d36e2f82ae 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_4.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_4.ir @@ -43,7 +43,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -59,5 +59,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_5.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_5.ir index 6c911a4ef6..1b76e47b6f 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_5.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_5.ir @@ -41,7 +41,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -57,5 +57,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_6.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_6.ir index 8007d7186a..7ff919daa5 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_6.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_6.ir @@ -39,7 +39,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -55,5 +55,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_7.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_7.ir index 009dac835a..2ee6a13e07 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_7.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_7.ir @@ -36,7 +36,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -52,5 +52,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_8.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_8.ir index 1dc0adce4a..afb5e9c4da 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_8.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_8.ir @@ -35,7 +35,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -51,5 +51,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_9.ir b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_9.ir index ef23fc3baa..4f747490be 100644 --- a/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_9.ir +++ b/test_cases/arc4_types/out/Arc4BoolTypeContract.ssa.opt_pass_9.ir @@ -34,7 +34,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -50,5 +50,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out/bool.O0.log b/test_cases/arc4_types/out/bool.O0.log index 13b353ea42..2738c9c6a2 100644 --- a/test_cases/arc4_types/out/bool.O0.log +++ b/test_cases/arc4_types/out/bool.O0.log @@ -10,42 +10,42 @@ PC Teal Stack 18 int 0 0x80, 0x00, 0, 0 19 setbit 0x80, 0x00 20 callsub test_stuff 0x80, 0x00 -323 proto 2 1 0x80, 0x00 -326 frame_dig -2 0x80, 0x00, 0x80 -328 int 0 0x80, 0x00, 0x80, 0 -329 getbit 0x80, 0x00, 1 -330 assert 0x80, 0x00 -331 frame_dig -1 0x80, 0x00, 0x00 -333 int 0 0x80, 0x00, 0x00, 0 -334 getbit 0x80, 0x00, 0 -335 ! 0x80, 0x00, 1 -336 assert 0x80, 0x00 -337 frame_dig -2 0x80, 0x00, 0x80 -339 int 0 0x80, 0x00, 0x80, 0 -340 getbit 0x80, 0x00, 1 -341 byte 0x00 0x80, 0x00, 1, 0x00 -342 int 0 0x80, 0x00, 1, 0x00, 0 -343 uncover 2 0x80, 0x00, 0x00, 0, 1 -345 setbit 0x80, 0x00, 0x80 -346 frame_dig -2 0x80, 0x00, 0x80, 0x80 -348 uncover 1 0x80, 0x00, 0x80, 0x80 -350 == 0x80, 0x00, 1 -351 assert 0x80, 0x00 -352 frame_dig -1 0x80, 0x00, 0x00 -354 int 0 0x80, 0x00, 0x00, 0 -355 getbit 0x80, 0x00, 0 -356 byte 0x00 0x80, 0x00, 0, 0x00 -357 int 0 0x80, 0x00, 0, 0x00, 0 -358 uncover 2 0x80, 0x00, 0x00, 0, 0 -360 setbit 0x80, 0x00, 0x00 -361 frame_dig -1 0x80, 0x00, 0x00, 0x00 -363 uncover 1 0x80, 0x00, 0x00, 0x00 -365 == 0x80, 0x00, 1 +359 proto 2 1 0x80, 0x00 +362 frame_dig -2 0x80, 0x00, 0x80 +364 int 0 0x80, 0x00, 0x80, 0 +365 getbit 0x80, 0x00, 1 366 assert 0x80, 0x00 -367 frame_dig -2 0x80, 0x00, 0x80 -369 int 0 0x80, 0x00, 0x80, 0 -370 getbit 0x80, 0x00, 1 -371 retsub 1 +367 frame_dig -1 0x80, 0x00, 0x00 +369 int 0 0x80, 0x00, 0x00, 0 +370 getbit 0x80, 0x00, 0 +371 ! 0x80, 0x00, 1 +372 assert 0x80, 0x00 +373 frame_dig -2 0x80, 0x00, 0x80 +375 int 0 0x80, 0x00, 0x80, 0 +376 getbit 0x80, 0x00, 1 +377 byte 0x00 0x80, 0x00, 1, 0x00 +378 int 0 0x80, 0x00, 1, 0x00, 0 +379 uncover 2 0x80, 0x00, 0x00, 0, 1 +381 setbit 0x80, 0x00, 0x80 +382 frame_dig -2 0x80, 0x00, 0x80, 0x80 +384 uncover 1 0x80, 0x00, 0x80, 0x80 +386 == 0x80, 0x00, 1 +387 assert 0x80, 0x00 +388 frame_dig -1 0x80, 0x00, 0x00 +390 int 0 0x80, 0x00, 0x00, 0 +391 getbit 0x80, 0x00, 0 +392 byte 0x00 0x80, 0x00, 0, 0x00 +393 int 0 0x80, 0x00, 0, 0x00, 0 +394 uncover 2 0x80, 0x00, 0x00, 0, 0 +396 setbit 0x80, 0x00, 0x00 +397 frame_dig -1 0x80, 0x00, 0x00, 0x00 +399 uncover 1 0x80, 0x00, 0x00, 0x00 +401 == 0x80, 0x00, 1 +402 assert 0x80, 0x00 +403 frame_dig -2 0x80, 0x00, 0x80 +405 int 0 0x80, 0x00, 0x80, 0 +406 getbit 0x80, 0x00, 1 +407 retsub 1 23 pop 24 txn NumAppArgs 0 26 bz main_ternary_false@2 @@ -264,5 +264,41 @@ PC Teal Stack 314 byte 0x0003a0 0x0003A0, 0x0003A0 319 == 1 320 assert -321 int 1 1 -322 return 1 \ No newline at end of file +321 byte 0x00 0x00 +322 int 0 0x00, 0 +323 int 1 0x00, 0, 1 +324 setbit 0x80 +325 int 0 0x80, 0 +326 getbit 1 +327 int 1 1, 1 +328 == 1 +329 assert +330 byte 0x00 0x00 +331 int 0 0x00, 0 +332 int 0 0x00, 0, 0 +333 setbit 0x00 +334 int 0 0x00, 0 +335 getbit 0 +336 int 1 0, 1 +337 != 1 +338 assert +339 byte 0x00 0x00 +340 int 0 0x00, 0 +341 int 0 0x00, 0, 0 +342 setbit 0x00 +343 int 0 0x00, 0 +344 getbit 0 +345 int 0 0, 0 +346 == 1 +347 assert +348 byte 0x00 0x00 +349 int 0 0x00, 0 +350 int 1 0x00, 0, 1 +351 setbit 0x80 +352 int 0 0x80, 0 +353 getbit 1 +354 int 0 1, 0 +355 != 1 +356 assert +357 int 1 1 +358 return 1 \ No newline at end of file diff --git a/test_cases/arc4_types/out/bool.awst b/test_cases/arc4_types/out/bool.awst index a0e1c3f52f..4f9f074d38 100644 --- a/test_cases/arc4_types/out/bool.awst +++ b/test_cases/arc4_types/out/bool.awst @@ -10,6 +10,10 @@ contract Arc4BoolTypeContract assert(static_boolean_array[12u - 1u] == arc4_encode(true, arc4.bool), comment="Single boolean can be unpacked") dynamic_boolean_array: arc4.dynamic_array = new arc4.dynamic_array(arc4_encode(true, arc4.bool), arc4_encode(false, arc4.bool), arc4_encode(true, arc4.bool)) assert(reinterpret_cast(dynamic_boolean_array) == hex<"0003A0">) + assert(arc4_decode(arc4_encode(true, arc4.bool), bool) == true) + assert(arc4_decode(arc4_encode(false, arc4.bool), bool) != true) + assert(arc4_decode(arc4_encode(false, arc4.bool), bool) == false) + assert(arc4_decode(arc4_encode(true, arc4.bool), bool) != false) return true } diff --git a/test_cases/arc4_types/out_O2/Arc4BoolTypeContract.destructured.ir b/test_cases/arc4_types/out_O2/Arc4BoolTypeContract.destructured.ir index 533f71f453..7816c038b3 100644 --- a/test_cases/arc4_types/out_O2/Arc4BoolTypeContract.destructured.ir +++ b/test_cases/arc4_types/out_O2/Arc4BoolTypeContract.destructured.ir @@ -18,7 +18,7 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -34,5 +34,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.approval.teal b/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.approval.teal index 5fc7efd703..4dc5cd7a93 100644 --- a/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.approval.teal +++ b/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.approval.teal @@ -298,6 +298,50 @@ main_ternary_merge@3: == assert // arc4_types/bool.py:44 + // assert ARC4Bool(True) == True # noqa: E712 + byte 0x00 + int 0 + int 1 + setbit + int 0 + getbit + int 1 + == + assert + // arc4_types/bool.py:45 + // assert ARC4Bool(False) != True # noqa: E712 + byte 0x00 + int 0 + int 0 + setbit + int 0 + getbit + int 1 + != + assert + // arc4_types/bool.py:46 + // assert False == ARC4Bool(False) # noqa: E712, SIM300 + byte 0x00 + int 0 + int 0 + setbit + int 0 + getbit + int 0 + == + assert + // arc4_types/bool.py:47 + // assert False != ARC4Bool(True) # noqa: E712, SIM300 + byte 0x00 + int 0 + int 1 + setbit + int 0 + getbit + int 0 + != + assert + // arc4_types/bool.py:49 // return True int 1 return @@ -305,24 +349,24 @@ main_ternary_merge@3: // test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> uint64: test_stuff: - // arc4_types/bool.py:49-50 + // arc4_types/bool.py:54-55 // @subroutine // def test_stuff(self, true: ARC4Bool, false: ARC4Bool) -> bool: proto 2 1 - // arc4_types/bool.py:51 + // arc4_types/bool.py:56 // assert true.native frame_dig -2 int 0 getbit assert - // arc4_types/bool.py:53 + // arc4_types/bool.py:58 // assert not false.native frame_dig -1 int 0 getbit ! assert - // arc4_types/bool.py:55 + // arc4_types/bool.py:60 // assert true == ARC4Bool(true.native) frame_dig -2 int 0 @@ -335,7 +379,7 @@ test_stuff: uncover 1 == assert - // arc4_types/bool.py:56 + // arc4_types/bool.py:61 // assert false == ARC4Bool(false.native) frame_dig -1 int 0 @@ -348,7 +392,7 @@ test_stuff: uncover 1 == assert - // arc4_types/bool.py:58 + // arc4_types/bool.py:63 // return true.native frame_dig -2 int 0 diff --git a/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.clear.teal b/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.clear.teal index 415feaebae..e420dd0805 100644 --- a/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.clear.teal +++ b/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.clear.teal @@ -1,7 +1,7 @@ #pragma version 10 test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program: - // arc4_types/bool.py:47 + // arc4_types/bool.py:52 // return True int 1 return diff --git a/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.destructured.ir b/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.destructured.ir index b47d7e2983..9265019f28 100644 --- a/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.destructured.ir +++ b/test_cases/arc4_types/out_unoptimized/Arc4BoolTypeContract.destructured.ir @@ -82,10 +82,26 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: let dynamic_boolean_array#0: bytes = array_data%1#0 let tmp%5#0: bool = (== dynamic_boolean_array#0 0x0003a0) (assert tmp%5#0) + let encoded_bool%22#0: bytes = (setbit 0x00 0u 1u) + let tmp%6#0: bool = (getbit encoded_bool%22#0 0u) + let tmp%7#0: bool = (== tmp%6#0 1u) + (assert tmp%7#0) + let encoded_bool%23#0: bytes = (setbit 0x00 0u 0u) + let tmp%8#0: bool = (getbit encoded_bool%23#0 0u) + let tmp%9#0: bool = (!= tmp%8#0 1u) + (assert tmp%9#0) + let encoded_bool%24#0: bytes = (setbit 0x00 0u 0u) + let tmp%10#0: bool = (getbit encoded_bool%24#0 0u) + let tmp%11#0: bool = (== tmp%10#0 0u) + (assert tmp%11#0) + let encoded_bool%25#0: bytes = (setbit 0x00 0u 1u) + let tmp%12#0: bool = (getbit encoded_bool%25#0 0u) + let tmp%13#0: bool = (!= tmp%12#0 0u) + (assert tmp%13#0) return 1u subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.test_stuff(true: bytes, false: bytes) -> bool: - block@0: // L49 + block@0: // L54 let tmp%0#0: bool = (getbit true#0 0u) (assert tmp%0#0) let tmp%1#0: bool = (getbit false#0 0u) @@ -104,5 +120,5 @@ contract test_cases.arc4_types.bool.Arc4BoolTypeContract: program clear-state: subroutine test_cases.arc4_types.bool.Arc4BoolTypeContract.clear_state_program() -> bool: - block@0: // L46 + block@0: // L51 return 1u \ No newline at end of file diff --git a/test_cases/arc4_types/puya.log b/test_cases/arc4_types/puya.log index 136c0b307f..add64dbf4b 100644 --- a/test_cases/arc4_types/puya.log +++ b/test_cases/arc4_types/puya.log @@ -655,8 +655,8 @@ debug: Added result#9 to Phi node: let result#7: bytes = φ(result#5 <- block@19 debug: Terminated block@26: // after_for_L63 debug: Sealing block@0: // L79 debug: Terminated block@0: // L79 -debug: Sealing block@0: // L49 -debug: Terminated block@0: // L49 +debug: Sealing block@0: // L54 +debug: Terminated block@0: // L54 debug: Sealing block@0: // L12 debug: Terminated block@0: // L12 debug: Sealing block@None: // ternary_true_L15 @@ -668,8 +668,8 @@ debug: Created Phi assignment: let ternary_result%0#2: bool = undefined while tr debug: Added ternary_result%0#0 to Phi node: let ternary_result%0#2: bool = φ(ternary_result%0#0 <- block@1) in block@1: // ternary_true_L15 debug: Added ternary_result%0#1 to Phi node: let ternary_result%0#2: bool = φ(ternary_result%0#0 <- block@1, ternary_result%0#1 <- block@2) in block@2: // ternary_false_L15 debug: Terminated block@3: // ternary_merge_L15 -debug: Sealing block@0: // L46 -debug: Terminated block@0: // L46 +debug: Sealing block@0: // L51 +debug: Terminated block@0: // L51 debug: Sealing block@0: // L12 arc4_types/bool_eval.py:55:9 warning: assertion is always true, ignoring arc4_types/bool_eval.py:56:9 warning: assertion is always true, ignoring @@ -2328,8 +2328,14 @@ debug: Simplified (setbit 0x00 0u 1u) to 0x80 debug: Simplified (setbit 0x00 0u 0u) to 0x00 debug: Simplified (setbit 0x00 0u 1u) to 0x80 debug: Simplified (concat 0x encoded_bool%19#0) to encoded_bool%19#0 +debug: Simplified (setbit 0x00 0u 1u) to 0x80 +debug: Simplified (setbit 0x00 0u 0u) to 0x00 +debug: Simplified (setbit 0x00 0u 0u) to 0x00 +debug: Simplified (== tmp%10#0 0u) to (! tmp%10#0) +debug: Simplified (setbit 0x00 0u 1u) to 0x80 debug: Optimizer: Remove Unused Variables debug: Removing unused variable array_length%0#0 +debug: Removing unused variable tmp%13#0 debug: Optimizer: Inner Txn Field Replacer debug: Optimizer: Simplify Control Ops debug: Optimizer: Remove Linear Jump @@ -2348,9 +2354,9 @@ debug: Optimizer: Remove Linear Jump debug: Optimizer: Remove Empty Blocks debug: Optimizer: Remove Unreachable Blocks debug: Optimizer: Repeated Expression Elimination -debug: Replacing redundant declaration let tmp%3#0: bool = (getbit true#0 0u) with copy of existing registers [Register(ir_type=bool, name='tmp%0', version=0, source_location=arc4_types/bool.py:51:15-26)] -debug: Replacing redundant declaration let tmp%5#0: bool = (getbit false#0 0u) with copy of existing registers [Register(ir_type=bool, name='tmp%1', version=0, source_location=arc4_types/bool.py:53:19-31)] -debug: Replacing redundant declaration let tmp%7#0: bool = (getbit true#0 0u) with copy of existing registers [Register(ir_type=bool, name='tmp%0', version=0, source_location=arc4_types/bool.py:51:15-26)] +debug: Replacing redundant declaration let tmp%3#0: bool = (getbit true#0 0u) with copy of existing registers [Register(ir_type=bool, name='tmp%0', version=0, source_location=arc4_types/bool.py:56:15-26)] +debug: Replacing redundant declaration let tmp%5#0: bool = (getbit false#0 0u) with copy of existing registers [Register(ir_type=bool, name='tmp%1', version=0, source_location=arc4_types/bool.py:58:19-31)] +debug: Replacing redundant declaration let tmp%7#0: bool = (getbit true#0 0u) with copy of existing registers [Register(ir_type=bool, name='tmp%0', version=0, source_location=arc4_types/bool.py:56:15-26)] debug: Found equivalence set: tmp%0#0, tmp%3#0, tmp%7#0 debug: Replacing {tmp%3#0, tmp%7#0} with tmp%0#0 made 2 modifications debug: Found equivalence set: tmp%1#0, tmp%5#0 @@ -2388,6 +2394,10 @@ debug: Simplified (getbit 0x80 0u) to 1u debug: Simplified (< 11u 12u) to 1u debug: Simplified (getbit 0x00 0u) to 0u debug: Simplified (getbit 0x80 0u) to 1u +debug: Simplified (getbit 0x80 0u) to 1u +debug: Simplified (getbit 0x00 0u) to 0u +debug: Simplified (getbit 0x00 0u) to 0u +debug: Simplified (getbit 0x80 0u) to 1u debug: Optimizer: Remove Unused Variables debug: Removing unused variable encoded_bool%0#0 debug: Removing unused variable encoded_bool%1#0 @@ -2411,6 +2421,10 @@ debug: Removing unused variable encoded_bool%19#0 debug: Removing unused variable encoded_bool%20#0 debug: Removing unused variable encoded_bool%21#0 debug: Removing unused variable array_head_and_tail%14#0 +debug: Removing unused variable encoded_bool%22#0 +debug: Removing unused variable encoded_bool%23#0 +debug: Removing unused variable encoded_bool%24#0 +debug: Removing unused variable encoded_bool%25#0 debug: Optimizer: Inner Txn Field Replacer debug: Optimizer: Simplify Control Ops debug: Optimizer: Remove Linear Jump @@ -2447,6 +2461,9 @@ debug: Optimizer: Copy Propagation debug: Optimizer: Intrinsic Simplifier debug: Simplified (setbit 0x80 1u 1u) to 0xc0 debug: Simplified (setbit 0x80 1u 0u) to 0x80 +debug: Simplified (== 1u 1u) to 1u +debug: Simplified (!= 0u 1u) to 1u +debug: Simplified (! 0u) to 1u debug: Optimizer: Remove Unused Variables debug: Removing unused variable is_true%0#0 debug: Removing unused variable is_true%1#0 @@ -2461,6 +2478,10 @@ debug: Removing unused variable is_true%9#0 debug: Removing unused variable index_is_in_bounds%0#0 debug: Removing unused variable is_true%12#0 debug: Removing unused variable is_true%13#0 +debug: Removing unused variable tmp%6#0 +debug: Removing unused variable tmp%8#0 +debug: Removing unused variable tmp%10#0 +debug: Removing unused variable tmp%12#0 debug: Optimizer: Inner Txn Field Replacer debug: Optimizer: Simplify Control Ops debug: Optimizer: Remove Linear Jump @@ -2500,6 +2521,9 @@ debug: Simplified (setbit 0x80 2u 1u) to 0xa0 debug: Optimizer: Remove Unused Variables debug: Removing unused variable array_head_and_tail%1#0 debug: Removing unused variable array_head_and_tail%15#0 +debug: Removing unused variable tmp%7#0 +debug: Removing unused variable tmp%9#0 +debug: Removing unused variable tmp%11#0 debug: Optimizer: Inner Txn Field Replacer debug: Optimizer: Simplify Control Ops debug: Optimizer: Remove Linear Jump