-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EVM instruction names #252
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,8 @@ | |
#include <array> | ||
#include "eei.h" | ||
#include "exceptions.h" | ||
#include "evm-instructions.h" | ||
|
||
#include <evmc/instructions.h> | ||
|
||
using namespace std; | ||
using namespace wasm; | ||
|
@@ -177,8 +178,10 @@ inline int64_t maxCallGas(int64_t gas) { | |
heraAssert(sp <= (1024 * stackItemSize), "EVM stack pointer out of bounds."); | ||
heraAssert(opcode >= 0x00 && opcode <= 0xff, "Invalid EVM instruction."); | ||
|
||
auto it = evmInstructionNames.find(static_cast<uint8_t>(opcode)); | ||
string opName = (it != evmInstructionNames.end()) ? it->second : "UNKNOWN"; | ||
const char* const* const opNamesTable = evmc_get_instruction_names_table(EVMC_BYZANTIUM); | ||
const char* opName = opNamesTable[static_cast<uint8_t>(opcode)]; | ||
if (opName == nullptr) | ||
opName = "UNDEFINED"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure tests depends on this, but the "undefined" name comes from https://github.com/ethereum/evmc/blob/master/include/evmc/evmc.h#L229. |
||
|
||
cout << "{\"depth\":" << dec << msg.depth | ||
<< ",\"gas\":" << result.gasLeft | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG, that looks hideous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. If you want I can change it to
const char* const*
:DThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any better option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because you cannot return an array in C. It must be a const pointer to an item (which is
const char*
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can just use
auto
orauto*
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that ensure constness though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The best would be
const auto
.