mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2394 from ethereum/lll-shifts
Support shl/shr in LLL
This commit is contained in:
commit
d693822a6f
@ -74,6 +74,9 @@ void CompilerState::populateStandard()
|
|||||||
"(def 'szabo 1000000000000)"
|
"(def 'szabo 1000000000000)"
|
||||||
"(def 'finney 1000000000000000)"
|
"(def 'finney 1000000000000000)"
|
||||||
"(def 'ether 1000000000000000000)"
|
"(def 'ether 1000000000000000000)"
|
||||||
|
// these could be replaced by native instructions once supported by EVM
|
||||||
|
"(def 'shl (val shift) (mul val (exp 2 shift)))"
|
||||||
|
"(def 'shr (val shift) (div val (exp 2 shift)))"
|
||||||
"}";
|
"}";
|
||||||
CodeFragment::compile(s, *this);
|
CodeFragment::compile(s, *this);
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,26 @@ BOOST_AUTO_TEST_CASE(sha3_one_arg)
|
|||||||
fromHex("b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6")));
|
fromHex("b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(shift_left)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
(returnlll
|
||||||
|
(return (shl 1 8)))
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
BOOST_CHECK(callFallback() == encodeArgs(u256(256)));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(shift_right)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
(returnlll
|
||||||
|
(return (shr 65536 8)))
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
BOOST_CHECK(callFallback() == encodeArgs(u256(256)));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user