aboutsummaryrefslogtreecommitdiffstats
path: root/liblll/CodeFragment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'liblll/CodeFragment.cpp')
-rw-r--r--liblll/CodeFragment.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp
index 0aef05a9..f37cb8b9 100644
--- a/liblll/CodeFragment.cpp
+++ b/liblll/CodeFragment.cpp
@@ -45,6 +45,10 @@ using namespace dev::lll;
void CodeFragment::finalise(CompilerState const& _cs)
{
+ // NOTE: add this as a safeguard in case the user didn't issue an
+ // explicit stop at the end of the sequence
+ m_asm.append(Instruction::STOP);
+
if (_cs.usedAlloc && _cs.vars.size() && !m_finalised)
{
m_finalised = true;
@@ -232,7 +236,12 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
int c = 0;
for (auto const& i: _t)
if (c++)
- m_asm.append(CodeFragment(i, _s, m_readFile, true).m_asm);
+ {
+ auto fragment = CodeFragment(i, _s, m_readFile, true).m_asm;
+ if ((m_asm.deposit() + fragment.deposit()) < 0)
+ error<IncorrectParameterCount>("The assembly instruction resulted in stack underflow");
+ m_asm.append(fragment);
+ }
}
else if (us == "INCLUDE")
{
@@ -348,7 +357,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
else if (i.which() == sp::utree_type::string_type)
{
auto sr = i.get<sp::basic_string<boost::iterator_range<char const*>, sp::utree_type::string_type>>();
- data.insert(data.end(), (byte const *)sr.begin(), (byte const*)sr.end());
+ data.insert(data.end(), (uint8_t const *)sr.begin(), (uint8_t const*)sr.end());
}
else if (i.which() == sp::utree_type::any_type)
{