diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-15 12:48:05 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2013-08-15 15:28:37 +0200 |
commit | 7b2c9178b93fc31779c05553dcc48930d66342e2 (patch) | |
tree | 939b3247eeac5a1c480c80ce7bffda23980940bf /src/qml/compiler/qv4compiler.cpp | |
parent | ab44ecae18bba8aa09c6c12c37aca8f6df454cdc (diff) |
Ported lookups to use the compiled data infrastructure
Change-Id: Idf75cd51087ea825f22aabda59661be461fd3b86
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4compiler.cpp')
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 07687cca17..135c8679f1 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -67,6 +67,33 @@ int QV4::Compiler::JSUnitGenerator::getStringId(const QString &string) const return stringToId.value(string); } +uint QV4::Compiler::JSUnitGenerator::registerGetterLookup(const QString &name) +{ + CompiledData::Lookup l; + l.type_and_flags = CompiledData::Lookup::Type_Getter; + l.nameIndex = registerString(name); + lookups << l; + return lookups.size() - 1; +} + +uint QV4::Compiler::JSUnitGenerator::registerSetterLookup(const QString &name) +{ + CompiledData::Lookup l; + l.type_and_flags = CompiledData::Lookup::Type_Setter; + l.nameIndex = registerString(name); + lookups << l; + return lookups.size() - 1; +} + +uint QV4::Compiler::JSUnitGenerator::registerGlobalGetterLookup(const QString &name) +{ + CompiledData::Lookup l; + l.type_and_flags = CompiledData::Lookup::Type_GlobalGetter; + l.nameIndex = registerString(name); + lookups << l; + return lookups.size() - 1; +} + QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit() { registerString(irModule->fileName); @@ -87,7 +114,9 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit() functionDataSize += QV4::CompiledData::Function::calculateSize(f); } - char *data = (char *)malloc(unitSize + functionDataSize + stringDataSize); + const uint lookupDataSize = CompiledData::Lookup::calculateSize() * lookups.count(); + + char *data = (char *)malloc(unitSize + functionDataSize + stringDataSize + lookupDataSize); QV4::CompiledData::Unit *unit = (QV4::CompiledData::Unit*)data; memcpy(unit->magic, QV4::CompiledData::magic_str, sizeof(unit->magic)); @@ -98,6 +127,8 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit() unit->offsetToStringTable = sizeof(QV4::CompiledData::Unit); unit->functionTableSize = irModule->functions.size(); unit->offsetToFunctionTable = unit->offsetToStringTable + unit->stringTableSize * sizeof(uint); + unit->lookupTableSize = lookups.count(); + unit->offsetToLookupTable = unitSize + stringDataSize + functionDataSize; unit->sourceFileIndex = getStringId(irModule->fileName); // write strings and string table @@ -134,6 +165,10 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit() f += QV4::CompiledData::Function::calculateSize(function); } + CompiledData::Lookup *lookupsToWrite = (CompiledData::Lookup*)(data + unit->offsetToLookupTable); + foreach (const CompiledData::Lookup &l, lookups) + *lookupsToWrite++ = l; + return unit; } |