diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-10-03 03:47:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-03 03:47:31 +0800 |
commit | 91b20b4bd247ca5163fc562d54ae639eda2532ef (patch) | |
tree | 86dd0ac897b4b67b51f6487b363ab7c21fb54acd | |
parent | e7a1e1abe73700db6bfee9dd2b058b16cc5b2002 (diff) | |
parent | cbd4465a7f0337450316bd38fb8613542fc134b9 (diff) | |
download | dexon-solidity-91b20b4bd247ca5163fc562d54ae639eda2532ef.tar dexon-solidity-91b20b4bd247ca5163fc562d54ae639eda2532ef.tar.gz dexon-solidity-91b20b4bd247ca5163fc562d54ae639eda2532ef.tar.bz2 dexon-solidity-91b20b4bd247ca5163fc562d54ae639eda2532ef.tar.lz dexon-solidity-91b20b4bd247ca5163fc562d54ae639eda2532ef.tar.xz dexon-solidity-91b20b4bd247ca5163fc562d54ae639eda2532ef.tar.zst dexon-solidity-91b20b4bd247ca5163fc562d54ae639eda2532ef.zip |
Merge pull request #3005 from ethereum/lll-instruction
lll: do not expose push/dup/swap/jumpdest as functions
-rw-r--r-- | liblll/CodeFragment.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 4fa2c646..6951c40a 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -113,6 +113,22 @@ CodeFragment::CodeFragment(sp::utree const& _t, CompilerState& _s, bool _allowAS } } +namespace +{ +/// Returns true iff the instruction is valid as a function. +bool validFunctionalInstruction(string us) +{ + auto it = c_instructions.find(us); + return !( + it == c_instructions.end() || + solidity::isPushInstruction(it->second) || + solidity::isDupInstruction(it->second) || + solidity::isSwapInstruction(it->second) || + it->second == solidity::Instruction::JUMPDEST + ); +} +} + void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) { if (_t.tag() == 0 && _t.empty()) @@ -409,7 +425,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) for (auto const& i: cs.macros) _s.macros.insert(i); } - else if (c_instructions.count(us)) + else if (c_instructions.count(us) && validFunctionalInstruction(us)) { auto it = c_instructions.find(us); requireSize(instructionInfo(it->second).args); |