Browse Source

LLL bugfixes.

GUI state saving.
cl-refactor
Gav Wood 11 years ago
parent
commit
9b98888e26
  1. 5
      alethzero/MainWin.cpp
  2. 20
      libethereum/Instruction.cpp
  3. 2
      libethereum/Instruction.h

5
alethzero/MainWin.cpp

@ -97,6 +97,7 @@ void Main::writeSettings()
s.setValue("peers", m_peers); s.setValue("peers", m_peers);
s.setValue("geometry", saveGeometry()); s.setValue("geometry", saveGeometry());
s.setValue("windowState", saveState());
} }
void Main::readSettings() void Main::readSettings()
@ -104,6 +105,8 @@ void Main::readSettings()
QSettings s("ethereum", "alethzero"); QSettings s("ethereum", "alethzero");
restoreGeometry(s.value("geometry").toByteArray()); restoreGeometry(s.value("geometry").toByteArray());
restoreState(s.value("windowState").toByteArray());
QByteArray b = s.value("address").toByteArray(); QByteArray b = s.value("address").toByteArray();
if (b.isEmpty()) if (b.isEmpty())
@ -366,7 +369,7 @@ void Main::on_destination_textChanged()
void Main::on_data_textChanged() void Main::on_data_textChanged()
{ {
string code = ui->data->toPlainText().toStdString(); string code = ui->data->toPlainText().toStdString();
m_data = code[0] == '(' ? compileLisp(code) : assemble(code); m_data = code[0] == '(' ? compileLisp(code, true) : assemble(code);
ui->code->setPlainText(QString::fromStdString(disassemble(m_data))); ui->code->setPlainText(QString::fromStdString(disassemble(m_data)));
updateFee(); updateFee();
} }

20
libethereum/Instruction.cpp

@ -56,7 +56,7 @@ u256s eth::assemble(std::string const& _code)
return ret; return ret;
} }
u256s eth::compileLisp(std::string const& _code) u256s eth::compileLisp(std::string const& _code, bool _quiet)
{ {
u256s ret; u256s ret;
vector<pair<Instruction, int>> inStack; vector<pair<Instruction, int>> inStack;
@ -92,21 +92,22 @@ u256s eth::compileLisp(std::string const& _code)
string t = string(s, d - s); string t = string(s, d - s);
if (isdigit(t[0])) if (isdigit(t[0]))
{
ret.push_back(u256(t));
if (inStack.size() && !inStack.back().second) if (inStack.size() && !inStack.back().second)
cwarn << "Cannot execute numeric" << t; {
if (!_quiet)
cwarn << "Cannot execute numeric" << t;
}
else else
{ {
ret.push_back(Instruction::PUSH); ret.push_back(Instruction::PUSH);
ret.push_back(u256(t)); ret.push_back(u256(t));
} }
}
else else
{ {
boost::algorithm::to_upper(t); boost::algorithm::to_upper(t);
auto it = c_instructions.find(t); auto it = c_instructions.find(t);
if (it != c_instructions.end()) if (it != c_instructions.end())
{
if (inStack.size()) if (inStack.size())
{ {
if (!inStack.back().second) if (!inStack.back().second)
@ -115,9 +116,10 @@ u256s eth::compileLisp(std::string const& _code)
ret.push_back((u256)it->second); ret.push_back((u256)it->second);
inStack.back().second++; inStack.back().second++;
} }
else else if (!_quiet)
cwarn << "Instruction outside parens" << t; cwarn << "Instruction outside parens" << t;
else }
else if (!_quiet)
cwarn << "Unknown assembler token" << t; cwarn << "Unknown assembler token" << t;
} }
} }
@ -139,12 +141,12 @@ string eth::disassemble(u256s const& _mem)
{ {
if (numerics) if (numerics)
numerics--; numerics--;
ret << " 0x" << hex << n; ret << "0x" << hex << n << " ";
} }
else else
{ {
auto const& ii = iit->second; auto const& ii = iit->second;
ret << " " << ii.name; ret << ii.name << " ";
numerics = ii.additional; numerics = ii.additional;
} }
} }

2
libethereum/Instruction.h

@ -204,6 +204,6 @@ static const std::map<std::string, Instruction> c_instructions =
u256s assemble(std::string const& _code); u256s assemble(std::string const& _code);
std::string disassemble(u256s const& _mem); std::string disassemble(u256s const& _mem);
u256s compileLisp(std::string const& _code); u256s compileLisp(std::string const& _code, bool _quiet = false);
} }

Loading…
Cancel
Save