aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-01 10:20:49 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-04 18:25:10 +0000
commit656db7a425fec6661ee3b42b89594a3e28637cdd (patch)
treeb3546bd33b128d2789b70b98e1122b903937bc33 /src/qml/jsruntime/qv4functionobject.cpp
parenta0a702cd9a315946a1b35dfe54d2dc965210ab6e (diff)
Don't define a prototype property for most functions
Only functions that are constructors should have a prototype property. Change-Id: Ifcf6f8b6c38de055d871d57ada38a23432974263 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index fe1ebbd556..f4037991b1 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -96,7 +96,7 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name,
f->setName(name);
if (createProto)
- f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_Prototype, Heap::FunctionObject::Index_ProtoConstructor);
+ f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor);
}
@@ -130,8 +130,6 @@ void Heap::FunctionObject::init()
Object::init();
this->scope.set(internalClass->engine, internalClass->engine->rootContext()->d());
- Q_ASSERT(internalClass && internalClass->find(internalClass->engine->id_prototype()->propertyKey()) == Index_Prototype);
- setProperty(internalClass->engine, Index_Prototype, Primitive::undefinedValue());
}
void Heap::FunctionObject::setFunction(Function *f)
@@ -148,16 +146,15 @@ void Heap::FunctionObject::destroy()
Object::destroy();
}
-void FunctionObject::createDefaultPrototypeProperty(uint protoSlot, uint protoConstructorSlot)
+void FunctionObject::createDefaultPrototypeProperty(uint protoConstructorSlot)
{
Scope s(this);
- Q_ASSERT(internalClass() && internalClass()->find(s.engine->id_prototype()->propertyKey()) == protoSlot);
Q_ASSERT(s.engine->internalClasses(EngineBase::Class_ObjectProto)->find(s.engine->id_constructor()->propertyKey()) == protoConstructorSlot);
ScopedObject proto(s, s.engine->newObject(s.engine->internalClasses(EngineBase::Class_ObjectProto)));
proto->setProperty(protoConstructorSlot, d());
- setProperty(protoSlot, proto);
+ defineDefaultProperty(s.engine->id_prototype(), proto, Attr_NotEnumerable|Attr_NotConfigurable);
}
ReturnedValue FunctionObject::name() const
@@ -524,7 +521,7 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function
ScopedString name(s, n ? n->d() : function->name());
if (name)
f->setName(name);
- f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_Prototype, Heap::FunctionObject::Index_ProtoConstructor);
+ 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)));