17ReturnedValue BooleanCtor::virtualCallAsConstructor(
const FunctionObject *that,
const Value *argv,
int argc,
const Value *newTarget)
19 auto v4 = that->engine();
20 bool n = argc ? argv[0].toBoolean() :
false;
22 ReturnedValue o = Encode(v4->newBooleanObject(n));
26 ScopedObject obj(scope, o);
27 obj->setProtoFromNewTarget(newTarget);
28 return obj->asReturnedValue();
37void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor)
40 ScopedObject o(scope);
41 ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
42 ctor->defineReadonlyProperty(engine->id_prototype(), (o =
this));
43 defineDefaultProperty(QStringLiteral(
"constructor"), (o = ctor));
44 defineDefaultProperty(engine->id_toString(), method_toString);
45 defineDefaultProperty(engine->id_valueOf(), method_valueOf);
62ReturnedValue BooleanPrototype::method_toString(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
65 bool result = ::value(thisObject, &exception);
66 ExecutionEngine *v4 = b->engine();
68 return v4->throwTypeError();
70 return (result ? v4->id_true() : v4->id_false())->asReturnedValue();