Browse Source

- Bug fix (failed compilation alert was loaded in a separate thread).

- Coding Standards.
 - Add DebuggingStatusResult in AssemblyDebuggerCtrl
cl-refactor
yann300 10 years ago
committed by yann300
parent
commit
6030db73f7
  1. 25
      mix/AssemblyDebuggerCtrl.cpp
  2. 11
      mix/AssemblyDebuggerCtrl.h
  3. 4
      mix/AssemblyDebuggerModel.cpp
  4. 4
      mix/DebuggingStateWrapper.h
  5. 6
      mix/KeyEventManager.h
  6. 4
      mix/TransactionBuilder.cpp

25
mix/AssemblyDebuggerCtrl.cpp

@ -33,8 +33,9 @@ using namespace dev::mix;
AssemblyDebuggerCtrl::AssemblyDebuggerCtrl(QTextDocument* _doc): Extension(ExtensionDisplayBehavior::ModalDialog)
{
qRegisterMetaType<AssemblyDebuggerData>();
connect(this, SIGNAL(dataAvailable(QList<QObject*>, AssemblyDebuggerData)),
this, SLOT(updateGUI(QList<QObject*>, AssemblyDebuggerData)), Qt::QueuedConnection);
qRegisterMetaType<DebuggingStatusResult>();
connect(this, SIGNAL(dataAvailable(bool, DebuggingStatusResult, QList<QObject*>, AssemblyDebuggerData)),
this, SLOT(updateGUI(bool, DebuggingStatusResult, QList<QObject*>, AssemblyDebuggerData)), Qt::QueuedConnection);
m_modelDebugger = std::unique_ptr<AssemblyDebuggerModel>(new AssemblyDebuggerModel);
m_doc = _doc;
}
@ -65,7 +66,7 @@ void AssemblyDebuggerCtrl::keyPressed(int _key)
if (!m_modelDebugger->compile(m_doc->toPlainText()))
{
AppContext::getInstance()->displayMessageDialog("debugger","compilation failed");
emit dataAvailable(false, DebuggingStatusResult::Compilationfailed);
return;
}
@ -84,15 +85,21 @@ void AssemblyDebuggerCtrl::keyPressed(int _key)
wStates.append(s);
}
AssemblyDebuggerData code = DebuggingStateWrapper::getHumanReadableCode(debuggingContent.executionCode, this);
emit dataAvailable(wStates, code);
emit dataAvailable(true, DebuggingStatusResult::Ok, wStates, code);
});
}
}
void AssemblyDebuggerCtrl::updateGUI(QList<QObject*> _wStates, AssemblyDebuggerData _code)
void AssemblyDebuggerCtrl::updateGUI(bool success, DebuggingStatusResult reason, QList<QObject*> _wStates, AssemblyDebuggerData _code)
{
AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("debugStates", QVariant::fromValue(_wStates));
AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("humanReadableExecutionCode", QVariant::fromValue(std::get<0>(_code)));
AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("bytesCodeMapping", QVariant::fromValue(std::get<1>(_code)));
this->addContentOn(this);
Q_UNUSED(reason);
if (success)
{
AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("debugStates", QVariant::fromValue(_wStates));
AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("humanReadableExecutionCode", QVariant::fromValue(std::get<0>(_code)));
AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("bytesCodeMapping", QVariant::fromValue(std::get<1>(_code)));
this->addContentOn(this);
}
else
AppContext::getInstance()->displayMessageDialog("debugger","compilation failed");
}

11
mix/AssemblyDebuggerCtrl.h

@ -26,7 +26,14 @@
#include "AssemblyDebuggerModel.h"
using AssemblyDebuggerData = std::tuple<QList<QObject*>, dev::mix::QQMLMap*>;
enum DebuggingStatusResult
{
Ok,
Compilationfailed
};
Q_DECLARE_METATYPE(AssemblyDebuggerData)
Q_DECLARE_METATYPE(DebuggingStatusResult)
namespace dev
{
@ -51,10 +58,10 @@ private:
public Q_SLOTS:
void keyPressed(int);
void updateGUI(QList<QObject*> _wStates, AssemblyDebuggerData _code);
void updateGUI(bool success, DebuggingStatusResult reason, QList<QObject*> _wStates = QList<QObject*>(), AssemblyDebuggerData _code = AssemblyDebuggerData());
signals:
void dataAvailable(QList<QObject*> _wStates, AssemblyDebuggerData _code);
void dataAvailable(bool success, DebuggingStatusResult reason, QList<QObject*> _wStates = QList<QObject*>(), AssemblyDebuggerData _code = AssemblyDebuggerData());
};

4
mix/AssemblyDebuggerModel.cpp

@ -81,11 +81,11 @@ DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::by
DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::u256 _value,
dev::u256 _gasPrice,
dev::u256 _gas,
QString code,
QString _code,
KeyPair _key)
{
ConstantCompilationModel compiler;
CompilerResult res = compiler.compile(code);
CompilerResult res = compiler.compile(_code);
if (!res.success)
{
DebuggingContent r;

4
mix/DebuggingStateWrapper.h

@ -111,7 +111,7 @@ class DebuggingStateWrapper: public QObject
Q_PROPERTY(QStringList levels READ levels)
public:
DebuggingStateWrapper(bytes _code, bytes _data, QObject* parent): QObject(parent), m_code(_code), m_data(_data) {}
DebuggingStateWrapper(bytes _code, bytes _data, QObject* _parent): QObject(_parent), m_code(_code), m_data(_data) {}
int step() { return (int)m_state.steps; }
int curPC() { return (int)m_state.curPC; }
int gasCost() { return (int)m_state.gasCost; }
@ -125,7 +125,7 @@ public:
QStringList levels();
DebuggingState state() { return m_state; }
void setState(DebuggingState _state) { m_state = _state; }
static std::tuple<QList<QObject*>, QQMLMap*> getHumanReadableCode(bytes const& code, QObject* _objUsedAsParent);
static std::tuple<QList<QObject*>, QQMLMap*> getHumanReadableCode(bytes const& _code, QObject* _objUsedAsParent);
private:
DebuggingState m_state;

6
mix/KeyEventManager.h

@ -30,13 +30,13 @@ class KeyEventManager: public QObject
public:
KeyEventManager() {}
void registerEvent(const QObject* receiver, const char* slot);
void unRegisterEvent(QObject* receiver);
void registerEvent(const QObject* _receiver, const char* _slot);
void unRegisterEvent(QObject* _receiver);
signals:
void onKeyPressed(int);
public Q_SLOTS:
void keyPressed(QVariant event);
void keyPressed(QVariant _event);
};

4
mix/TransactionBuilder.cpp

@ -33,8 +33,8 @@ Transaction TransactionBuilder::getCreationTransaction(u256 _value, u256 _gasPri
}
Transaction TransactionBuilder::getBasicTransaction(u256 _value, u256 _gasPrice, u256 _gas,
QString address, bytes _data, u256 _nonce, Secret _secret) const
QString _address, bytes _data, u256 _nonce, Secret _secret) const
{
return Transaction(_value, _gasPrice, _gas, dev::fromString(address.toStdString()), _data, _nonce, _secret);
return Transaction(_value, _gasPrice, _gas, dev::fromString(_address.toStdString()), _data, _nonce, _secret);
}

Loading…
Cancel
Save