diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-27 17:07:06 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-28 15:07:03 +0100 |
commit | 0ed744c1ef955cdb94cbd89c58283663da490d7d (patch) | |
tree | e07da64307bb70331ed0a9cbfa78ecd960b57b14 /src/qml/compiler/qv4compiler_p.h | |
parent | 6bbd173a9cb36021ed284522ac628400469eab2f (diff) |
Various cleanups
* Encapsulate the string pooling for the V4 data generation into a StringGenerator class.
* Move type reference collection into the IR::Document, where it belongs (as it writes
into the typeReferences there)
* const fixes
* Remove unused methods and members
* Store unit and qml unit sizes right in the generated data structure. That makes copying
easier (like we do when generating the QML data based on the JS fields)
Change-Id: I053146ab0b00cc90ac7f72f867415962d1be121b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4compiler_p.h')
-rw-r--r-- | src/qml/compiler/qv4compiler_p.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4compiler_p.h b/src/qml/compiler/qv4compiler_p.h index 6fd597a3b3..756e7cfd52 100644 --- a/src/qml/compiler/qv4compiler_p.h +++ b/src/qml/compiler/qv4compiler_p.h @@ -59,13 +59,31 @@ struct JSClassMember; namespace Compiler { -struct Q_QML_EXPORT JSUnitGenerator { - JSUnitGenerator(IR::Module *module, int headerSize = -1); - - IR::Module *irModule; +struct Q_QML_EXPORT StringTableGenerator { + StringTableGenerator(); int registerString(const QString &str); int getStringId(const QString &string) const; + QString stringForIndex(int index) const { return strings.at(index); } + uint stringCount() const { return strings.size(); } + uint dataSize() const { return stringDataSize; } + + void clear(); + + void serialize(uint *stringTable, char *dataStart, char *stringData); + +private: + QHash<QString, int> stringToId; + QStringList strings; + uint stringDataSize; +}; + +struct Q_QML_EXPORT JSUnitGenerator { + JSUnitGenerator(IR::Module *module, int headerSize = -1); + + int registerString(const QString &str) { return stringTable.registerString(str); } + int getStringId(const QString &string) const { return stringTable.getStringId(string); } + QString stringForIndex(int index) const { return stringTable.stringForIndex(index); } uint registerGetterLookup(const QString &name); uint registerSetterLookup(const QString &name); @@ -79,13 +97,14 @@ struct Q_QML_EXPORT JSUnitGenerator { int registerJSClass(int count, IR::ExprList *args); - QV4::CompiledData::Unit *generateUnit(int *totalUnitSize = 0); + QV4::CompiledData::Unit *generateUnit(); // Returns bytes written int writeFunction(char *f, int index, IR::Function *irFunction); - QHash<QString, int> stringToId; - QStringList strings; - uint stringDataSize; + StringTableGenerator stringTable; +private: + IR::Module *irModule; + QHash<IR::Function *, uint> functionOffsets; QList<CompiledData::Lookup> lookups; QVector<CompiledData::RegExp> regexps; |