|
@ -1388,7 +1388,8 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompileState& _s) |
|
|
std::map<std::string, Instruction> const c_unary = { { "!", Instruction::NOT } }; |
|
|
std::map<std::string, Instruction> const c_unary = { { "!", Instruction::NOT } }; |
|
|
|
|
|
|
|
|
vector<CodeFragment> code; |
|
|
vector<CodeFragment> code; |
|
|
CompileState ns; |
|
|
CompileState ns = _s; |
|
|
|
|
|
ns.vars.clear(); |
|
|
int c = 0; |
|
|
int c = 0; |
|
|
for (auto const& i: _t) |
|
|
for (auto const& i: _t) |
|
|
if (c++) |
|
|
if (c++) |
|
@ -1415,10 +1416,10 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompileState& _s) |
|
|
{ |
|
|
{ |
|
|
auto it = c_arith.find(s); |
|
|
auto it = c_arith.find(s); |
|
|
requireMinSize(1); |
|
|
requireMinSize(1); |
|
|
for (unsigned i = 0; i < code.size(); ++i) |
|
|
for (unsigned i = code.size(); i; --i) |
|
|
{ |
|
|
{ |
|
|
requireDeposit(i, 1); |
|
|
requireDeposit(i - 1, 1); |
|
|
appendFragment(code[i], 1); |
|
|
appendFragment(code[i - 1], 1); |
|
|
} |
|
|
} |
|
|
for (unsigned i = 1; i < code.size(); ++i) |
|
|
for (unsigned i = 1; i < code.size(); ++i) |
|
|
appendInstruction(it->second); |
|
|
appendInstruction(it->second); |
|
@ -1545,7 +1546,6 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompileState& _s) |
|
|
requireDeposit(i, 1); |
|
|
requireDeposit(i, 1); |
|
|
|
|
|
|
|
|
vector<CodeLocation> ends; |
|
|
vector<CodeLocation> ends; |
|
|
onePath(); |
|
|
|
|
|
if (code.size() > 1) |
|
|
if (code.size() > 1) |
|
|
{ |
|
|
{ |
|
|
appendPush(s == "||" ? 1 : 0); |
|
|
appendPush(s == "||" ? 1 : 0); |
|
@ -1558,12 +1558,10 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompileState& _s) |
|
|
ends.push_back(appendJumpI()); |
|
|
ends.push_back(appendJumpI()); |
|
|
} |
|
|
} |
|
|
appendInstruction(Instruction::POP); |
|
|
appendInstruction(Instruction::POP); |
|
|
otherPath(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Check if true - predicate
|
|
|
// Check if true - predicate
|
|
|
appendFragment(code.back(), 1); |
|
|
appendFragment(code.back(), 1); |
|
|
donePaths(); |
|
|
|
|
|
|
|
|
|
|
|
// At end now.
|
|
|
// At end now.
|
|
|
for (auto& i: ends) |
|
|
for (auto& i: ends) |
|
|