Browse Source

- class / function documentation.

- misc changes.
cl-refactor
yann300 10 years ago
parent
commit
ab85477987
  1. 10
      mix/AppContext.cpp
  2. 18
      mix/AppContext.h
  3. 22
      mix/AssemblyDebuggerCtrl.cpp
  4. 21
      mix/AssemblyDebuggerCtrl.h
  5. 20
      mix/AssemblyDebuggerModel.cpp
  6. 11
      mix/AssemblyDebuggerModel.h
  7. 12
      mix/CodeEditorExtensionManager.h
  8. 9
      mix/ConstantCompilationCtrl.h
  9. 9
      mix/ConstantCompilationModel.h
  10. 23
      mix/ContractCallDataEncoder.cpp
  11. 14
      mix/ContractCallDataEncoder.h
  12. 10
      mix/DebuggingStateWrapper.cpp
  13. 30
      mix/DebuggingStateWrapper.h
  14. 10
      mix/Extension.h
  15. 6
      mix/KeyEventManager.h
  16. 1
      mix/MixApplication.h
  17. 23
      mix/QBasicNodeDefinition.cpp
  18. 6
      mix/QBasicNodeDefinition.h
  19. 11
      mix/QContractDefinition.cpp
  20. 4
      mix/QContractDefinition.h
  21. 2
      mix/QFunctionDefinition.cpp
  22. 3
      mix/QFunctionDefinition.h
  23. 23
      mix/QVariableDeclaration.cpp
  24. 3
      mix/QVariableDeclaration.h
  25. 6
      mix/QVariableDefinition.h

10
mix/AppContext.cpp

