aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4module.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-15 13:18:32 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-15 18:55:53 +0000
commit0e45db9a04c339ee7aa0e692e5ad3827db388628 (patch)
treebfe5f6c20051da567785932547a1b405180611d9 /src/qml/jsruntime/qv4module.cpp
parent7f59171d00d185828b32d5d3e1cc9bcd34e7b003 (diff)
Fix order of own property names of module namespace objects
They must be sorted, no duplicates and only one default entry at most. Change-Id: Ia9c0e54a761ce7cbfebb837330bf3769d505eb3b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4module.cpp')
-rw-r--r--src/qml/jsruntime/qv4module.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp
index e8e84ac965..5974c9be73 100644
--- a/src/qml/jsruntime/qv4module.cpp
+++ b/src/qml/jsruntime/qv4module.cpp
@@ -162,7 +162,9 @@ bool Module::virtualDeleteProperty(Managed *m, PropertyKey id)
struct ModuleNamespaceIterator : ObjectOwnPropertyKeyIterator
{
- uint exportIndex = 0;
+ QStringList exportedNames;
+ int exportIndex = 0;
+ ModuleNamespaceIterator(const QStringList &names) : exportedNames(names) {}
~ModuleNamespaceIterator() override = default;
PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
@@ -171,23 +173,23 @@ struct ModuleNamespaceIterator : ObjectOwnPropertyKeyIterator
PropertyKey ModuleNamespaceIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
{
const Module *module = static_cast<const Module *>(o);
- if (exportIndex < module->d()->unit->unitData()->localExportEntryTableSize) {
+ if (exportIndex < exportedNames.count()) {
if (attrs)
*attrs = Attr_Data;
- if (pd) {
- const CompiledData::ExportEntry &entry = module->d()->unit->unitData()->localExportEntryTable()[exportIndex];
- Scope scope(module->engine());
- ScopedString exportName(scope, module->d()->unit->runtimeStrings[entry.exportName]);
- pd->value = *module->d()->unit->resolveExport(exportName);
- }
+ Scope scope(module->engine());
+ ScopedString exportName(scope, scope.engine->newString(exportedNames.at(exportIndex)));
exportIndex++;
+ if (pd)
+ pd->value = *module->d()->unit->resolveExport(exportName);
+ return exportName->toPropertyKey();
}
return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
}
-OwnPropertyKeyIterator *Module::virtualOwnPropertyKeys(const Object *)
+OwnPropertyKeyIterator *Module::virtualOwnPropertyKeys(const Object *o)
{
- return new ModuleNamespaceIterator;
+ const Module *module = static_cast<const Module *>(o);
+ return new ModuleNamespaceIterator(module->d()->unit->exportedNames());
}
Heap::Object *Module::virtualGetPrototypeOf(const Managed *)