diff options
author | Simon Hausmann <[email protected]> | 2016-07-14 16:19:04 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2016-07-15 08:58:15 +0000 |
commit | cf23466f0aa370790bec05bc7764176c194fe5bb (patch) | |
tree | 98647e3a120c34af9cef3fb46fe0503fca593dd6 /src/qml/compiler/qv4compiler_p.h | |
parent | c586fc4be2428db57ba8579f8280d09893ba796d (diff) |
Simplify CompiledData::Unit serialization
There are currently two places where we calculate the total size of a
CompiledData::Unit including all of its data, once in its calculateSize()
function and then when constructing the Unit itself. This is error prone when
trying to do changes to the layout, as two places need to be adjusted. Instead
we can centralize the populating of the entire CompiledData::Unit header, the
calculation of the various offsets as well as the entire size in one shot in a
new generateHeader function. Afterwards we can allocate the final amount of
memory and copy the remaining bytes across and assemble the final data
structure.
Change-Id: Ic26d7812e59d2bee2f45cd72742e3195a56950df
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4compiler_p.h')
-rw-r--r-- | src/qml/compiler/qv4compiler_p.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compiler_p.h b/src/qml/compiler/qv4compiler_p.h index 2ff08d76dd..4b67fe8600 100644 --- a/src/qml/compiler/qv4compiler_p.h +++ b/src/qml/compiler/qv4compiler_p.h @@ -52,6 +52,7 @@ #include <QtCore/qstring.h> #include "qv4jsir_p.h" +#include <private/qjson_p.h> QT_BEGIN_NAMESPACE @@ -114,10 +115,12 @@ struct Q_QML_PRIVATE_EXPORT JSUnitGenerator { QV4::CompiledData::Unit *generateUnit(GeneratorOption option = GenerateWithStringTable); // Returns bytes written - int writeFunction(char *f, IR::Function *irFunction) const; + void writeFunction(char *f, IR::Function *irFunction) const; StringTableGenerator stringTable; private: + CompiledData::Unit generateHeader(GeneratorOption option, QJsonPrivate::q_littleendian<quint32> *functionOffsets, uint *jsClassDataOffset) const; + IR::Module *irModule; QList<CompiledData::Lookup> lookups; |