aboutsummaryrefslogtreecommitdiffstats
path: root/liblll
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-10-02 17:25:06 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-10-02 23:21:21 +0800
commitcbd4465a7f0337450316bd38fb8613542fc134b9 (patch)
tree3b8678e515428c6e88db61f2b6f44bbe33abc708 /liblll
parent6cbb726fb8970c6cb98e9b6a2928ef612ad9d760 (diff)
downloaddexon-solidity-cbd4465a7f0337450316bd38fb8613542fc134b9.tar
dexon-solidity-cbd4465a7f0337450316bd38fb8613542fc134b9.tar.gz
dexon-solidity-cbd4465a7f0337450316bd38fb8613542fc134b9.tar.bz2
dexon-solidity-cbd4465a7f0337450316bd38fb8613542fc134b9.tar.lz
dexon-solidity-cbd4465a7f0337450316bd38fb8613542fc134b9.tar.xz
dexon-solidity-cbd4465a7f0337450316bd38fb8613542fc134b9.tar.zst
dexon-solidity-cbd4465a7f0337450316bd38fb8613542fc134b9.zip
lll: do not expose push/dup/swap/jumpdest as functions
Diffstat (limited to 'liblll')
-rw-r--r--liblll/CodeFragment.cpp18
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);