callData->args[i] = args.at(i).d->getValue(engine);
}
- Value result;
+ ScopedValue result(scope);
QV4::ExecutionContext *ctx = engine->current;
try {
result = f->construct(callData);
vtbl = &static_vtbl;
}
-Value ArrayCtor::construct(Managed *m, CallData *callData)
+ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData)
{
ExecutionEngine *v4 = m->engine();
ArrayObject *a = v4->newArrayObject();
}
a->setArrayLengthUnchecked(len);
- return Value::fromObject(a);
+ return Value::fromObject(a).asReturnedValue();
}
ReturnedValue ArrayCtor::call(Managed *that, CallData *callData)
{
- return construct(that, callData).asReturnedValue();
+ return construct(that, callData);
}
ArrayPrototype::ArrayPrototype(InternalClass *ic)
{
ArrayCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
vtbl = &static_vtbl;
}
-Value BooleanCtor::construct(Managed *m, CallData *callData)
+ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData)
{
bool n = callData->argc ? callData->args[0].toBoolean() : false;
- return Value::fromObject(m->engine()->newBooleanObject(Value::fromBoolean(n)));
+ return Value::fromObject(m->engine()->newBooleanObject(Value::fromBoolean(n))).asReturnedValue();
}
ReturnedValue BooleanCtor::call(Managed *, CallData *callData)
{
BooleanCtor(ExecutionContext *scope);
- static Value construct(Managed *, CallData *callData);
+ static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
vtbl = &static_vtbl;
}
-Value DateCtor::construct(Managed *m, CallData *callData)
+ReturnedValue DateCtor::construct(Managed *m, CallData *callData)
{
double t = 0;
}
Object *o = m->engine()->newDateObject(Value::fromDouble(t));
- return Value::fromObject(o);
+ return Value::fromObject(o).asReturnedValue();
}
ReturnedValue DateCtor::call(Managed *m, CallData *)
{
DateCtor(ExecutionContext *scope);
- static Value construct(Managed *, CallData *callData);
+ static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *);
protected:
vtbl = &static_vtbl;
}
-Value ErrorCtor::construct(Managed *m, CallData *callData)
+ReturnedValue ErrorCtor::construct(Managed *m, CallData *callData)
{
- return Value::fromObject(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Value::undefinedValue()));
+ return Value::fromObject(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue();
}
ReturnedValue ErrorCtor::call(Managed *that, CallData *callData)
{
- return that->construct(callData).asReturnedValue();
+ return that->construct(callData);
}
EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope)
vtbl = &static_vtbl;
}
-Value EvalErrorCtor::construct(Managed *m, CallData *callData)
+ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData)
{
- return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue()));
+ return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue()))
+ .asReturnedValue();
}
RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope)
vtbl = &static_vtbl;
}
-Value RangeErrorCtor::construct(Managed *m, CallData *callData)
+ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData)
{
- return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue()));
+ return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue();
}
ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope)
vtbl = &static_vtbl;
}
-Value ReferenceErrorCtor::construct(Managed *m, CallData *callData)
+ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData)
{
- return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue()));
+ return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue();
}
SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope)
vtbl = &static_vtbl;
}
-Value SyntaxErrorCtor::construct(Managed *m, CallData *callData)
+ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData)
{
- return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue()));
+ return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue();
}
TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope)
vtbl = &static_vtbl;
}
-Value TypeErrorCtor::construct(Managed *m, CallData *callData)
+ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData)
{
- return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue()));
+ return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue();
}
URIErrorCtor::URIErrorCtor(ExecutionContext *scope)
vtbl = &static_vtbl;
}
-Value URIErrorCtor::construct(Managed *m, CallData *callData)
+ReturnedValue URIErrorCtor::construct(Managed *m, CallData *callData)
{
- return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue()));
+ return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue();
}
void ErrorPrototype::init(ExecutionEngine *engine, const Value &ctor, Object *obj)
ErrorCtor(ExecutionContext *scope);
ErrorCtor(ExecutionContext *scope, String *name);
- static Value construct(Managed *, CallData *callData);
+ static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
{
EvalErrorCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
protected:
static const ManagedVTable static_vtbl;
{
RangeErrorCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
protected:
static const ManagedVTable static_vtbl;
{
ReferenceErrorCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
protected:
static const ManagedVTable static_vtbl;
{
SyntaxErrorCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
protected:
static const ManagedVTable static_vtbl;
{
TypeErrorCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
protected:
static const ManagedVTable static_vtbl;
{
URIErrorCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
protected:
static const ManagedVTable static_vtbl;
function->compilationUnit->deref();
}
-Value FunctionObject::newInstance()
+ReturnedValue FunctionObject::newInstance()
{
Scope scope(engine());
ScopedCallData callData(scope, 0);
return false;
}
-Value FunctionObject::construct(Managed *that, CallData *)
+ReturnedValue FunctionObject::construct(Managed *that, CallData *)
{
FunctionObject *f = static_cast<FunctionObject *>(that);
ExecutionEngine *v4 = f->engine();
if (proto.isObject())
ic = v4->emptyClass->changePrototype(proto.objectValue());
Object *obj = v4->newObject(ic);
- return Value::fromObject(obj);
+ return Value::fromObject(obj).asReturnedValue();
}
ReturnedValue FunctionObject::call(Managed *, CallData *)
}
// 15.3.2
-Value FunctionCtor::construct(Managed *that, CallData *callData)
+ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData)
{
FunctionCtor *f = static_cast<FunctionCtor *>(that);
MemoryManager::GCBlocker gcBlocker(f->engine()->memoryManager);
QV4::CompiledData::CompilationUnit *compilationUnit = isel->compile();
QV4::Function *vmf = compilationUnit->linkToEngine(v4);
- return Value::fromObject(FunctionObject::creatScriptFunction(v4->rootContext, vmf));
+ return Value::fromObject(FunctionObject::creatScriptFunction(v4->rootContext, vmf)).asReturnedValue();
}
// 15.3.1: This is equivalent to new Function(...)
ReturnedValue FunctionCtor::call(Managed *that, CallData *callData)
{
- return construct(that, callData).asReturnedValue();
+ return construct(that, callData);
}
FunctionPrototype::FunctionPrototype(InternalClass *ic)
}
}
-Value ScriptFunction::construct(Managed *that, CallData *callData)
+ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData)
{
ScriptFunction *f = static_cast<ScriptFunction *>(that);
ExecutionEngine *v4 = f->engine();
ctx->engine->popContext();
if (result->isObject())
- return result;
- return Value::fromObject(obj);
+ return result.asReturnedValue();
+ return Value::fromObject(obj).asReturnedValue();
}
ReturnedValue ScriptFunction::call(Managed *that, CallData *callData)
}
}
-Value SimpleScriptFunction::construct(Managed *that, CallData *callData)
+ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData)
{
SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that);
ExecutionEngine *v4 = f->engine();
ctx->engine->popContext();
if (result->isObject())
- return result;
- return Value::fromObject(obj);
+ return result.asReturnedValue();
+ return Value::fromObject(obj).asReturnedValue();
}
ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData)
isBuiltinFunction = true;
}
-Value BuiltinFunctionOld::construct(Managed *f, CallData *)
+ReturnedValue BuiltinFunctionOld::construct(Managed *f, CallData *)
{
f->engine()->current->throwTypeError();
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
}
ReturnedValue BuiltinFunctionOld::call(Managed *that, CallData *callData)
return f->target->call(callData);
}
-Value BoundFunction::construct(Managed *that, CallData *dd)
+ReturnedValue BoundFunction::construct(Managed *that, CallData *dd)
{
BoundFunction *f = static_cast<BoundFunction *>(that);
Scope scope(f->scope->engine);
FunctionObject(ExecutionContext *scope, String *name = 0, bool createProto = false);
~FunctionObject();
- Value newInstance();
+ ReturnedValue newInstance();
- static Value construct(Managed *that, CallData *);
+ static ReturnedValue construct(Managed *that, CallData *);
static ReturnedValue call(Managed *that, CallData *d);
- inline Value construct(CallData *callData) {
+ inline ReturnedValue construct(CallData *callData) {
return vtbl->construct(this, callData);
}
inline ReturnedValue call(CallData *callData) {
{
FunctionCtor(ExecutionContext *scope);
- static Value construct(Managed *that, CallData *callData);
+ static ReturnedValue construct(Managed *that, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
BuiltinFunctionOld(ExecutionContext *scope, String *name, Value (*code)(SimpleCallContext *));
- static Value construct(Managed *, CallData *);
+ static ReturnedValue construct(Managed *, CallData *);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
isBuiltinFunction = true;
}
- static Value construct(Managed *m, CallData *)
+ static ReturnedValue construct(Managed *m, CallData *)
{
m->engine()->current->throwTypeError();
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
}
static ReturnedValue call(Managed *that, CallData *callData);
struct ScriptFunction: FunctionObject {
ScriptFunction(ExecutionContext *scope, Function *function);
- static Value construct(Managed *, CallData *callData);
+ static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
struct SimpleScriptFunction: FunctionObject {
SimpleScriptFunction(ExecutionContext *scope, Function *function);
- static Value construct(Managed *, CallData *callData);
+ static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
~BoundFunction() {}
- static Value construct(Managed *, CallData *d);
+ static ReturnedValue construct(Managed *, CallData *d);
static ReturnedValue call(Managed *that, CallData *dd);
static const ManagedVTable static_vtbl;
m->engine()->current->throwTypeError();
}
-Value Managed::construct(Managed *m, CallData *)
+ReturnedValue Managed::construct(Managed *m, CallData *)
{
m->engine()->current->throwTypeError();
}
struct ManagedVTable
{
ReturnedValue (*call)(Managed *, CallData *data);
- Value (*construct)(Managed *, CallData *data);
+ ReturnedValue (*construct)(Managed *, CallData *data);
void (*markObjects)(Managed *);
void (*destroy)(Managed *);
void (*collectDeletables)(Managed *, GCDeletable **deletable);
inline bool hasInstance(const Value &v) {
return vtbl->hasInstance(this, v);
}
- Value construct(CallData *d);
+ ReturnedValue construct(CallData *d);
ReturnedValue call(CallData *d);
Value get(String *name, bool *hasProperty = 0);
Value getIndexed(uint index, bool *hasProperty = 0);
static void destroy(Managed *that) { that->_data = 0; }
static bool hasInstance(Managed *that, const Value &value);
- static Value construct(Managed *m, CallData *d);
+ static ReturnedValue construct(Managed *m, CallData *d);
static ReturnedValue call(Managed *m, CallData *);
static void getLookup(Managed *m, Lookup *, Value *);
static void setLookup(Managed *m, Lookup *l, const Value &v);
vtbl = &static_vtbl;
}
-Value NumberCtor::construct(Managed *m, CallData *callData)
+ReturnedValue NumberCtor::construct(Managed *m, CallData *callData)
{
double dbl = callData->argc ? callData->args[0].toNumber() : 0.;
- return Value::fromObject(m->engine()->newNumberObject(Value::fromDouble(dbl)));
+ return Value::fromObject(m->engine()->newNumberObject(Value::fromDouble(dbl))).asReturnedValue();
}
ReturnedValue NumberCtor::call(Managed *, CallData *callData)
{
NumberCtor(ExecutionContext *scope);
- static Value construct(Managed *that, CallData *callData);
+ static ReturnedValue construct(Managed *that, CallData *callData);
static ReturnedValue call(Managed *, CallData *callData);
protected:
vtbl = &static_vtbl;
}
-Value ObjectCtor::construct(Managed *that, CallData *callData)
+ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData)
{
ObjectCtor *ctor = static_cast<ObjectCtor *>(that);
ExecutionEngine *v4 = that->engine();
Value proto = ctor->get(v4->id_prototype);
if (proto.isObject())
obj->setPrototype(proto.objectValue());
- return Value::fromObject(obj);
+ return Value::fromObject(obj).asReturnedValue();
}
- return Value::fromReturnedValue(__qmljs_to_object(v4->current, ValueRef(&callData->args[0])));
+ return Value::fromReturnedValue(__qmljs_to_object(v4->current, ValueRef(&callData->args[0]))).asReturnedValue();
}
ReturnedValue ObjectCtor::call(Managed *m, CallData *callData)
{
ObjectCtor(ExecutionContext *scope);
- static Value construct(Managed *that, CallData *callData);
+ static ReturnedValue construct(Managed *that, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
vtbl = &static_vtbl;
}
-Value RegExpCtor::construct(Managed *m, CallData *callData)
+ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
{
ExecutionContext *ctx = m->engine()->current;
Scope scope(ctx);
ctx->throwTypeError();
RegExpObject *o = ctx->engine->newRegExpObject(re->value, re->global);
- return Value::fromObject(o);
+ return Value::fromObject(o).asReturnedValue();
}
QString pattern;
ctx->throwSyntaxError(0);
RegExpObject *o = ctx->engine->newRegExpObject(re, global);
- return Value::fromObject(o);
+ return Value::fromObject(o).asReturnedValue();
}
ReturnedValue RegExpCtor::call(Managed *that, CallData *callData)
return callData->args[0].asReturnedValue();
}
- return construct(that, callData).asReturnedValue();
+ return construct(that, callData);
}
void RegExpPrototype::init(ExecutionContext *ctx, const Value &ctor)
ScopedCallData callData(scope, ctx->argumentCount);
memcpy(callData->args, ctx->arguments, ctx->argumentCount*sizeof(Value));
- RegExpObject *re = ctx->engine->regExpCtor.asFunctionObject()->construct(callData).as<RegExpObject>();
+ RegExpObject *re = Value::fromReturnedValue(ctx->engine->regExpCtor.asFunctionObject()->construct(callData)).as<RegExpObject>();
r->value = re->value;
r->global = re->global;
{
RegExpCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
if (!f)
context->throwTypeError();
- return f->construct(callData).asReturnedValue();
+ return f->construct(callData);
}
if (!f)
context->throwTypeError();
- return f->construct(callData).asReturnedValue();
+ return f->construct(callData);
}
ReturnedValue __qmljs_construct_value(ExecutionContext *context, const ValueRef func, CallDataRef callData)
if (!f)
context->throwTypeError();
- return f->construct(callData).asReturnedValue();
+ return f->construct(callData);
}
ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueRef base, String *name, CallDataRef callData)
if (!f)
context->throwTypeError();
- return f->construct(callData).asReturnedValue();
+ return f->construct(callData);
}
void __qmljs_throw(ExecutionContext *context, const ValueRef value)
vtbl = &static_vtbl;
}
-Value StringCtor::construct(Managed *m, CallData *callData)
+ReturnedValue StringCtor::construct(Managed *m, CallData *callData)
{
Value value;
if (callData->argc)
value = Value::fromString(callData->args[0].toString(m->engine()->current));
else
value = Value::fromString(m->engine()->current, QString());
- return Value::fromObject(m->engine()->newStringObject(value));
+ return Value::fromObject(m->engine()->newStringObject(value)).asReturnedValue();
}
ReturnedValue StringCtor::call(Managed *m, CallData *callData)
if (!rx) {
ScopedCallData callData(scope, 1);
callData->args[0] = regexp;
- rx = context->engine->regExpCtor.asFunctionObject()->construct(callData).as<RegExpObject>();
+ rx = Value::fromReturnedValue(context->engine->regExpCtor.asFunctionObject()->construct(callData)).as<RegExpObject>();
}
if (!rx)
else
string = ctx->thisObject.toString(ctx)->toQString();
- Value regExpValue = ctx->argument(0);
- RegExpObject *regExp = regExpValue.as<RegExpObject>();
+ ScopedValue regExpValue(scope, ctx->argument(0));
+ RegExpObject *regExp = regExpValue->as<RegExpObject>();
if (!regExp) {
ScopedCallData callData(scope, 1);
callData->args[0] = regExpValue;
regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(callData);
- regExp = regExpValue.as<RegExpObject>();
+ regExp = regExpValue->as<RegExpObject>();
}
uint* matchOffsets = (uint*)alloca(regExp->value->captureCount() * 2 * sizeof(uint));
uint result = regExp->value->match(string, /*offset*/0, matchOffsets);
{
StringCtor(ExecutionContext *scope);
- static Value construct(Managed *m, CallData *callData);
+ static ReturnedValue construct(Managed *m, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
protected:
}
// ###
-inline Value Managed::construct(CallData *d) {
+inline ReturnedValue Managed::construct(CallData *d) {
return vtbl->construct(this, d);
}
inline ReturnedValue Managed::call(CallData *d) {
if (c->proto)
c->proto->mark();
}
- static Value construct(Managed *that, QV4::CallData *)
+ static ReturnedValue construct(Managed *that, QV4::CallData *)
{
QQmlXMLHttpRequestCtor *ctor = that->as<QQmlXMLHttpRequestCtor>();
if (!ctor)
QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager());
QQmlXMLHttpRequestWrapper *w = new (that->engine()->memoryManager) QQmlXMLHttpRequestWrapper(that->engine(), r);
w->setPrototype(ctor->proto);
- return Value::fromObject(w);
+ return Value::fromObject(w).asReturnedValue();
}
static ReturnedValue call(Managed *, QV4::CallData *) {
isBuiltinFunction = true;
}
- static QV4::Value construct(QV4::Managed *m, QV4::CallData *)
+ static QV4::ReturnedValue construct(QV4::Managed *m, QV4::CallData *)
{
m->engine()->current->throwTypeError();
- return QV4::Value::undefinedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
}
static QV4::ReturnedValue call(QV4::Managed *that, QV4::CallData *callData)