362 const Object *rhs = rval.as<Object>();
364 return engine->throwTypeError();
366 const FunctionObject *f = rhs->as<FunctionObject>();
369 if (f && f->d()->prototype() == engine->functionPrototype()->d() && !f->hasHasInstanceProperty())
370 return Object::checkedInstanceOf(engine, f, lval);
373 ScopedValue hasInstance(scope, rhs->get(engine->symbol_hasInstance()));
374 if (hasInstance->isUndefined())
375 return Encode(rhs->instanceOf(lval));
377 FunctionObject *fHasInstance = hasInstance->as<FunctionObject>();
379 return engine->throwTypeError();
381 return Encode(fHasInstance->call(&rval, &lval, 1));
793 if (engine->currentStackFrame->v4Function->isStrict()) {
794 engine->throwTypeError();
798 o = object.toObject(engine);
800 if (engine->hasException)
803 if (index.isPositiveInt()) {
804 uint idx =
static_cast<uint>(index.int_32());
805 if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
806 Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>();
807 if (idx < s->values.size) {
808 s->setData(engine, idx, value);
812 return o->put(idx, value);
815 ScopedPropertyKey name(scope, index.toPropertyKey(engine));
816 if (engine->hasException)
818 return o->put(name, value);
1091 Scoped<JavaScriptFunctionObject> f(scope);
1093 if (scope.engine->currentStackFrame->isJSTypesFrame()) {
1094 JSTypesStackFrame *frame =
static_cast<JSTypesStackFrame *>(
1095 scope.engine->currentStackFrame);
1097 if (frame->jsFrame->thisObject.isEmpty()) {
1098 scope.engine->throwReferenceError(
1099 QStringLiteral(
"Missing call to super()."), QString(), 0, 0);
1103 f = Value::fromStaticValue(frame->jsFrame->function);
1104 homeObject = f->getHomeObject();
1106 Q_ASSERT(scope.engine->currentStackFrame->isMetaTypesFrame());
1107 MetaTypesStackFrame *frame =
static_cast<MetaTypesStackFrame *>(
1108 scope.engine->currentStackFrame);
1109 if (frame->thisObject() ==
nullptr) {
1110 scope.engine->throwReferenceError(
1111 QStringLiteral(
"Missing call to super()."), QString(), 0, 0);
1120 if (CallContext *c = ctx->asCallContext()) {
1121 f = c->d()->function;
1122 QV4::Function *fn = f->function();
1123 if (fn && !fn->isArrowFunction() && fn->kind != Function::Eval)
1126 ctx = ctx->d()->outer;
1129 homeObject = f->getHomeObject();
1132 scope.engine->throwTypeError();
1135 Q_ASSERT(homeObject);
1136 ScopedObject proto(scope, homeObject->getPrototypeOf());
1138 scope.engine->throwTypeError();
1440 QString objectAsString = QStringLiteral(
"[null]");
1441 if (!thisObject->isUndefined())
1442 objectAsString = thisObject->toQStringNoThrow();
1443 QString msg = QStringLiteral(
"Property '%1' of object %2 is not a function")
1444 .arg(propertyName, objectAsString);
1445 return engine->throwTypeError(msg);
1609 Value *v = scope.constructUndefined(1);
1610 Value *arguments = v;
1611 for (
int i = 0; i < argc; ++i) {
1612 if (!argv[i].isEmpty()) {
1615 v = scope.constructUndefined(1);
1620 it = Runtime::GetIterator::call(scope.engine, argv[i], 1);
1621 if (scope.hasException())
1622 return {
nullptr, 0 };
1624 done = Runtime::IteratorNext::call(scope.engine, it, v);
1625 if (scope.hasException())
1626 return {
nullptr, 0 };
1627 Q_ASSERT(done->isBoolean());
1628 if (done->booleanValue())
1631 constexpr auto safetyMargin = 100;
1632 if (qint64(scope.engine->jsStackLimit - scope.engine->jsStackTop) < safetyMargin) {
1633 scope.engine->throwRangeError(QLatin1String(
"Too many elements in array to use it with the spread operator"));
1634 return {
nullptr, 0 };
1636 v = scope.constructUndefined(1);
1639 return { arguments, argCount };