diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-11 11:07:32 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-17 07:47:09 +0000 |
commit | 1dac47c1418b44cf4a56b42bfca2b277795fd213 (patch) | |
tree | 26727943c30628340662a66d7cbe9f52d75c5b58 /src/qml/jsruntime/qv4functionobject.cpp | |
parent | d89d5cffe79bd060a1b04a2c47a3d728bffbe195 (diff) |
Cleanups in Value/Primitive
Get rid of Primitive and move the corresponding methods
directly into Value. Mark many methods in Value as
constexpr and turn Value into a POD type again.
Keep Primitive as a pure alias to Value for source
compatibility of other modules that might be using it.
Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 7dd9c90511..a2a5cdd474 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -200,7 +200,7 @@ Heap::FunctionObject *FunctionObject::createBuiltinFunction(ExecutionEngine *eng name = engine->newString(QChar::fromLatin1('[') + nameOrSymbol->toQString().midRef(1) + QChar::fromLatin1(']')); ScopedFunctionObject function(scope, engine->memoryManager->allocate<FunctionObject>(engine->rootContext(), name, code)); - function->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(argumentCount)); + function->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(argumentCount)); return function->d(); } @@ -305,11 +305,11 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor) Scope scope(engine); ScopedObject o(scope); - ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1)); + ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1)); ctor->defineReadonlyProperty(engine->id_prototype(), (o = this)); defineReadonlyConfigurableProperty(engine->id_name(), *engine->id_empty()); - defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0)); + defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0)); defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); defineDefaultProperty(engine->id_toString(), method_toString, 0); defineDefaultProperty(QStringLiteral("apply"), method_apply, 2); @@ -364,7 +364,7 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons int l = qMin(len, (uint)a->d()->context->argc()); memcpy(arguments, a->d()->context->args(), l*sizeof(Value)); for (quint32 i = l; i < len; ++i) - arguments[i] = Primitive::undefinedValue(); + arguments[i] = Value::undefinedValue(); } else if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) { auto sad = static_cast<Heap::SimpleArrayData *>(arr->arrayData()); uint alen = sad ? sad->values.size : 0; @@ -373,7 +373,7 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons for (uint i = 0; i < alen; ++i) arguments[i] = sad->data(i); for (quint32 i = alen; i < len; ++i) - arguments[i] = Primitive::undefinedValue(); + arguments[i] = Value::undefinedValue(); } else { // need to init the arguments array, as the get() calls below can have side effects memset(arguments, 0, len*sizeof(Value)); @@ -407,7 +407,7 @@ ReturnedValue FunctionPrototype::method_bind(const FunctionObject *b, const Valu if (!target || target->isBinding()) return scope.engine->throwTypeError(); - ScopedValue boundThis(scope, argc ? argv[0] : Primitive::undefinedValue()); + ScopedValue boundThis(scope, argc ? argv[0] : Value::undefinedValue()); Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)nullptr); int nArgs = (argc - 1 >= 0) ? argc - 1 : 0; @@ -474,7 +474,7 @@ ReturnedValue ScriptFunction::virtualCallAsConstructor(const FunctionObject *fo, frame.init(v4, f->function(), argv, argc); frame.setupJSFrame(v4->jsStackTop, *f, f->scope(), thisObject, - newTarget ? *newTarget : Primitive::undefinedValue()); + newTarget ? *newTarget : Value::undefinedValue()); frame.push(); v4->jsStackTop += frame.requiredJSStackFrameSize(); @@ -496,8 +496,8 @@ ReturnedValue ScriptFunction::virtualCall(const FunctionObject *fo, const Value CppStackFrame frame; frame.init(engine, fo->function(), argv, argc); frame.setupJSFrame(engine->jsStackTop, *fo, fo->scope(), - thisObject ? *thisObject : Primitive::undefinedValue(), - Primitive::undefinedValue()); + thisObject ? *thisObject : Value::undefinedValue(), + Value::undefinedValue()); frame.push(); engine->jsStackTop += frame.requiredJSStackFrameSize(); @@ -527,7 +527,7 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor); Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()->propertyKey()) == Index_Length); - setProperty(s.engine, Index_Length, Primitive::fromInt32(int(function->compiledFunction->length))); + setProperty(s.engine, Index_Length, Value::fromInt32(int(function->compiledFunction->length))); } Heap::InternalClass *ScriptFunction::classForConstructor() const @@ -559,8 +559,8 @@ ReturnedValue ConstructorFunction::virtualCallAsConstructor(const FunctionObject CppStackFrame frame; frame.init(v4, f->function(), argv, argc); frame.setupJSFrame(v4->jsStackTop, *f, f->scope(), - Primitive::emptyValue(), - newTarget ? *newTarget : Primitive::undefinedValue()); + Value::emptyValue(), + newTarget ? *newTarget : Value::undefinedValue()); frame.push(); v4->jsStackTop += frame.requiredJSStackFrameSize(); @@ -576,7 +576,7 @@ ReturnedValue ConstructorFunction::virtualCallAsConstructor(const FunctionObject return result; else if (!Value::fromReturnedValue(result).isUndefined()) return v4->throwTypeError(); - else if (Primitive::fromReturnedValue(thisObject).isEmpty()) { + else if (Value::fromReturnedValue(thisObject).isEmpty()) { Scope scope(v4); ScopedString s(scope, v4->newString(QStringLiteral("this"))); return v4->throwReferenceError(s); @@ -613,8 +613,8 @@ ReturnedValue DefaultClassConstructorFunction::virtualCallAsConstructor(const Fu CppStackFrame frame; frame.init(v4, nullptr, argv, argc); frame.setupJSFrame(v4->jsStackTop, *f, f->scope(), - Primitive::undefinedValue(), - newTarget ? *newTarget : Primitive::undefinedValue(), argc, argc); + Value::undefinedValue(), + newTarget ? *newTarget : Value::undefinedValue(), argc, argc); frame.push(); v4->jsStackTop += frame.requiredJSStackFrameSize(argc); @@ -631,7 +631,7 @@ ReturnedValue DefaultClassConstructorFunction::virtualCallAsConstructor(const Fu return result; else if (!Value::fromReturnedValue(result).isUndefined()) return v4->throwTypeError(); - else if (Primitive::fromReturnedValue(thisObject).isEmpty()) { + else if (Value::fromReturnedValue(thisObject).isEmpty()) { Scope scope(v4); ScopedString s(scope, v4->newString(QStringLiteral("this"))); return v4->throwReferenceError(s); @@ -669,7 +669,7 @@ void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject len -= boundArgs->size(); if (len < 0) len = 0; - f->defineReadonlyConfigurableProperty(s.engine->id_length(), Primitive::fromInt32(len)); + f->defineReadonlyConfigurableProperty(s.engine->id_length(), Value::fromInt32(len)); ScopedProperty pd(s); pd->value = s.engine->thrower(); |