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));
797 if (engine->currentStackFrame->v4Function->isStrict()) {
798 engine->throwTypeError();
802 o = object.toObject(engine);
804 if (engine->hasException)
807 if (index.isPositiveInt()) {
808 uint idx =
static_cast<uint>(index.int_32());
809 if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
810 Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>();
811 if (idx < s->values.size) {
812 s->setData(engine, idx, value);
816 return o->put(idx, value);
819 ScopedPropertyKey name(scope, index.toPropertyKey(engine));
820 if (engine->hasException)
822 return o->put(name, value);
1095 Scoped<JavaScriptFunctionObject> f(scope);
1097 if (scope.engine->currentStackFrame->isJSTypesFrame()) {
1098 JSTypesStackFrame *frame =
static_cast<JSTypesStackFrame *>(
1099 scope.engine->currentStackFrame);
1101 if (frame->jsFrame->thisObject.isEmpty()) {
1102 scope.engine->throwReferenceError(
1103 QStringLiteral(
"Missing call to super()."), QString(), 0, 0);
1107 f = Value::fromStaticValue(frame->jsFrame->function);
1108 homeObject = f->getHomeObject();
1110 Q_ASSERT(scope.engine->currentStackFrame->isMetaTypesFrame());
1111 MetaTypesStackFrame *frame =
static_cast<MetaTypesStackFrame *>(
1112 scope.engine->currentStackFrame);
1113 if (frame->thisObject() ==
nullptr) {
1114 scope.engine->throwReferenceError(
1115 QStringLiteral(
"Missing call to super()."), QString(), 0, 0);
1124 if (CallContext *c = ctx->asCallContext()) {
1125 f = c->d()->function;
1126 QV4::Function *fn = f->function();
1127 if (fn && !fn->isArrowFunction() && fn->kind != Function::Eval)
1130 ctx = ctx->d()->outer;
1133 homeObject = f->getHomeObject();
1136 scope.engine->throwTypeError();
1139 Q_ASSERT(homeObject);
1140 ScopedObject proto(scope, homeObject->getPrototypeOf());
1142 scope.engine->throwTypeError();
1444 QString objectAsString = QStringLiteral(
"[null]");
1445 if (!thisObject->isUndefined())
1446 objectAsString = thisObject->toQStringNoThrow();
1447 QString msg = QStringLiteral(
"Property '%1' of object %2 is not a function")
1448 .arg(propertyName, objectAsString);
1449 return engine->throwTypeError(msg);
1613 Value *v = scope.constructUndefined(1);
1614 Value *arguments = v;
1615 for (
int i = 0; i < argc; ++i) {
1616 if (!argv[i].isEmpty()) {
1619 v = scope.constructUndefined(1);
1624 it = Runtime::GetIterator::call(scope.engine, argv[i], 1);
1625 if (scope.hasException())
1626 return {
nullptr, 0 };
1628 done = Runtime::IteratorNext::call(scope.engine, it, v);
1629 if (scope.hasException())
1630 return {
nullptr, 0 };
1631 Q_ASSERT(done->isBoolean());
1632 if (done->booleanValue())
1635 constexpr auto safetyMargin = 100;
1636 if (qint64(scope.engine->jsStackLimit - scope.engine->jsStackTop) < safetyMargin) {
1637 scope.engine->throwRangeError(QLatin1String(
"Too many elements in array to use it with the spread operator"));
1638 return {
nullptr, 0 };
1640 v = scope.constructUndefined(1);
1643 return { arguments, argCount };