@ -26,7 +26,7 @@
#include <QMessageBox>
#include <QQmlComponent>
#include <QQmlApplicationEngine>
#include "libdevcrypto/FileSystem.h"
#include <libdevcrypto/FileSystem.h>
#include "KeyEventManager.h"
#include "AppContext.h"
using namespace dev;
@ -41,7 +41,7 @@ AppContext::AppContext(QQmlApplicationEngine* _engine)
m_applicationEngine = std::unique_ptr<QQmlApplicationEngine>(_engine);
m_keyEventManager = std::unique_ptr<KeyEventManager>(new KeyEventManager());
m_webThree = std::unique_ptr<dev::WebThreeDirect>(new WebThreeDirect(std::string("Mix/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/Mix", false, {"eth", "shh"}));
m_compiler = std::unique_ptr<CompilerStack>(new CompilerStack());
m_compiler = std::unique_ptr<CompilerStack>(new CompilerStack()); //TODO : to move in a codel model structure.
}
QQmlApplicationEngine* AppContext::appEngine()
@ -49,11 +49,6 @@ QQmlApplicationEngine* AppContext::appEngine()
return m_applicationEngine.get();
}
dev::eth::Client* AppContext::getEthereumClient()
{
return m_webThree->ethereum();
}
void AppContext::initKeyEventManager(QObject* _res)
{
QObject* mainContent = _res->findChild<QObject*>("mainContent", Qt::FindChildrenRecursively);
@ -81,6 +76,7 @@ void AppContext::setApplicationContext(QQmlApplicationEngine* _engine)
void AppContext::displayMessageDialog(QString _title, QString _message)
{
// TODO : move it in a UI dedicated layer.
QObject* dialogWin = m_applicationEngine.get()->rootObjects().at(0)->findChild<QObject*>("alertMessageDialog", Qt::FindChildrenRecursively);
QObject* dialogWinComponent = m_applicationEngine.get()->rootObjects().at(0)->findChild<QObject*>("alertMessageDialogContent", Qt::FindChildrenRecursively);
dialogWinComponent->setProperty("source", QString("qrc:/qml/BasicMessage.qml"));

18
mix/AppContext.h

@ -28,8 +28,8 @@
#pragma once
#include <QQmlApplicationEngine>
#include "libsolidity/CompilerStack.h"
#include "libwebthree/WebThree.h"
#include <libsolidity/CompilerStack.h>
#include <libwebthree/WebThree.h>
#include "KeyEventManager.h"
namespace dev
@ -37,6 +37,9 @@ namespace dev
namespace mix
{
/**
* @brief Provides access to application scope variable.
*/
class AppContext: public QObject
{
Q_OBJECT
@ -44,13 +47,19 @@ class AppContext: public QObject
public:
AppContext(QQmlApplicationEngine* _engine);
~AppContext() {}
/// get the current QQmlApplicationEngine instance.
static AppContext* getInstance() { return Instance; }
/// renew QQMLApplicationEngine with a new instance.
static void setApplicationContext(QQmlApplicationEngine* _engine);
/// get the current QQMLApplicationEngine instance.
QQmlApplicationEngine* appEngine();
dev::eth::Client* getEthereumClient();
/// initialize KeyEventManager (used to handle key pressed event).
void initKeyEventManager(QObject* _obj);
/// get the current KeyEventManager instance.
KeyEventManager* getKeyEventManager();
/// get the current Compiler instance (used to parse and compile contract code).
dev::solidity::CompilerStack* compiler();
/// display an alert message.
void displayMessageDialog(QString _title, QString _message);
private:
@ -61,10 +70,11 @@ private:
std::unique_ptr<solidity::CompilerStack> m_compiler;
public slots:
/// delete the current instance when application quit.
void quitApplication() { delete Instance; }
/// initialize components after the loading of the main QML view.
void resourceLoaded(QObject* _obj, QUrl _url) { Q_UNUSED(_url); initKeyEventManager(_obj); }
};
}
}

22
mix/AssemblyDebuggerCtrl.cpp

@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file AssemblyDebuggerCtrl.h
/** @file AssemblyDebuggerCtrl.cpp
* @author Yann yann@ethdev.com
* @date 2014
* display opcode debugging.
@ -23,7 +23,7 @@
#include <QQmlContext>
#include <QModelIndex>
#include <libdevcore/CommonJS.h>
#include "libethereum/Transaction.h"
#include <libethereum/Transaction.h>
#include "AssemblyDebuggerModel.h"
#include "AssemblyDebuggerCtrl.h"
#include "KeyEventManager.h"
@ -44,6 +44,7 @@ AssemblyDebuggerCtrl::AssemblyDebuggerCtrl(QTextDocument* _doc): Extension(Exten
qRegisterMetaType<QVariableDeclaration*>("QVariableDeclaration*");
qRegisterMetaType<AssemblyDebuggerData>("AssemblyDebuggerData");
qRegisterMetaType<DebuggingStatusResult>("DebuggingStatusResult");
connect(this, SIGNAL(dataAvailable(bool, DebuggingStatusResult, QList<QVariableDefinition*>, QList<QObject*>, AssemblyDebuggerData)),
this, SLOT(updateGUI(bool, DebuggingStatusResult, QList<QVariableDefinition*>, QList<QObject*>, AssemblyDebuggerData)), Qt::QueuedConnection);
@ -77,9 +78,14 @@ void AssemblyDebuggerCtrl::keyPressed(int _key)
deployContract(m_doc->toPlainText());
});
}
else if (_key == Qt::Key_F6)
{
m_modelDebugger.get()->resetState();
AppContext::getInstance()->displayMessageDialog(QApplication::tr("State status"), QApplication::tr("State reseted ... need to redeploy contract"));
}
}
void AssemblyDebuggerCtrl::callContract(dev::mix::TransactionSettings _tr, Address _contract)
void AssemblyDebuggerCtrl::callContract(TransactionSettings _tr, Address _contract)
{
CompilerResult compilerRes = m_compilation.get()->compile(m_doc->toPlainText());
if (!compilerRes.success)
@ -99,7 +105,7 @@ void AssemblyDebuggerCtrl::callContract(dev::mix::TransactionSettings _tr, Addre
}
if (!f)
{
AppContext::getInstance()->displayMessageDialog(QApplication::tr("debugger"), QApplication::tr("contract code changed. Please redeploy contract"));
AppContext::getInstance()->displayMessageDialog(QApplication::tr("debugger"), QApplication::tr("function not found. Please redeploy this contract."));
return;
}
c.encode(f->index());
@ -108,7 +114,7 @@ void AssemblyDebuggerCtrl::callContract(dev::mix::TransactionSettings _tr, Addre
QVariableDeclaration* var = (QVariableDeclaration*)f->parameters().at(k);
c.encode(var, _tr.parameterValues[var->name()]);
}
DebuggingContent debuggingContent = m_modelDebugger->getContractCallDebugStates(_contract, c.encodedData(), _tr);
DebuggingContent debuggingContent = m_modelDebugger->callContract(_contract, c.encodedData(), _tr);
debuggingContent.returnParameters = c.decode(f->returnParameters(), debuggingContent.returnValue);
finalizeExecution(debuggingContent);
}
@ -121,7 +127,7 @@ void AssemblyDebuggerCtrl::deployContract(QString _source)
emit dataAvailable(false, DebuggingStatusResult::Compilationfailed);
return;
}
m_previousDebugResult = m_modelDebugger->getContractInitiationDebugStates(compilerRes.bytes);
m_previousDebugResult = m_modelDebugger->deployContract(compilerRes.bytes);
finalizeExecution(m_previousDebugResult);
}
@ -139,7 +145,7 @@ void AssemblyDebuggerCtrl::finalizeExecution(DebuggingContent _debuggingContent)
emit dataAvailable(true, DebuggingStatusResult::Ok, _debuggingContent.returnParameters, wStates, code);
}
void AssemblyDebuggerCtrl::updateGUI(bool _success, DebuggingStatusResult _reason, QList<QVariableDefinition*> _returnParam, QList<QObject*> _wStates, AssemblyDebuggerData _code)
void AssemblyDebuggerCtrl::updateGUI(bool _success, DebuggingStatusResult const& _reason, QList<QVariableDefinition*> const& _returnParam, QList<QObject*> const& _wStates, AssemblyDebuggerData const& _code)
{
Q_UNUSED(_reason);
if (_success)
@ -154,7 +160,7 @@ void AssemblyDebuggerCtrl::updateGUI(bool _success, DebuggingStatusResult _reaso
m_ctx->displayMessageDialog(QApplication::tr("debugger"), QApplication::tr("compilation failed"));
}
void AssemblyDebuggerCtrl::runTransaction(TransactionSettings _tr)
void AssemblyDebuggerCtrl::runTransaction(TransactionSettings const& _tr)
{
QtConcurrent::run([this, _tr]()
{

21
mix/AssemblyDebuggerCtrl.h

@ -14,13 +14,13 @@
/** @file AssemblyDebuggerCtrl.h
* @author Yann yann@ethdev.com
* @date 2014
* Display debugging steps in assembly code.s
* Extension which display debugging steps in assembly code.
*/
#pragma once
#include <QKeySequence>
#include "QTextDocument"
#include <QTextDocument>
#include "Extension.h"
#include "ConstantCompilationModel.h"
#include "TransactionListModel.h"
@ -43,12 +43,15 @@ namespace dev
namespace mix
{
/**
* @brief Extension which display transaction creation or transaction call debugging. handle: F5 to deploy contract, F6 to reset state.
*/
class AssemblyDebuggerCtrl: public Extension
{
Q_OBJECT
public:
AssemblyDebuggerCtrl(QTextDocument*);
AssemblyDebuggerCtrl(QTextDocument* _doc);
~AssemblyDebuggerCtrl() {}
void start() const override;
QString title() const override;
@ -61,16 +64,20 @@ private:
std::unique_ptr<AssemblyDebuggerModel> m_modelDebugger;
std::unique_ptr<ConstantCompilationModel> m_compilation;
DebuggingContent m_previousDebugResult; //TODO: to be replaced by more consistent struct. Used for now to keep the contract address in case of future transaction call.
DebuggingContent m_previousDebugResult; //TODO: to be replaced in a more consistent struct. Used for now to keep the contract address in case of future transaction call.
QTextDocument* m_doc;
public slots:
/// handle key pressed. F5 deploy contract - F6 reset state.
void keyPressed(int);
void updateGUI(bool _success, DebuggingStatusResult _reason, QList<QVariableDefinition*> _returnParams = QList<QVariableDefinition*>(), QList<QObject*> _wStates = QList<QObject*>(), AssemblyDebuggerData _code = AssemblyDebuggerData());
void runTransaction(TransactionSettings _tr);
/// update UI with machine states result. Display a modal dialog.
void updateGUI(bool _success, DebuggingStatusResult const& _reason, QList<QVariableDefinition*> const& _returnParams = QList<QVariableDefinition*>(), QList<QObject*> const& _wStates = QList<QObject*>(), AssemblyDebuggerData const& _code = AssemblyDebuggerData());
/// run the given transaction.
void runTransaction(TransactionSettings const& _tr);
signals:
void dataAvailable(bool _success, DebuggingStatusResult _reason, QList<QVariableDefinition*> _returnParams = QList<QVariableDefinition*>(), QList<QObject*> _wStates = QList<QObject*>(), AssemblyDebuggerData _code = AssemblyDebuggerData());
/// emited when machine states are available.
void dataAvailable(bool _success, DebuggingStatusResult const& _reason, QList<QVariableDefinition*> const& _returnParams = QList<QVariableDefinition*>(), QList<QObject*> const& _wStates = QList<QObject*>(), AssemblyDebuggerData const& _code = AssemblyDebuggerData());
};
}

20
mix/AssemblyDebuggerModel.cpp

@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file AssemblyDebuggerModel.h
/** @file AssemblyDebuggerModel.cpp
* @author Yann yann@ethdev.com
* @date 2014
* used as a model to debug contract assembly code.
@ -42,13 +42,10 @@ AssemblyDebuggerModel::AssemblyDebuggerModel():
m_currentExecution = std::unique_ptr<Executive>(new Executive(m_executiveState, 0));
}
DebuggingContent AssemblyDebuggerModel::executeTransaction(bytesConstRef _rawTransaction)
DebuggingContent AssemblyDebuggerModel::executeTransaction(bytesConstRef const& _rawTransaction)
{
QList<DebuggingState> machineStates;
// Reset the state back to our clean premine.
m_currentExecution = std::unique_ptr<Executive>(new Executive(m_executiveState, 0));
QList<DebuggingState> states;
m_currentExecution.reset(new Executive(m_executiveState, 0));
m_currentExecution->setup(_rawTransaction);
std::vector<DebuggingState const*> levels;
bytes code;
@ -89,12 +86,12 @@ DebuggingContent AssemblyDebuggerModel::executeTransaction(bytesConstRef _rawTra
return d;
}
DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(bytes _code)
DebuggingContent AssemblyDebuggerModel::deployContract(bytes const& _code)
{
u256 gasPrice = 10000000000000;
u256 gas = 1000000;
u256 amount = 100;
dev::eth::Transaction _tr(amount, gasPrice, min(gas, m_baseState.gasLimitRemaining()), _code, m_executiveState.transactionsFrom(dev::toAddress(m_userAccount.secret())), m_userAccount.secret());
Transaction _tr(amount, gasPrice, min(gas, m_baseState.gasLimitRemaining()), _code, m_executiveState.transactionsFrom(dev::toAddress(m_userAccount.secret())), m_userAccount.secret());
bytes b = _tr.rlp();
dev::bytesConstRef bytesRef = &b;
DebuggingContent d = executeTransaction(bytesRef);
@ -103,11 +100,9 @@ DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(bytes _
return d;
}
DebuggingContent AssemblyDebuggerModel::getContractCallDebugStates(Address _contract, bytes _data,
dev::mix::TransactionSettings _tr)
DebuggingContent AssemblyDebuggerModel::callContract(Address const& _contract, bytes const& _data, TransactionSettings const& _tr)
{
dev::eth::Transaction tr = Transaction(_tr.value, _tr.gasPrice, min(_tr.gas, m_baseState.gasLimitRemaining()), _contract, _data, m_executiveState.transactionsFrom(dev::toAddress(m_userAccount.secret())), m_userAccount.secret());
Transaction tr = Transaction(_tr.value, _tr.gasPrice, min(_tr.gas, m_baseState.gasLimitRemaining()), _contract, _data, m_executiveState.transactionsFrom(dev::toAddress(m_userAccount.secret())), m_userAccount.secret());
bytes b = tr.rlp();
dev::bytesConstRef bytesRef = &b;
DebuggingContent d = executeTransaction(bytesRef);
@ -117,5 +112,6 @@ DebuggingContent AssemblyDebuggerModel::getContractCallDebugStates(Address _cont
void AssemblyDebuggerModel::resetState()
{
// Reset the state back to our clean premine.
m_executiveState = m_baseState;
}

11
mix/AssemblyDebuggerModel.h

@ -40,9 +40,11 @@ class AssemblyDebuggerModel
{
public:
AssemblyDebuggerModel();
DebuggingContent getContractCallDebugStates(Address _contract, bytes _data, dev::mix::TransactionSettings _tr);
DebuggingContent getContractInitiationDebugStates(bytes _code);
bool compile(QString);
/// call function in a already deployed contract.
DebuggingContent callContract(Address const& _contract, bytes const& _data, TransactionSettings const& _tr);
/// deploy the contract described by _code.
DebuggingContent deployContract(bytes const& _code);
/// reset state to the base state.
void resetState();
private:
@ -51,9 +53,8 @@ private:
eth::State m_baseState;
eth::State m_executiveState;
std::unique_ptr<eth::Executive> m_currentExecution;
DebuggingContent executeTransaction(dev::bytesConstRef _rawTransaction);
DebuggingContent executeTransaction(dev::bytesConstRef const& _rawTransaction);
};
}
}

12
mix/CodeEditorExtensionManager.h

@ -22,7 +22,6 @@
#pragma once
#include "memory"
#include <QQuickItem>
#include <QTextDocument>
#include <QVector>
@ -33,6 +32,9 @@ namespace dev
namespace mix
{
/**
* @brief Init and provides connection between extensions.
*/
class CodeEditorExtensionManager: public QObject
{
Q_OBJECT
@ -44,10 +46,15 @@ class CodeEditorExtensionManager: public QObject
public:
CodeEditorExtensionManager() {}
~CodeEditorExtensionManager();
/// initialize all extensions.
void initExtensions();
/// initialize extension.
void initExtension(std::shared_ptr<Extension>);
/// set current text editor.
void setEditor(QQuickItem*);
/// set current tab view
void setTabView(QQuickItem*);
/// set current right tab view.
void setRightTabView(QQuickItem*);
private:
@ -56,9 +63,8 @@ private:
QQuickItem* m_tabView;
QQuickItem* m_rightTabView;
QTextDocument* m_doc;
void loadEditor(QQuickItem*);
void loadEditor(QQuickItem* _editor);
};
}
}

