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));
791 if (engine->currentStackFrame->v4Function->isStrict()) {
792 engine->throwTypeError();
796 o = object.toObject(engine);
798 if (engine->hasException)
801 if (index.isPositiveInt()) {
802 uint idx =
static_cast<uint>(index.int_32());
803 if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
804 Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>();
805 if (idx < s->values.size) {
806 s->setData(engine, idx, value);
810 return o->put(idx, value);
813 ScopedPropertyKey name(scope, index.toPropertyKey(engine));
814 if (engine->hasException)
816 return o->put(name, value);
1088 Scoped<JavaScriptFunctionObject> f(scope);
1090 if (scope.engine->currentStackFrame->isJSTypesFrame()) {
1091 JSTypesStackFrame *frame =
static_cast<JSTypesStackFrame *>(
1092 scope.engine->currentStackFrame);
1094 if (frame->jsFrame->thisObject.isEmpty()) {
1095 scope.engine->throwReferenceError(
1096 QStringLiteral(
"Missing call to super()."), QString(), 0, 0);
1100 f = Value::fromStaticValue(frame->jsFrame->function);
1101 homeObject = f->getHomeObject();
1103 Q_ASSERT(scope.engine->currentStackFrame->isMetaTypesFrame());
1104 MetaTypesStackFrame *frame =
static_cast<MetaTypesStackFrame *>(
1105 scope.engine->currentStackFrame);
1106 if (frame->thisObject() ==
nullptr) {
1107 scope.engine->throwReferenceError(
1108 QStringLiteral(
"Missing call to super()."), QString(), 0, 0);
1117 if (CallContext *c = ctx->asCallContext()) {
1118 f = c->d()->function;
1119 QV4::Function *fn = f->function();
1120 if (fn && !fn->isArrowFunction() && fn->kind != Function::Eval)
1123 ctx = ctx->d()->outer;
1126 homeObject = f->getHomeObject();
1129 scope.engine->throwTypeError();
1132 Q_ASSERT(homeObject);
1133 ScopedObject proto(scope, homeObject->getPrototypeOf());
1135 scope.engine->throwTypeError();
1437 QString objectAsString = QStringLiteral(
"[null]");
1438 if (!thisObject->isUndefined())
1439 objectAsString = thisObject->toQStringNoThrow();
1440 QString msg = QStringLiteral(
"Property '%1' of object %2 is not a function")
1441 .arg(propertyName, objectAsString);
1442 return engine->throwTypeError(msg);
1605 Value *v = scope.constructUndefined(1);
1606 Value *arguments = v;
1607 for (
int i = 0; i < argc; ++i) {
1608 if (!argv[i].isEmpty()) {
1611 v = scope.constructUndefined(1);
1616 it = Runtime::GetIterator::call(scope.engine, argv[i], 1);
1617 if (scope.hasException())
1618 return {
nullptr, 0 };
1620 done = Runtime::IteratorNext::call(scope.engine, it, v);
1621 if (scope.hasException())
1622 return {
nullptr, 0 };
1623 Q_ASSERT(done->isBoolean());
1624 if (done->booleanValue())
1627 constexpr auto safetyMargin = 100;
1628 if (qint64(scope.engine->jsStackLimit - scope.engine->jsStackTop) < safetyMargin) {
1629 scope.engine->throwRangeError(QLatin1String(
"Too many elements in array to use it with the spread operator"));
1630 return {
nullptr, 0 };
1632 v = scope.constructUndefined(1);
1635 return { arguments, argCount };