Browse Source

Better interface for instrInfo.

cl-refactor
Gav Wood 10 years ago
parent
commit
be4bea3c11
  1. 3
      eth/main.cpp
  2. 2
      libethereum/Executive.cpp
  3. 2
      libevmface/Instruction.cpp
  4. 4
      libevmface/Instruction.h
  5. 6
      liblll/Assembly.cpp
  6. 2
      liblll/CodeFragment.cpp
  7. 1
      libqethereum/QEthereum.cpp
  8. 1
      libqethereum/QmlEthereum.cpp
  9. 1
      neth/main.cpp
  10. 1
      third/MainWin.cpp
  11. 1
      walleth/MainWin.cpp

3
eth/main.cpp

@ -45,7 +45,6 @@ using namespace std;
using namespace eth;
using namespace boost::algorithm;
using eth::Instruction;
using eth::c_instructionInfo;
#undef RETURN
@ -610,7 +609,7 @@ int main(int argc, char** argv)
f << " STORAGE" << endl;
for (auto const& i: ext->state().storage(ext->myAddress))
f << showbase << hex << i.first << ": " << i.second << endl;
f << dec << ext->level << " | " << ext->myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm->curPC() << " : " << c_instructionInfo.at(instr).name << " | " << dec << vm->gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32";
f << dec << ext->level << " | " << ext->myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm->curPC() << " : " << eth::instructionInfo(instr).name << " | " << dec << vm->gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32";
};
else if (format == "standard")
oof = [&](uint64_t, Instruction instr, bigint, bigint, void* vvm, void const* vextVM)

2
libethereum/Executive.cpp

@ -158,7 +158,7 @@ OnOpFunc Executive::simpleTrace()
for (auto const& i: ext.state().storage(ext.myAddress))
o << showbase << hex << i.first << ": " << i.second << endl;
eth::LogOutputStream<VMTraceChannel, false>(true) << o.str();
eth::LogOutputStream<VMTraceChannel, false>(false) << " | " << dec << ext.level << " | " << ext.myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm.curPC() << " : " << c_instructionInfo.at(inst).name << " | " << dec << vm.gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32" << " ]";
eth::LogOutputStream<VMTraceChannel, false>(false) << " | " << dec << ext.level << " | " << ext.myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << dec << vm.gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32" << " ]";
};
}

2
libevmface/Instruction.cpp

@ -149,7 +149,7 @@ const std::map<std::string, Instruction> eth::c_instructions =
{ "SUICIDE", Instruction::SUICIDE }
};
const std::map<Instruction, InstructionInfo> eth::c_instructionInfo =
static const std::map<Instruction, InstructionInfo> c_instructionInfo =
{ // Add, Args, Ret
{ Instruction::STOP, { "STOP", 0, 0, 0 } },
{ Instruction::ADD, { "ADD", 0, 2, 1 } },

4
libevmface/Instruction.h

@ -175,10 +175,8 @@ struct InstructionInfo
int ret; ///< Number of items placed (back) on the stack by this instruction, assuming args items were removed.
};
InstructionInfo instructionInfo(Instruction _inst);
/// Information on all the instructions.
extern const std::map<Instruction, InstructionInfo> c_instructionInfo;
InstructionInfo instructionInfo(Instruction _inst);
/// Convert from string mnemonic to Instruction type.
extern const std::map<std::string, Instruction> c_instructions;

6
liblll/Assembly.cpp

@ -31,7 +31,7 @@ int AssemblyItem::deposit() const
switch (m_type)
{
case Operation:
return c_instructionInfo.at((Instruction)(byte)m_data).ret - c_instructionInfo.at((Instruction)(byte)m_data).args;
return instructionInfo((Instruction)(byte)m_data).ret - instructionInfo((Instruction)(byte)m_data).args;
case Push: case PushString: case PushTag: case PushData: case PushSub: case PushSubSize:
return 1;
case Tag:
@ -116,7 +116,7 @@ ostream& eth::operator<<(ostream& _out, AssemblyItemsConstRef _i)
switch (i.type())
{
case Operation:
_out << " " << c_instructionInfo.at((Instruction)(byte)i.data()).name;
_out << " " << instructionInfo((Instruction)(byte)i.data()).name;
break;
case Push:
_out << " PUSH" << i.data();
@ -153,7 +153,7 @@ ostream& Assembly::streamOut(ostream& _out, string const& _prefix) const
switch (i.m_type)
{
case Operation:
_out << _prefix << " " << c_instructionInfo.at((Instruction)(byte)i.m_data).name << endl;
_out << _prefix << " " << instructionInfo((Instruction)(byte)i.m_data).name << endl;
break;
case Push:
_out << _prefix << " PUSH " << i.m_data << endl;

2
liblll/CodeFragment.cpp

@ -369,7 +369,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
else if (c_instructions.count(us))
{
auto it = c_instructions.find(us);
int ea = c_instructionInfo.at(it->second).args;
int ea = instructionInfo(it->second).args;
if (ea >= 0)
requireSize(ea);
else

1
libqethereum/QEthereum.cpp

@ -43,7 +43,6 @@ using eth::operator +;
// vars
using eth::g_logPost;
using eth::g_logVerbosity;
using eth::c_instructionInfo;
eth::bytes toBytes(QString const& _s)
{

1
libqethereum/QmlEthereum.cpp

@ -45,7 +45,6 @@ using eth::units;
// vars
using eth::g_logPost;
using eth::g_logVerbosity;
using eth::c_instructionInfo;
// Horrible global for the mainwindow. Needed for the QmlEthereums to find the Main window which acts as multiplexer for now.
// Can get rid of this once we've sorted out ITC for signalling & multiplexed querying.

1
neth/main.cpp

@ -51,7 +51,6 @@ using namespace std;
using namespace eth;
using namespace boost::algorithm;
using eth::Instruction;
using eth::c_instructionInfo;
bool isTrue(std::string const& _m)
{

1
third/MainWin.cpp

@ -81,7 +81,6 @@ using eth::operator<<;
// vars
using eth::g_logPost;
using eth::g_logVerbosity;
using eth::c_instructionInfo;
static QString fromRaw(eth::h256 _n, unsigned* _inc = nullptr)
{

1
walleth/MainWin.cpp

@ -50,7 +50,6 @@ using eth::units;
// vars
using eth::g_logPost;
using eth::g_logVerbosity;
using eth::c_instructionInfo;
Main::Main(QWidget *parent) :
QMainWindow(parent),

Loading…
Cancel
Save