9
mix/ConstantCompilationCtrl.h

@ -28,12 +28,15 @@ namespace dev
namespace mix
{
/**
* @brief Extension which display assembly code of the contract being edited.
*/
class ConstantCompilationCtrl: public Extension
{
Q_OBJECT
public:
ConstantCompilationCtrl(QTextDocument*);
ConstantCompilationCtrl(QTextDocument* _doc);
~ConstantCompilationCtrl() {}
void start() const override;
QString title() const override;
@ -42,13 +45,13 @@ public:
private:
QTextDocument* m_editor;
std::unique_ptr<ConstantCompilationModel> m_compilationModel;
void writeOutPut(CompilerResult const&);
void writeOutPut(CompilerResult const& _res);
void resetOutPut();
public slots:
/// compile text editor content.
void compile();
};
}
}

9
mix/ConstantCompilationModel.h

@ -22,15 +22,18 @@
#pragma once
#include <QObject>
#include <libevm/VM.h>
#include <libsolidity/AST.h>
#include <QObject>
namespace dev
{
namespace mix
{
/**
* @brief Provides compiler result information.
*/
struct CompilerResult
{
QString hexCode;
@ -39,12 +42,16 @@ struct CompilerResult
bool success;
};
/**
* @brief Compile source code using the solidity library.
*/
class ConstantCompilationModel
{
public:
ConstantCompilationModel() {}
~ConstantCompilationModel() {}
/// compile code.
CompilerResult compile(QString _code);
};

23
mix/ContractCallDataEncoder.cpp

@ -24,7 +24,7 @@
#include <QMap>
#include <QStringList>
#include <libdevcore/CommonJS.h>
#include "libsolidity/AST.h"
#include <libsolidity/AST.h>
#include "QVariableDeclaration.h"
#include "QVariableDefinition.h"
#include "ContractCallDataEncoder.h"
@ -38,10 +38,6 @@ ContractCallDataEncoder::ContractCallDataEncoder()
bytes ContractCallDataEncoder::encodedData()
{
std::ostringstream si;
si << std::hex << toJS(m_encodedData);
qDebug() << "encoded data";
qDebug() << si;
return m_encodedData;
}
@ -58,9 +54,6 @@ void ContractCallDataEncoder::encode(QVariableDeclaration* _dec, bool _value)
void ContractCallDataEncoder::encode(QVariableDeclaration* _dec, QString _value)
{
qDebug() << _dec->type();
qDebug() << _value;
qDebug() << "(())";
int padding = this->padding(_dec->type());
bytes data = padded(jsToBytes(_value.toStdString()), padding);
m_encodedData.insert(m_encodedData.end(), data.begin(), data.end());
@ -69,17 +62,9 @@ void ContractCallDataEncoder::encode(QVariableDeclaration* _dec, QString _value)
void ContractCallDataEncoder::encode(QVariableDeclaration* _dec, u256 _value)
{
int padding = this->padding(_dec->type());
qDebug() << _dec->type();
std::ostringstream s;
s << std::hex << "0x" << _value;
qDebug() << QString::fromStdString(s.str());
bytes data = padded(jsToBytes(s.str()), padding);
std::ostringstream si;
si << std::hex << toJS(data);
qDebug() << si;
m_encodedData.insert(m_encodedData.end(), data.begin(), data.end());
encodedData();
}
@ -88,15 +73,12 @@ QList<QVariableDefinition*> ContractCallDataEncoder::decode(QList<QObject*> _ret
{
QList<QVariableDefinition*> r;
std::string returnValue = toJS(_value);
qDebug() << QString::fromStdString(returnValue);
returnValue = returnValue.substr(2, returnValue.length() - 1);
for (int k = 0; k <_returnParameters.length(); k++)
{
QVariableDeclaration* dec = (QVariableDeclaration*)_returnParameters.at(k);
int padding = this->padding(dec->type());
std::string rawParam = returnValue.substr(0, padding * 2);
qDebug() << QString::fromStdString(rawParam);
r.append(new QVariableDefinition(dec, convertToReadable(unpadded(rawParam), dec)));
returnValue = returnValue.substr(rawParam.length(), returnValue.length() - 1);
}
@ -161,10 +143,9 @@ QString ContractCallDataEncoder::convertToInt(std::string _v)
{
qDebug() << "QString::fromStdString(_v);";
qDebug() << QString::fromStdString(_v);
//TO DO to be improve to manage all int, uint size (128, 256, ...)
//TO DO to be improve to manage all int, uint size (128, 256, ...) in ethereum QML types task #612.
int x = std::stol(_v, nullptr, 16);
std::stringstream ss;
ss << std::dec << x;
return QString::fromStdString(ss.str());
}

14
mix/ContractCallDataEncoder.h

@ -30,27 +30,35 @@ namespace dev
namespace mix
{
/**
* @brief encode/decode data to be sent to a transaction or to be displayed in a view.
*/
class ContractCallDataEncoder
{
public:
ContractCallDataEncoder();
/// encode variable in order to be sent as parameter.
void encode(QVariableDeclaration* _dec, QString _value);
/// encode variable in order to be sent as parameter.
void encode(QVariableDeclaration* _dec, u256 _value);
QList<QVariableDefinition*> decode(QList<QObject*> _dec, bytes _value);
/// encode variable in order to be sent as parameter.
void encode(QVariableDeclaration* _dec, bool _value);
/// encode index of the function to call.
void encode(int _functionIndex);
/// decode variable in order to be sent to QML view.
QList<QVariableDefinition*> decode(QList<QObject*> _dec, bytes _value);
/// get all encoded data encoded by encode function.
bytes encodedData();
private:
QMap<QString, int> typePadding;
int padding(QString _type);
bytes m_encodedData;
static QString convertToReadable(std::string _v, QVariableDeclaration* _dec);
static QString convertToBool(std::string _v);
static QString convertToInt(std::string _v);
static int integerPadding(int _bitValue);
static QString formatBool(bool _value);
bytes m_encodedData;
};
}

10
mix/DebuggingStateWrapper.cpp

@ -23,11 +23,11 @@
#include <QApplication>
#include <QDebug>
#include <QPointer>
#include "libevmcore/Instruction.h"
#include "libdevcore/CommonJS.h"
#include "libdevcrypto/Common.h"
#include "libevmcore/Instruction.h"
#include "libdevcore/Common.h"
#include <libevmcore/Instruction.h>
#include <libdevcore/CommonJS.h>
#include <libdevcrypto/Common.h>
#include <libevmcore/Instruction.h>
#include <libdevcore/Common.h>
#include "DebuggingStateWrapper.h"
using namespace dev;
using namespace dev::eth;

30
mix/DebuggingStateWrapper.h

@ -23,9 +23,9 @@
#pragma once
#include <QStringList>
#include "libethereum/State.h"
#include "libethereum/Executive.h"
#include "libdevcore/Common.h"
#include <libdevcore/Common.h>
#include <libethereum/State.h>
#include <libethereum/Executive.h>
#include "QVariableDefinition.h"
namespace dev
@ -33,6 +33,9 @@ namespace dev
namespace mix
{
/**
* @brief Store information about a machine state.
*/
struct DebuggingState
{
uint64_t steps;
@ -48,6 +51,9 @@ struct DebuggingState
std::vector<DebuggingState const*> levels;
};
/**
* @brief Store information about a machine states.
*/
struct DebuggingContent
{
QList<DebuggingState> machineStates;
@ -71,7 +77,9 @@ class HumanReadableCode: public QObject
public:
HumanReadableCode(QString _line, int _processIndex): QObject(), m_line(_line), m_processIndex(_processIndex) {}
/// get the assembly code line.
QString line() { return m_line; }
/// get corresponding index.
int processIndex() { return m_processIndex; }
private:
@ -89,6 +97,7 @@ class QQMLMap: public QObject
public:
QQMLMap(QMap<int, int> _map): QObject(), m_map(_map) { }
/// get the value associated with _key store in n_map.
Q_INVOKABLE int getValue(int _key) { return m_map.value(_key); }
private:
@ -116,20 +125,35 @@ class DebuggingStateWrapper: public QObject
public:
DebuggingStateWrapper(bytes _code, bytes _data): QObject(), m_code(_code), m_data(_data) {}
/// get the step of this machine states.
int step() { return (int)m_state.steps; }
/// get the proccessed code.
int curPC() { return (int)m_state.curPC; }
/// get gas left.
QString gasLeft();
/// get gas cost.
QString gasCost();
/// get gas used.
QString gas();
/// get stack.
QString debugStack();
/// get storage.
QString debugStorage();
/// get memory.
QString debugMemory();
/// get call data.
QString debugCallData();
/// get info to be displayed in the header.
QString headerInfo();
/// get end of debug information.
QString endOfDebug();
/// get all previous steps.
QStringList levels();
/// get the current processed machine state.
DebuggingState state() { return m_state; }
/// set the current processed machine state.
void setState(DebuggingState _state) { m_state = _state; }
/// convert all machine state in human readable code.
static std::tuple<QList<QObject*>, QQMLMap*> getHumanReadableCode(bytes const& _code);
private:

10
mix/Extension.h

@ -43,12 +43,19 @@ class Extension: public QObject
public:
Extension();
Extension(ExtensionDisplayBehavior _displayBehavior);
/// return the QML url of the view to display.
virtual QString contentUrl() const { return ""; }
/// reuturn the title of this extension.
virtual QString title() const { return ""; }
/// initialize extension.
virtual void start() const {}
void addContentOn(QObject* _tabView);
/// add the view define in contentUrl() in the _view QObject.
void addContentOn(QObject* _view);
/// add the view define in contentUrl() in the _view QObject (_view has to be a tab).
void addTabOn(QObject* _view);
/// modify the display behavior of this extension.
void setDisplayBehavior(ExtensionDisplayBehavior _displayBehavior) { m_displayBehavior = _displayBehavior; }
/// get the display behavior of thi extension.
ExtensionDisplayBehavior getDisplayBehavior() { return m_displayBehavior; }
protected:
@ -62,5 +69,4 @@ private:
};
}
}

6
mix/KeyEventManager.h

@ -30,13 +30,17 @@ class KeyEventManager: public QObject
public:
KeyEventManager() {}
/// allows _receiver to handle key pressed event.
void registerEvent(const QObject* _receiver, const char* _slot);
/// unregister _receiver.
void unRegisterEvent(QObject* _receiver);
signals:
void onKeyPressed(int);
/// emited when a key is pressed.
void onKeyPressed(int _event);
public slots:
/// called when a key is pressed.
void keyPressed(QVariant _event);
};

1
mix/MixApplication.h

@ -41,5 +41,4 @@ public:
};
}
}

