Update SimpleStore.yul

This commit is contained in:
ControlCplusControlV 2022-03-07 21:13:46 -07:00 committed by GitHub
parent a70729779c
commit 457253a46d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 49 additions and 7 deletions

View File

@ -1,11 +1,53 @@
object "SimpleStore" {
code {
datacopy(0, dataoffset("Runtime"), datasize("Runtime"))
return(0, datasize("Runtime"))
}
object "Runtime" {
code {
calldatacopy(0, 0, 36) // write calldata to memory
datacopy(0, dataoffset("Runtime"), datasize("Runtime"))
return(0, datasize("Runtime"))
}
object "Runtime" {
code {
function mslice(position, length) -> result {
result := div(mload(position), exp(2, sub(256, mul(length, 8))))
}
function StoreCalldata.sig(pos) -> res {
res := mslice(StoreCalldata.sig.position(pos), 4)
}
function StoreCalldata.sig.position(_pos) -> _offset {
function StoreCalldata.sig.position._chunk0(pos) -> __r {
__r := 0x00
}
function StoreCalldata.sig.position._chunk1(pos) -> __r {
__r := pos
}
_offset := add(StoreCalldata.sig.position._chunk0(_pos), add(StoreCalldata.sig.position._chunk1(_pos), 0))
}
function StoreCalldata.val(pos) -> res {
res := mslice(StoreCalldata.val.position(pos), 32)
}
function StoreCalldata.val.position(_pos) -> _offset {
function StoreCalldata.val.position._chunk0(pos) -> __r {
__r := 0x04
}
function StoreCalldata.val.position._chunk1(pos) -> __r {
__r := pos
}
_offset := add(StoreCalldata.val.position._chunk0(_pos), add(StoreCalldata.val.position._chunk1(_pos), 0))
}
calldatacopy(0, 0, 36) // write calldata to memory
switch StoreCalldata.sig(0) // select signature from memory (at position 0)
case 0x6057361d { // new signature method
sstore(0, StoreCalldata.val(0)) // sstore calldata value
log2(0, 0, 0x69404ebde4a368ae324ed310becfefc3edfe9e5ebca74464e37ffffd8309a3c1, StoreCalldata.val(0))
}
case 0x6d4ce63c {
mstore(100, sload(0))
return (100, 32)
}
}
}
}
}