|
|
@ -44,25 +44,25 @@ const std::map<std::string, Instruction> eth::c_instructions = |
|
|
|
{ "GT", Instruction::GT }, |
|
|
|
{ "EQ", Instruction::EQ }, |
|
|
|
{ "NOT", Instruction::NOT }, |
|
|
|
{ "ROTATE", Instruction::ROTATE }, |
|
|
|
{ "AND", Instruction::AND }, |
|
|
|
{ "OR", Instruction::OR }, |
|
|
|
{ "XOR", Instruction::XOR }, |
|
|
|
{ "BYTE", Instruction::BYTE }, |
|
|
|
{ "SHA3", Instruction::SHA3 }, |
|
|
|
{ "ADDRESS", Instruction::ADDRESS }, |
|
|
|
{ "BALANCE", Instruction::BALANCE }, |
|
|
|
{ "ORIGIN", Instruction::ORIGIN }, |
|
|
|
{ "CALLER", Instruction::CALLER }, |
|
|
|
{ "CALLVALUE", Instruction::CALLVALUE }, |
|
|
|
{ "CALLDATA", Instruction::CALLDATA }, |
|
|
|
{ "CALLDATALOAD", Instruction::CALLDATALOAD }, |
|
|
|
{ "CALLDATASIZE", Instruction::CALLDATASIZE }, |
|
|
|
{ "BASEFEE", Instruction::GASPRICE }, |
|
|
|
{ "PREVHASH", Instruction::PREVHASH }, |
|
|
|
{ "PREVNONCE", Instruction::PREVNONCE }, |
|
|
|
{ "COINBASE", Instruction::COINBASE }, |
|
|
|
{ "TIMESTAMP", Instruction::TIMESTAMP }, |
|
|
|
{ "NUMBER", Instruction::NUMBER }, |
|
|
|
{ "DIFFICULTY", Instruction::DIFFICULTY }, |
|
|
|
{ "GASLIMIT", Instruction::GASLIMIT }, |
|
|
|
{ "PUSH", Instruction::PUSH }, |
|
|
|
{ "POP", Instruction::POP }, |
|
|
|
{ "DUP", Instruction::DUP }, |
|
|
@ -75,6 +75,8 @@ const std::map<std::string, Instruction> eth::c_instructions = |
|
|
|
{ "JUMP", Instruction::JUMP }, |
|
|
|
{ "JUMPI", Instruction::JUMPI }, |
|
|
|
{ "PC", Instruction::PC }, |
|
|
|
{ "MEMSIZE", Instruction::MEMSIZE }, |
|
|
|
{ "GAS", Instruction::GAS }, |
|
|
|
{ "CREATE", Instruction::CREATE }, |
|
|
|
{ "CALL", Instruction::CALL }, |
|
|
|
{ "RETURN", Instruction::RETURN }, |
|
|
@ -97,25 +99,25 @@ const std::map<Instruction, InstructionInfo> eth::c_instructionInfo = |
|
|
|
{ Instruction::GT, { "GT", 0, 2, 1 } }, |
|
|
|
{ Instruction::EQ, { "EQ", 0, 2, 1 } }, |
|
|
|
{ Instruction::NOT, { "NOT", 0, 1, 1 } }, |
|
|
|
{ Instruction::ROTATE, { "ROTATE", 0, 2, 1 } }, |
|
|
|
{ Instruction::ADD, { "ADD", 0, 2, 1 } }, |
|
|
|
{ Instruction::OR, { "OR", 0, 2, 1 } }, |
|
|
|
{ Instruction::XOR, { "XOR", 0, 2, 1 } }, |
|
|
|
{ Instruction::BYTE, { "BYTE", 0, 2, 1 } }, |
|
|
|
{ Instruction::SHA3, { "SHA3", 0, 2, 1 } }, |
|
|
|
{ Instruction::ADDRESS, { "ADDRESS", 0, 0, 1 } }, |
|
|
|
{ Instruction::BALANCE, { "BALANCE", 0, 1, 1 } }, |
|
|
|
{ Instruction::ORIGIN, { "ORIGIN", 0, 1, 1 } }, |
|
|
|
{ Instruction::CALLER, { "CALLER", 0, 0, 1 } }, |
|
|
|
{ Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1 } }, |
|
|
|
{ Instruction::CALLDATA, { "CALLDATA", 0, 0, 1 } }, |
|
|
|
{ Instruction::CALLDATALOAD, { "CALLDATALOAD", 0, 1, 1 } }, |
|
|
|
{ Instruction::CALLDATASIZE, { "CALLDATASIZE", 0, 1, 1 } }, |
|
|
|
{ Instruction::GASPRICE, { "BASEFEE", 0, 0, 1 } }, |
|
|
|
{ Instruction::PREVHASH, { "PREVHASH", 0, 0, 1 } }, |
|
|
|
{ Instruction::PREVNONCE, { "PREVNONCE", 0, 0, 1 } }, |
|
|
|
{ Instruction::COINBASE, { "COINBASE", 0, 0, 1 } }, |
|
|
|
{ Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1 } }, |
|
|
|
{ Instruction::NUMBER, { "NUMBER", 0, 0, 1 } }, |
|
|
|
{ Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1 } }, |
|
|
|
{ Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1 } }, |
|
|
|
{ Instruction::PUSH, { "PUSH", 1, 0, 1 } }, |
|
|
|
{ Instruction::POP, { "POP", 0, 1, 0 } }, |
|
|
|
{ Instruction::DUP, { "DUP", 0, 1, 2 } }, |
|
|
@ -128,7 +130,9 @@ const std::map<Instruction, InstructionInfo> eth::c_instructionInfo = |
|
|
|
{ Instruction::JUMP, { "JUMP", 0, 1, 0 } }, |
|
|
|
{ Instruction::JUMPI, { "JUMPI", 0, 2, 0 } }, |
|
|
|
{ Instruction::PC, { "PC", 0, 0, 1 } }, |
|
|
|
{ Instruction::CREATE, { "CREATE", 0, 3, 1 } }, // endowment, first word in memory, data words
|
|
|
|
{ Instruction::MEMSIZE, { "MEMSIZE", 0, 0, 1 } }, |
|
|
|
{ Instruction::GAS, { "GAS", 0, 0, 1 } }, |
|
|
|
{ Instruction::CREATE, { "CREATE", 0, 3, 1 } }, |
|
|
|
{ Instruction::CALL, { "CALL", 0, 7, 1 } }, |
|
|
|
{ Instruction::RETURN, { "RETURN", 0, 2, 0 } }, |
|
|
|
{ Instruction::SUICIDE, { "SUICIDE", 0, 1, 0} } |
|
|
@ -352,16 +356,16 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, u256s |
|
|
|
if (compileLispFragment(d, e, _quiet, codes[3], locs[3]) != -1) |
|
|
|
return false; |
|
|
|
|
|
|
|
// First fragment - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[0], locs[0]); |
|
|
|
|
|
|
|
// Push the positive location.
|
|
|
|
o_code.push_back(Instruction::PUSH); |
|
|
|
unsigned posLocation = (unsigned)o_code.size(); |
|
|
|
o_locs.push_back(posLocation); |
|
|
|
o_code.push_back(0); |
|
|
|
|
|
|
|
// First fragment - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[0], locs[0]); |
|
|
|
|
|
|
|
// Jump to positive if true.
|
|
|
|
// Jump to negative if false.
|
|
|
|
o_code.push_back(Instruction::JUMPI); |
|
|
|
|
|
|
|
// Second fragment - negative.
|
|
|
@ -399,15 +403,15 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, u256s |
|
|
|
if (compileLispFragment(d, e, _quiet, codes[2], locs[2]) != -1) |
|
|
|
return false; |
|
|
|
|
|
|
|
// First fragment - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[0], locs[0]); |
|
|
|
|
|
|
|
// Push the positive location.
|
|
|
|
o_code.push_back(Instruction::PUSH); |
|
|
|
unsigned endLocation = (unsigned)o_code.size(); |
|
|
|
o_locs.push_back(endLocation); |
|
|
|
o_code.push_back(0); |
|
|
|
|
|
|
|
// First fragment - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[0], locs[0]); |
|
|
|
|
|
|
|
// Jump to end...
|
|
|
|
if (t == "WHEN") |
|
|
|
o_code.push_back(Instruction::NOT); |
|
|
@ -439,15 +443,15 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, u256s |
|
|
|
|
|
|
|
unsigned startLocation = (unsigned)o_code.size(); |
|
|
|
|
|
|
|
// First fragment - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[0], locs[0]); |
|
|
|
|
|
|
|
// Push the positive location.
|
|
|
|
o_code.push_back(Instruction::PUSH); |
|
|
|
unsigned endInsertion = (unsigned)o_code.size(); |
|
|
|
o_locs.push_back(endInsertion); |
|
|
|
o_code.push_back(0); |
|
|
|
|
|
|
|
// First fragment - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[0], locs[0]); |
|
|
|
|
|
|
|
// Jump to positive if true.
|
|
|
|
o_code.push_back(Instruction::NOT); |
|
|
|
o_code.push_back(Instruction::JUMPI); |
|
|
@ -568,15 +572,15 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, u256s |
|
|
|
|
|
|
|
for (unsigned i = 1; i < codes.size(); ++i) |
|
|
|
{ |
|
|
|
// Check if true - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[i - 1], locs[i - 1]); |
|
|
|
|
|
|
|
// Push the false location.
|
|
|
|
o_code.push_back(Instruction::PUSH); |
|
|
|
ends.push_back((unsigned)o_code.size()); |
|
|
|
o_locs.push_back(ends.back()); |
|
|
|
o_code.push_back(0); |
|
|
|
|
|
|
|
// Check if true - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[i - 1], locs[i - 1]); |
|
|
|
|
|
|
|
// Jump to end...
|
|
|
|
o_code.push_back(Instruction::NOT); |
|
|
|
o_code.push_back(Instruction::JUMPI); |
|
|
@ -622,15 +626,15 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, u256s |
|
|
|
|
|
|
|
for (unsigned i = 1; i < codes.size(); ++i) |
|
|
|
{ |
|
|
|
// Check if true - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[i - 1], locs[i - 1]); |
|
|
|
|
|
|
|
// Push the false location.
|
|
|
|
o_code.push_back(Instruction::PUSH); |
|
|
|
ends.push_back((unsigned)o_code.size()); |
|
|
|
o_locs.push_back(ends.back()); |
|
|
|
o_code.push_back(0); |
|
|
|
|
|
|
|
// Check if true - predicate
|
|
|
|
appendCode(o_code, o_locs, codes[i - 1], locs[i - 1]); |
|
|
|
|
|
|
|
// Jump to end...
|
|
|
|
o_code.push_back(Instruction::JUMPI); |
|
|
|
} |
|
|
|