You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a test case that should work and doesn't right now.
contract Container{
int x;
int y;
bool b;
int z;
transaction set() {
b = true;
z = 4;
y = 9;
x = -2;
}
transaction get() returns int{
if (b) {
return x * y;
} else {
return y + z;
}
}
}
main contract SGNotJustInts{
transaction main() returns int{
Container c = new Container();
c.set();
return c.get();
}
}
We generate this Yul, after optimization:
object "SGNotJustInts" {
code {
{
mstore(64, 128)
if callvalue() { revert(0, 0) }
let _1 := datasize("SGNotJustInts_deployed")
codecopy(0, dataoffset("SGNotJustInts_deployed"), _1)
return(0, _1)
}
}
object "SGNotJustInts_deployed" {
code {
{
mstore(64, 128)
if iszero(lt(calldatasize(), 4))
{
let _1 := 0
switch shr(224, calldataload(_1))
case 0xdffeadd0 {
if callvalue() { revert(_1, _1) }
abi_decode_tuple(calldatasize())
let _dd_ret := main()
let memPos := mload(64)
return(memPos, sub(abi_encode_to1(memPos, _dd_ret), memPos))
}
case 0xd49c9f7d {
if callvalue() { revert(_1, _1) }
abi_decode_tuple(calldatasize())
Container_set(address())
return(mload(64), _1)
}
case 0x89fe7992 {
if callvalue() { revert(_1, _1) }
abi_decode_tuple(calldatasize())
let _dd_ret_1 := Container_get(address())
let memPos_1 := mload(64)
return(memPos_1, sub(abi_encode_to1(memPos_1, _dd_ret_1), memPos_1))
}
}
revert(0, 0)
}
function abi_decode_tuple(dataEnd)
{
if slt(add(dataEnd, not(3)), 0) { revert(0, 0) }
}
function abi_encode_to1(headStart, value0) -> tail
{
tail := add(headStart, 32)
mstore(headStart, value0)
}
function main() -> _ret
{
let memPtr := mload(0x40)
let newFreePtr := add(memPtr, 96)
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr))
{
mstore(0, shl(224, 0x4e487b71))
mstore(4, 0x41)
revert(0, 0x24)
}
mstore(0x40, newFreePtr)
Container_set(memPtr)
_ret := Container_get(memPtr)
}
function Container_set(this)
{
let _1 := add(this, 64)
mstore(_1, true)
mstore(_1, 4)
mstore(add(this, 32), 9)
mstore(this, not(1))
}
function Container_get(this) -> _ret
{
switch mload(add(this, 64))
case true {
let _tmp := mload(this)
_ret := mul(_tmp, mload(add(this, 32)))
leave
}
case false {
_ret := add(mload(add(this, 32)), false)
leave
}
}
}
}
}
I think even just doing mstore(_1, true) is garbage, so I need to trace out exactly how booleans are getting represented and written out to memory.
The text was updated successfully, but these errors were encountered:
This is a test case that should work and doesn't right now.
We generate this Yul, after optimization:
I think even just doing
mstore(_1, true)
is garbage, so I need to trace out exactly how booleans are getting represented and written out to memory.The text was updated successfully, but these errors were encountered: