diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-07-01 22:39:38 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-03 08:09:25 +0000 |
commit | 1879525721fa348c18cdbc0ffb3830d689f06933 (patch) | |
tree | 232da7691528af3671aee1146b25026452840a33 /src | |
parent | 24938ed2b9dccacdc2390b40dc10f71b8f734ad2 (diff) |
Give classes a name property
Set the classes name as defined in the ES7 spec.
Change-Id: I5ef1d317dfdf92f5e7c141b9092fa391a64ce8af
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 7b2fd07f0b..9848c60602 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1515,10 +1515,6 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde const QV4::CompiledData::Class *cls = unit->data->classAt(classIndex); Scope scope(engine); - ScopedString name(scope); - if (cls->nameIndex != UINT_MAX) - name = unit->runtimeStrings[cls->nameIndex]; - // ### fix heritage ScopedObject protoParent(scope, engine->objectPrototype()); ScopedObject constructorParent(scope, engine->functionPrototype()); if (!superClass.isEmpty()) { @@ -1548,6 +1544,11 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde constructor->defineDefaultProperty(engine->id_prototype(), proto); proto->defineDefaultProperty(engine->id_constructor(), constructor); + ScopedString name(scope); + if (cls->nameIndex != UINT_MAX) { + name = unit->runtimeStrings[cls->nameIndex]; + constructor->defineReadonlyConfigurableProperty(engine->id_name(), name); + } ScopedObject receiver(scope, *constructor); ScopedPropertyKey propertyName(scope); |