aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-06-22 21:59:05 +0800
committerGitHub <noreply@github.com>2017-06-22 21:59:05 +0800
commitf90a514f80b74518fbbdd7ef3a511df4f13abed2 (patch)
treee0f9959974eef531fcbf70c3fac8bc6a35c57999
parentf823952d9f0cc1e37dec465111db976c7a1830b2 (diff)
parent0175008ffaaeecf1d110ef55f736f8ce45ffe90f (diff)
downloaddexon-solidity-f90a514f80b74518fbbdd7ef3a511df4f13abed2.tar.gz
dexon-solidity-f90a514f80b74518fbbdd7ef3a511df4f13abed2.tar.zst
dexon-solidity-f90a514f80b74518fbbdd7ef3a511df4f13abed2.zip
Merge pull request #2446 from benjaminion/lll-fix-msg-6-args
LLL: Fix msg macro with six arguments.
-rw-r--r--liblll/CompilerState.cpp3
-rw-r--r--test/liblll/EndToEndTest.cpp17
2 files changed, 19 insertions, 1 deletions
diff --git a/liblll/CompilerState.cpp b/liblll/CompilerState.cpp
index 72078535..5d38bb8c 100644
--- a/liblll/CompilerState.cpp
+++ b/liblll/CompilerState.cpp
@@ -49,7 +49,8 @@ void CompilerState::populateStandard()
"(def 'allgas (- (gas) 21))"
"(def 'send (to value) (call allgas to value 0 0 0 0))"
"(def 'send (gaslimit to value) (call gaslimit to value 0 0 0 0))"
- "(def 'msg (gaslimit to value data datasize outsize) { (set x outsize) (set y (alloc @32)) (call gaslimit to value data datasize @0 @32) @0 })"
+ // NOTE: in this macro, memory location 0 is set in order to force msize to be at least 32 bytes.
+ "(def 'msg (gaslimit to value data datasize outsize) { [0]:0 [0]:(msize) (call gaslimit to value data datasize @0 outsize) @0 })"
"(def 'msg (gaslimit to value data datasize) { (call gaslimit to value data datasize 0 32) @0 })"
"(def 'msg (gaslimit to value data) { [0]:data (msg gaslimit to value 0 32) })"
"(def 'msg (to value data) { [0]:data (msg allgas to value 0 32) })"
diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp
index 50949e98..02d024a4 100644
--- a/test/liblll/EndToEndTest.cpp
+++ b/test/liblll/EndToEndTest.cpp
@@ -366,6 +366,23 @@ BOOST_AUTO_TEST_CASE(keccak256_32bytes)
fromHex("b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6")));
}
+BOOST_AUTO_TEST_CASE(msg_six_args)
+{
+ char const* sourceCode = R"(
+ (returnlll
+ (seq
+ (when (= 0 (calldatasize))
+ (seq
+ (mstore 0x40 1)
+ (def 'outsize 0x20)
+ (return (msg 1000 (address) 42 0x40 0x20 outsize) outsize)))
+ (when (= 1 (calldataload 0x00))
+ (return (callvalue)))))
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callFallbackWithValue(42) == encodeArgs(u256(42)));
+}
+
BOOST_AUTO_TEST_CASE(create_1_arg)
{
char const* sourceCode = R"(