diff options
| author | Lars Knoll <lars.knoll@qt.io> | 2018-07-31 15:27:59 +0200 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-01 13:18:02 +0000 |
| commit | 81c5febf86339c141fb75bb2c3d166ac00b26f19 (patch) | |
| tree | ddb45633d88f7cf6fa7ec5684943c965cc7ff30d /src/qml/jsruntime/qv4runtime.cpp | |
| parent | 1ec824ed2f6b18705ecc4d9565f97ade5319da52 (diff) | |
Fix naming of methods defined in object or class literals
Change-Id: I01b7774097a447520c85ae6766e6ca1162e921ba
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 768d010bdf..7839db8e01 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1486,12 +1486,25 @@ ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, int classId ScopedPropertyKey name(scope); ScopedProperty pd(scope); + ScopedFunctionObject fn(scope); + ScopedString fnName(scope); for (int i = 0; i < additionalArgs; ++i) { Q_ASSERT(args->isInteger()); ObjectLiteralArgument arg = ObjectLiteralArgument(args->integerValue()); name = args[1].toPropertyKey(engine); if (engine->hasException) return Encode::undefined(); + if (args[2].isFunctionObject()) { + fn = static_cast<const FunctionObject &>(args[2]); + PropertyKey::FunctionNamePrefix prefix = PropertyKey::None; + if (arg == ObjectLiteralArgument::Getter) + prefix = PropertyKey::Getter; + else if (arg == ObjectLiteralArgument::Setter) + prefix = PropertyKey::Setter; + + fnName = name->asFunctionName(engine, prefix); + fn->setName(fnName); + } Q_ASSERT(arg == ObjectLiteralArgument::Value || args[2].isFunctionObject()); if (arg == ObjectLiteralArgument::Value || arg == ObjectLiteralArgument::Getter) { pd->value = args[2]; @@ -1569,10 +1582,18 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde } QV4::Function *f = unit->runtimeFunctions[methods[i].function]; Q_ASSERT(f); + PropertyKey::FunctionNamePrefix prefix = PropertyKey::None; + if (methods[i].type == CompiledData::Method::Getter) + prefix = PropertyKey::Getter; + else if (methods[i].type == CompiledData::Method::Setter) + prefix = PropertyKey::Setter; + + name = propertyName->asFunctionName(engine, prefix); + if (f->isGenerator()) - function = MemberGeneratorFunction::create(current, f); + function = MemberGeneratorFunction::create(current, f, name); else - function = FunctionObject::createMemberFunction(current, f); + function = FunctionObject::createMemberFunction(current, f, name); Q_ASSERT(function); PropertyAttributes attributes; switch (methods[i].type) { |
