diff --git a/libethereum/Instruction.cpp b/libethereum/Instruction.cpp index 58e5d045a..130793f93 100644 --- a/libethereum/Instruction.cpp +++ b/libethereum/Instruction.cpp @@ -761,7 +761,7 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes vector locs; map vars; if (compileLispFragment(d, e, _quiet, codes, locs, _vars) == -1) - break; + return false; unsigned codeLoc = o_code.size() + 5 + 1; o_locs.push_back(o_code.size()); pushLocation(o_code, codeLoc + codes.size()); @@ -769,13 +769,28 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes for (auto b: codes) o_code.push_back(b); + bytes ncode[1]; + vector nlocs[1]; + if (compileLispFragment(d, e, _quiet, ncode[0], nlocs[0], _vars) != 1) + return false; + pushLiteral(o_code, codes.size()); + o_code.push_back((byte)Instruction::DUP); + int o = compileLispFragment(d, e, _quiet, o_code, o_locs, _vars); + if (o == 1) + { + o_code.push_back((byte)Instruction::LT); + o_code.push_back((byte)Instruction::NOT); + o_code.push_back((byte)Instruction::MUL); + o_code.push_back((byte)Instruction::DUP); + } + else if (o != -1) + return false; + o_locs.push_back(o_code.size()); pushLocation(o_code, codeLoc); - if (compileLispFragment(d, e, _quiet, o_code, o_locs, _vars) != 1) - break; + appendCode(o_code, o_locs, ncode[0], nlocs[0]); o_code.push_back((byte)Instruction::CODECOPY); - pushLiteral(o_code, codes.size()); outs = 1; } else if (t == "&&")