aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arrayobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-18 15:26:45 +0200
committerLars Knoll <lars.knoll@qt.io>2018-08-23 19:18:15 +0000
commitf15cc9f1df8e17f049c111e3147d6c63c07eb756 (patch)
treeae4daaa5e1cde31c0e412b84e9521f3745911657 /src/qml/jsruntime/qv4arrayobject.cpp
parent6e2fc84646987135c96755fbe1c2af20fc722e3d (diff)
Implement IsConstructor for Function objects
Use the jsConstruct member in the function object for this and set it to a nullptr for methods that are not a constructor. Change-Id: I63d2971b23b2596a8e3b6d2781f0d9ed3208693b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4arrayobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 9be744038c..c162a38e9d 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -165,23 +165,13 @@ ScopedObject createObjectFromCtorOrArray(Scope &scope, ScopedFunctionObject ctor
{
ScopedObject a(scope, Primitive::undefinedValue());
- if (ctor) {
- // ### the spec says that we should only call constructors if
- // IsConstructor(that), but we have no way of knowing if a builtin is a
- // constructor. so for the time being, just try call it, and silence any
- // exceptions-- this is not ideal, as the spec also says that we should
- // return on exception.
- //
- // this also isn't completely kosher. for instance:
+ if (ctor && ctor->isConstructor()) {
+ // this isn't completely kosher. for instance:
// Array.from.call(Object, []).constructor == Object
// is expected by the tests, but naturally, we get Number.
ScopedValue argument(scope, useLen ? QV4::Encode(len) : Primitive::undefinedValue());
a = ctor->callAsConstructor(argument, useLen ? 1 : 0);
- if (scope.engine->hasException)
- scope.engine->catchException(); // probably not a constructor, then.
- }
-
- if (!a) {
+ } else {
a = scope.engine->newArrayObject(len);
}