Browse Source

Better lll instruction.

cl-refactor
Gav Wood 11 years ago
parent
commit
e089ef4f66
  1. 23
      libethereum/Instruction.cpp

23
libethereum/Instruction.cpp

@ -761,7 +761,7 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes
vector<unsigned> locs; vector<unsigned> locs;
map<string, unsigned> vars; map<string, unsigned> vars;
if (compileLispFragment(d, e, _quiet, codes, locs, _vars) == -1) if (compileLispFragment(d, e, _quiet, codes, locs, _vars) == -1)
break; return false;
unsigned codeLoc = o_code.size() + 5 + 1; unsigned codeLoc = o_code.size() + 5 + 1;
o_locs.push_back(o_code.size()); o_locs.push_back(o_code.size());
pushLocation(o_code, codeLoc + codes.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) for (auto b: codes)
o_code.push_back(b); o_code.push_back(b);
bytes ncode[1];
vector<unsigned> nlocs[1];
if (compileLispFragment(d, e, _quiet, ncode[0], nlocs[0], _vars) != 1)
return false;
pushLiteral(o_code, codes.size()); 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()); o_locs.push_back(o_code.size());
pushLocation(o_code, codeLoc); pushLocation(o_code, codeLoc);
if (compileLispFragment(d, e, _quiet, o_code, o_locs, _vars) != 1) appendCode(o_code, o_locs, ncode[0], nlocs[0]);
break;
o_code.push_back((byte)Instruction::CODECOPY); o_code.push_back((byte)Instruction::CODECOPY);
pushLiteral(o_code, codes.size());
outs = 1; outs = 1;
} }
else if (t == "&&") else if (t == "&&")

Loading…
Cancel
Save