mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Convenience fixups.
This commit is contained in:
parent
51e6c25164
commit
8a0dcc26c4
@ -142,6 +142,10 @@ AssemblyItem const& Assembly::append(AssemblyItem const& _i)
|
||||
return back();
|
||||
}
|
||||
|
||||
void Assembly::optimise()
|
||||
{
|
||||
}
|
||||
|
||||
bytes Assembly::assemble() const
|
||||
{
|
||||
bytes ret;
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
std::string out() const { std::stringstream ret; streamOut(ret); return ret.str(); }
|
||||
int deposit() const { return m_deposit; }
|
||||
bytes assemble() const;
|
||||
void optimise();
|
||||
std::ostream& streamOut(std::ostream& _out) const;
|
||||
|
||||
private:
|
||||
|
@ -102,7 +102,7 @@ CodeFragment::CodeFragment(sp::utree const& _t, CompilerState& _s, bool _allowAS
|
||||
|
||||
void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
||||
{
|
||||
if (_t.empty())
|
||||
if (_t.tag() == 0 && _t.empty())
|
||||
error<EmptyList>();
|
||||
else if (_t.tag() == 0 && _t.front().which() != sp::utree_type::symbol_type)
|
||||
error<DataNotExecutable>();
|
||||
@ -361,14 +361,17 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
||||
{
|
||||
requireSize(3);
|
||||
requireDeposit(0, 1);
|
||||
int minDep = min(code[1].m_asm.deposit(), code[2].m_asm.deposit());
|
||||
|
||||
m_asm.append(code[0].m_asm);
|
||||
auto pos = m_asm.appendJumpI();
|
||||
m_asm.onePath();
|
||||
m_asm << code[2].m_asm;
|
||||
m_asm.append(code[2].m_asm, minDep);
|
||||
auto end = m_asm.appendJump();
|
||||
m_asm.otherPath();
|
||||
m_asm << pos.tag() << code[1].m_asm << end.tag();
|
||||
m_asm << pos.tag();
|
||||
m_asm.append(code[1].m_asm, minDep);
|
||||
m_asm << end.tag();
|
||||
m_asm.donePaths();
|
||||
}
|
||||
else if (us == "WHEN" || us == "UNLESS")
|
||||
|
@ -43,10 +43,10 @@ public:
|
||||
static CodeFragment compile(std::string const& _src, CompilerState& _s);
|
||||
|
||||
/// Consolidates data and compiles code.
|
||||
bytes code() const { return m_asm.assemble(); }
|
||||
bytes code() { m_asm.optimise(); return m_asm.assemble(); }
|
||||
|
||||
/// Consolidates data and compiles code.
|
||||
std::string assembly() const { return m_asm.out(); }
|
||||
std::string assembly() { m_asm.optimise(); return m_asm.out(); }
|
||||
|
||||
private:
|
||||
template <class T> void error() const { throw T(); }
|
||||
|
Loading…
Reference in New Issue
Block a user