aboutsummaryrefslogtreecommitdiffstats
path: root/liblll
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-06-22 07:43:01 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-06-23 09:52:44 +0800
commitaf57c083f2aa144e765a7345f15713330b192e36 (patch)
treeb0c36e96f70704090fa3211eca09d56bad3b0e18 /liblll
parent1ffe286a81b9bad005cfefa3fc8672aecb0ec0f8 (diff)
downloaddexon-solidity-af57c083f2aa144e765a7345f15713330b192e36.tar
dexon-solidity-af57c083f2aa144e765a7345f15713330b192e36.tar.gz
dexon-solidity-af57c083f2aa144e765a7345f15713330b192e36.tar.bz2
dexon-solidity-af57c083f2aa144e765a7345f15713330b192e36.tar.lz
dexon-solidity-af57c083f2aa144e765a7345f15713330b192e36.tar.xz
dexon-solidity-af57c083f2aa144e765a7345f15713330b192e36.tar.zst
dexon-solidity-af57c083f2aa144e765a7345f15713330b192e36.zip
LLL: fix the set keyword (create symbol if not present)
Diffstat (limited to 'liblll')
-rw-r--r--liblll/CodeFragment.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp
index eeb64270..7496fe83 100644
--- a/liblll/CodeFragment.cpp
+++ b/liblll/CodeFragment.cpp
@@ -171,13 +171,23 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
return string();
};
- auto varAddress = [&](string const& n)
+ auto varAddress = [&](string const& n, bool createMissing = false)
{
if (n.empty())
error<InvalidName>("Empty variable name not allowed");
auto it = _s.vars.find(n);
if (it == _s.vars.end())
- error<InvalidName>(std::string("Symbol not found: ") + n);
+ {
+ if (createMissing)
+ {
+ // Create new variable
+ bool ok;
+ tie(it, ok) = _s.vars.insert(make_pair(n, make_pair(_s.stackSize, 32)));
+ _s.stackSize += 32;
+ }
+ else
+ error<InvalidName>(std::string("Symbol not found: ") + n);
+ }
return it->second.first;
};
@@ -210,7 +220,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
for (auto const& i: _t)
if (c++ == 2)
m_asm.append(CodeFragment(i, _s, false).m_asm);
- m_asm.append((u256)varAddress(firstAsString()));
+ m_asm.append((u256)varAddress(firstAsString(), true));
m_asm.append(Instruction::MSTORE);
}
else if (us == "GET")