|
@ -28,6 +28,7 @@ |
|
|
#include <QObject> |
|
|
#include <QObject> |
|
|
#include <QThread> |
|
|
#include <QThread> |
|
|
#include <QHash> |
|
|
#include <QHash> |
|
|
|
|
|
#include <QMetaEnum> |
|
|
#include <libdevcore/Common.h> |
|
|
#include <libdevcore/Common.h> |
|
|
#include <libdevcore/Guards.h> |
|
|
#include <libdevcore/Guards.h> |
|
|
#include <libevmasm/Assembly.h> |
|
|
#include <libevmasm/Assembly.h> |
|
@ -130,41 +131,60 @@ struct SourceMap |
|
|
using SourceMaps = QMap<QString, SourceMap>; //by source id
|
|
|
using SourceMaps = QMap<QString, SourceMap>; //by source id
|
|
|
using GasCostsMaps = QMap<QString, QVariantList>; //gas cost by contract name
|
|
|
using GasCostsMaps = QMap<QString, QVariantList>; //gas cost by contract name
|
|
|
|
|
|
|
|
|
class GasMapWrapper: public QObject |
|
|
|
|
|
{ |
|
|
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
|
|
Q_PROPERTY(GasCostsMaps gasMaps MEMBER m_gasMaps CONSTANT) |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
GasMapWrapper(QObject* _parent = nullptr): QObject(_parent){} |
|
|
|
|
|
void push(QString _source, int _start, int _end, QString _value, bool _isInfinite, QString _payload); |
|
|
|
|
|
bool contains(QString _key); |
|
|
|
|
|
void insert(QString _source, QVariantList _variantList); |
|
|
|
|
|
QVariantList gasCostsByDocId(QString _source); |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
GasCostsMaps m_gasMaps; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class GasMap: public QObject |
|
|
class GasMap: public QObject |
|
|
{ |
|
|
{ |
|
|
Q_OBJECT |
|
|
Q_OBJECT |
|
|
|
|
|
Q_ENUMS(type) |
|
|
Q_PROPERTY(int start MEMBER m_start CONSTANT) |
|
|
Q_PROPERTY(int start MEMBER m_start CONSTANT) |
|
|
Q_PROPERTY(int end MEMBER m_end CONSTANT) |
|
|
Q_PROPERTY(int end MEMBER m_end CONSTANT) |
|
|
Q_PROPERTY(QString gas MEMBER m_gas CONSTANT) |
|
|
Q_PROPERTY(QString gas MEMBER m_gas CONSTANT) |
|
|
Q_PROPERTY(bool isInfinite MEMBER m_isInfinite CONSTANT) |
|
|
Q_PROPERTY(bool isInfinite MEMBER m_isInfinite CONSTANT) |
|
|
Q_PROPERTY(QString payload MEMBER m_payload CONSTANT) |
|
|
Q_PROPERTY(QString codeBlockType READ codeBlockType CONSTANT) |
|
|
|
|
|
|
|
|
public: |
|
|
public: |
|
|
GasMap(int _start, int _end, QString _gas, bool _isInfinite, QString _payload, QObject* _parent): QObject(_parent), m_start(_start), m_end(_end), m_gas(_gas), m_isInfinite(_isInfinite), m_payload(_payload) {} |
|
|
|
|
|
|
|
|
enum type |
|
|
|
|
|
{ |
|
|
|
|
|
Statement, |
|
|
|
|
|
Function, |
|
|
|
|
|
Constructor |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
GasMap(int _start, int _end, QString _gas, bool _isInfinite, type _type, QObject* _parent): QObject(_parent), m_start(_start), m_end(_end), m_gas(_gas), m_isInfinite(_isInfinite), m_type(_type) {} |
|
|
|
|
|
|
|
|
int m_start; |
|
|
int m_start; |
|
|
int m_end; |
|
|
int m_end; |
|
|
QString m_gas; |
|
|
QString m_gas; |
|
|
bool m_isInfinite; |
|
|
bool m_isInfinite; |
|
|
QString m_payload; |
|
|
type m_type; |
|
|
|
|
|
|
|
|
|
|
|
QString codeBlockType() const |
|
|
|
|
|
{ |
|
|
|
|
|
QMetaEnum units = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("type")); |
|
|
|
|
|
if (m_type) |
|
|
|
|
|
{ |
|
|
|
|
|
const char* key = units.valueToKey(m_type); |
|
|
|
|
|
return QString(key).toLower(); |
|
|
|
|
|
} |
|
|
|
|
|
return QString(""); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class GasMapWrapper: public QObject |
|
|
|
|
|
{ |
|
|
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
|
|
Q_PROPERTY(GasCostsMaps gasMaps MEMBER m_gasMaps CONSTANT) |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
GasMapWrapper(QObject* _parent = nullptr): QObject(_parent){} |
|
|
|
|
|
void push(QString _source, int _start, int _end, QString _value, bool _isInfinite, GasMap::type _type); |
|
|
|
|
|
bool contains(QString _key); |
|
|
|
|
|
void insert(QString _source, QVariantList _variantList); |
|
|
|
|
|
QVariantList gasCostsByDocId(QString _source); |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
GasCostsMaps m_gasMaps; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/// Code compilation model. Compiles contracts in background an provides compiled contract data
|
|
|
/// Code compilation model. Compiles contracts in background an provides compiled contract data
|
|
@ -264,5 +284,3 @@ private: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Q_DECLARE_METATYPE(dev::mix::GasMap)
|
|
|
|
|
|