Browse Source

Merge branch 'develop' into call

cl-refactor
Gav Wood 11 years ago
parent
commit
f1eb1447fd
  1. 3
      CMakeLists.txt
  2. 62
      eth/main.cpp
  3. 2
      libethereum/Instruction.cpp

3
CMakeLists.txt

@ -153,6 +153,9 @@ if (NOT HEADLESS)
add_subdirectory(walleth)
endif ()
enable_testing()
add_test(NAME alltests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testeth)
unset(HEADLESS CACHE)
#unset(TARGET_PLATFORM CACHE)

62
eth/main.cpp

@ -29,9 +29,12 @@
#include "BlockChain.h"
#include "State.h"
#include "FileSystem.h"
#include "Instruction.h"
#include "BuildInfo.h"
using namespace std;
using namespace eth;
using eth::Instruction;
using eth::c_instructionInfo;
bool isTrue(std::string const& _m)
{
@ -83,6 +86,7 @@ void interactiveHelp()
<< " balance Gives the current balance." << endl
<< " transact <secret> <dest> <amount> Executes a given transaction." << endl
<< " send <dest> <amount> Executes a given transaction with current secret." << endl
<< " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl
<< " exit Exits the application." << endl;
}
@ -213,6 +217,9 @@ int main(int argc, char** argv)
cout << " Code by Gav Wood, (c) 2013, 2014." << endl;
cout << " Based on a design by Vitalik Buterin." << endl << endl;
if (!remoteHost.empty())
c.startNetwork(listenPort, remoteHost, remotePort, mode, peers, publicIP, upnp);
while (true)
{
cout << "> " << flush;
@ -289,6 +296,61 @@ int main(int argc, char** argv)
c.transact(us.secret(), dest, amount);
}
else if (cmd == "inspect")
{
string rechex;
cin >> rechex;
c.lock();
auto h = h160(fromHex(rechex));
stringstream s;
auto mem = c.state().contractMemory(h);
u256 next = 0;
unsigned numerics = 0;
bool unexpectedNumeric = false;
for (auto i: mem)
{
if (next < i.first)
{
unsigned j;
for (j = 0; j <= numerics && next + j < i.first; ++j)
s << (j < numerics || unexpectedNumeric ? " 0" : " STOP");
unexpectedNumeric = false;
numerics -= min(numerics, j);
if (next + j < i.first)
s << "\n@" << showbase << hex << i.first << " ";
}
else if (!next)
{
s << "@" << showbase << hex << i.first << " ";
}
auto iit = c_instructionInfo.find((Instruction)(unsigned)i.second);
if (numerics || iit == c_instructionInfo.end() || (u256)(unsigned)iit->first != i.second) // not an instruction or expecting an argument...
{
if (numerics)
numerics--;
else
unexpectedNumeric = true;
s << " " << showbase << hex << i.second;
}
else
{
auto const& ii = iit->second;
s << " " << ii.name;
numerics = ii.additional;
}
next = i.first + 1;
}
string outFile = getDataDir() + "/" + rechex + ".evm";
ofstream ofs;
ofs.open(outFile, ofstream::binary);
ofs.write(s.str().c_str(), s.str().length());
ofs.close();
c.unlock();
}
else if (cmd == "help")
{
interactiveHelp();

2
libethereum/Instruction.cpp

@ -503,7 +503,7 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, u256s
break;
}
unsigned datan = codes.size() - 3;
unsigned datan = (unsigned)codes.size() - 3;
unsigned i = 0;
for (auto it = codes.rbegin(); it != codes.rend(); ++it, ++i)
{

Loading…
Cancel
Save