23
mix/QBasicNodeDefinition.cpp

@ -1,23 +0,0 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QBasicNodeDefinition.cpp
* @author Yann yann@ethdev.com
* @date 2014
*/
#include "QBasicNodeDefinition.h"

6
mix/QBasicNodeDefinition.h

@ -22,7 +22,7 @@
#pragma once
#include <QObject>
#include "libsolidity/AST.h"
#include <libsolidity/AST.h>
namespace dev
{
@ -36,9 +36,9 @@ class QBasicNodeDefinition: public QObject
public:
QBasicNodeDefinition(): QObject() {}
~QBasicNodeDefinition() {
}
~QBasicNodeDefinition() {}
QBasicNodeDefinition(dev::solidity::Declaration* _d): QObject(), m_dec(_d) {}
/// get the name of the node.
QString name() const { return QString::fromStdString(m_dec->getName()); }
protected:

11
mix/QContractDefinition.cpp

@ -20,12 +20,11 @@
*/
#include <QObject>
#include "QContractDefinition.h"
#include "libsolidity/AST.h"
#include "libsolidity/Scanner.h"
#include "libsolidity/Parser.h"
#include "libsolidity/Scanner.h"
#include "libsolidity/NameAndTypeResolver.h"
#include <libsolidity/AST.h>
#include <libsolidity/Scanner.h>
#include <libsolidity/Parser.h>
#include <libsolidity/Scanner.h>
#include <libsolidity/NameAndTypeResolver.h>
#include "AppContext.h"
#include "QContractDefinition.h"
using namespace dev::solidity;

4
mix/QContractDefinition.h

@ -22,7 +22,7 @@
#pragma once
#include <QObject>
#include "libsolidity/AST.h"
#include <libsolidity/AST.h>
#include "QFunctionDefinition.h"
#include "QBasicNodeDefinition.h"
@ -38,7 +38,9 @@ class QContractDefinition: public QBasicNodeDefinition
public:
QContractDefinition(dev::solidity::ContractDefinition* _contract);
/// get all the functions of the contract.
QList<QFunctionDefinition*> functions() const { return m_functions; }
/// get the description (functions, parameters, return parameters, ...) of the contract describes by _code.
static std::shared_ptr<QContractDefinition> Contract(QString _code);
private:

2
mix/QFunctionDefinition.cpp

@ -19,9 +19,9 @@
* @date 2014
*/
#include <libsolidity/AST.h>
#include "QVariableDeclaration.h"
#include "QFunctionDefinition.h"
#include "libsolidity/AST.h"
using namespace dev::solidity;
using namespace dev::mix;

3
mix/QFunctionDefinition.h

@ -38,8 +38,11 @@ class QFunctionDefinition: public QBasicNodeDefinition
public:
QFunctionDefinition(dev::solidity::FunctionDefinition* _f, int _index): QBasicNodeDefinition(_f), m_index(_index) { initQParameters(); }
/// get all input parameters of this function.
QList<QObject*> parameters() const { return m_parameters; }
/// get all return parameters of this function.
QList<QObject*> returnParameters() const { return m_returnParameters; }
/// get the index of this function on the contract ABI.
int index() const { return m_index; }
private:

23
mix/QVariableDeclaration.cpp

@ -1,23 +0,0 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QVariableDeclaration.cpp
* @author Yann yann@ethdev.com
* @date 2014
*/
#include "QVariableDeclaration.h"
using namespace dev::mix;

3
mix/QVariableDeclaration.h

@ -19,7 +19,7 @@
* @date 2014
*/
#include "libsolidity/AST.h"
#include <libsolidity/AST.h>
#include "QBasicNodeDefinition.h"
#pragma once
@ -36,6 +36,7 @@ class QVariableDeclaration: public QBasicNodeDefinition
public:
QVariableDeclaration(dev::solidity::VariableDeclaration* _v): QBasicNodeDefinition(_v){}
/// get the type of this variable.
QString type() const { return QString::fromStdString(((solidity::VariableDeclaration*)m_dec)->getType()->toString()); }
};

6
mix/QVariableDefinition.h

@ -38,7 +38,9 @@ class QVariableDefinition: public QObject
public:
QVariableDefinition(QVariableDeclaration* _def, QString _value): QObject(), m_value(_value), m_dec(_def) {}
/// return the associated declaration of this variable definition.
QVariableDeclaration* declaration() const { return m_dec; }
/// return the variable value.
QString value() const { return m_value; }
private:
@ -55,7 +57,9 @@ public:
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
QVariableDefinition* val(int idx);
/// return the variable definition at index _idx.
QVariableDefinition* val(int _idx);
/// return the list of variables.
QList<QVariableDefinition*> def() { return m_def; }
private:

Loading…
Cancel
Save