Remove the context argument from Managed::construct
authorLars Knoll <lars.knoll@digia.com>
Sat, 22 Jun 2013 07:29:23 +0000 (09:29 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Sat, 22 Jun 2013 20:11:45 +0000 (22:11 +0200)
Change-Id: I39f5c23de787da70cd4259b3cdcd56391ee0dc7b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
25 files changed:
src/qml/qml/qqmlxmlhttprequest.cpp
src/qml/qml/v4/qv4arrayobject.cpp
src/qml/qml/v4/qv4arrayobject_p.h
src/qml/qml/v4/qv4booleanobject.cpp
src/qml/qml/v4/qv4booleanobject_p.h
src/qml/qml/v4/qv4dateobject.cpp
src/qml/qml/v4/qv4dateobject_p.h
src/qml/qml/v4/qv4errorobject.cpp
src/qml/qml/v4/qv4errorobject_p.h
src/qml/qml/v4/qv4functionobject.cpp
src/qml/qml/v4/qv4functionobject_p.h
src/qml/qml/v4/qv4managed.cpp
src/qml/qml/v4/qv4managed_p.h
src/qml/qml/v4/qv4numberobject.cpp
src/qml/qml/v4/qv4numberobject_p.h
src/qml/qml/v4/qv4objectproto.cpp
src/qml/qml/v4/qv4objectproto_p.h
src/qml/qml/v4/qv4regexpobject.cpp
src/qml/qml/v4/qv4regexpobject_p.h
src/qml/qml/v4/qv4runtime.cpp
src/qml/qml/v4/qv4stringobject.cpp
src/qml/qml/v4/qv4stringobject_p.h
src/qml/qml/v4/qv4value_p.h
src/qml/qml/v8/qjsvalue.cpp
src/qml/types/qqmldelegatemodel.cpp

index aec4949..e1de67c 100644 (file)
@@ -1556,15 +1556,15 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
         if (c->proto)
             c->proto->mark();
     }
-    static Value construct(Managed *that, ExecutionContext *context, Value *, int)
+    static Value construct(Managed *that, Value *, int)
     {
         QQmlXMLHttpRequestCtor *ctor = that->as<QQmlXMLHttpRequestCtor>();
         if (!ctor)
-            context->throwTypeError();
+            that->engine()->current->throwTypeError();
 
-        QV8Engine *engine = context->engine->v8Engine;
+        QV8Engine *engine = that->engine()->v8Engine;
         QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager());
-        QQmlXMLHttpRequestWrapper *w = new (context->engine->memoryManager) QQmlXMLHttpRequestWrapper(context->engine, r);
+        QQmlXMLHttpRequestWrapper *w = new (that->engine()->memoryManager) QQmlXMLHttpRequestWrapper(that->engine(), r);
         w->prototype = ctor->proto;
         return Value::fromObject(w);
     }
index 4734fbc..6f3f36a 100644 (file)
@@ -52,16 +52,17 @@ ArrayCtor::ArrayCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value ArrayCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int argc)
+Value ArrayCtor::construct(Managed *m, Value *argv, int argc)
 {
-    ArrayObject *a = ctx->engine->newArrayObject();
+    ExecutionEngine *v4 = m->engine();
+    ArrayObject *a = v4->newArrayObject();
     uint len;
     if (argc == 1 && argv[0].isNumber()) {
         bool ok;
         len = argv[0].asArrayLength(&ok);
 
         if (!ok)
-            ctx->throwRangeError(argv[0]);
+            v4->current->throwRangeError(argv[0]);
 
         if (len < 0x1000)
             a->arrayReserve(len);
@@ -77,9 +78,9 @@ Value ArrayCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int ar
     return Value::fromObject(a);
 }
 
-Value ArrayCtor::call(Managed *that, ExecutionContext *ctx, const Value &thisObject, Value *argv, int argc)
+Value ArrayCtor::call(Managed *that, ExecutionContext *, const Value &, Value *argv, int argc)
 {
-    return construct(that, ctx, argv, argc);
+    return construct(that, argv, argc);
 }
 
 ArrayPrototype::ArrayPrototype(ExecutionContext *context)
index 4201997..a1c9eb4 100644 (file)
@@ -53,7 +53,7 @@ struct ArrayCtor: FunctionObject
 {
     ArrayCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
index 3395e79..049f577 100644 (file)
@@ -51,10 +51,10 @@ BooleanCtor::BooleanCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value BooleanCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value BooleanCtor::construct(Managed *m, Value *args, int argc)
 {
     bool n = argc ? args[0].toBoolean() : false;
-    return Value::fromObject(ctx->engine->newBooleanObject(Value::fromBoolean(n)));
+    return Value::fromObject(m->engine()->newBooleanObject(Value::fromBoolean(n)));
 }
 
 Value BooleanCtor::call(Managed *, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc)
index 79f5d4a..cffdf8a 100644 (file)
@@ -53,7 +53,7 @@ struct BooleanCtor: FunctionObject
 {
     BooleanCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
index 83fdc2f..ab1c91a 100644 (file)
@@ -659,7 +659,7 @@ DateCtor::DateCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value DateCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value DateCtor::construct(Managed *m, Value *args, int argc)
 {
     double t = 0;
 
@@ -693,7 +693,7 @@ Value DateCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int arg
         t = TimeClip(UTC(t));
     }
 
-    Object *d = ctx->engine->newDateObject(Value::fromDouble(t));
+    Object *d = m->engine()->newDateObject(Value::fromDouble(t));
     return Value::fromObject(d);
 }
 
index dc94291..d58d5bd 100644 (file)
@@ -63,7 +63,7 @@ struct DateCtor: FunctionObject
 {
     DateCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
index ffd3058..bee8f5c 100644 (file)
@@ -235,14 +235,14 @@ ErrorCtor::ErrorCtor(ExecutionContext *scope, String *name)
     vtbl = &static_vtbl;
 }
 
-Value ErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value ErrorCtor::construct(Managed *m, Value *args, int argc)
 {
-    return Value::fromObject(ctx->engine->newErrorObject(argc ? args[0] : Value::undefinedValue()));
+    return Value::fromObject(m->engine()->newErrorObject(argc ? args[0] : Value::undefinedValue()));
 }
 
 Value ErrorCtor::call(Managed *that, ExecutionContext *ctx, const Value &, Value *args, int argc)
 {
-    return that->construct(ctx, args, argc);
+    return that->construct(args, argc);
 }
 
 EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope)
@@ -251,9 +251,9 @@ EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value EvalErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value EvalErrorCtor::construct(Managed *m, Value *args, int argc)
 {
-    return Value::fromObject(new (ctx->engine->memoryManager) EvalErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue()));
+    return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue()));
 }
 
 RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope)
@@ -262,9 +262,9 @@ RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value RangeErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value RangeErrorCtor::construct(Managed *m, Value *args, int argc)
 {
-    return Value::fromObject(new (ctx->engine->memoryManager) RangeErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue()));
+    return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue()));
 }
 
 ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope)
@@ -273,9 +273,9 @@ ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value ReferenceErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value ReferenceErrorCtor::construct(Managed *m, Value *args, int argc)
 {
-    return Value::fromObject(new (ctx->engine->memoryManager) ReferenceErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue()));
+    return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue()));
 }
 
 SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope)
@@ -284,9 +284,9 @@ SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value SyntaxErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value SyntaxErrorCtor::construct(Managed *m, Value *args, int argc)
 {
-    return Value::fromObject(new (ctx->engine->memoryManager) SyntaxErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue()));
+    return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue()));
 }
 
 TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope)
@@ -295,9 +295,9 @@ TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value TypeErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value TypeErrorCtor::construct(Managed *m, Value *args, int argc)
 {
-    return Value::fromObject(new (ctx->engine->memoryManager) TypeErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue()));
+    return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue()));
 }
 
 URIErrorCtor::URIErrorCtor(ExecutionContext *scope)
@@ -306,9 +306,9 @@ URIErrorCtor::URIErrorCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value URIErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value URIErrorCtor::construct(Managed *m, Value *args, int argc)
 {
-    return Value::fromObject(new (ctx->engine->memoryManager) URIErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue()));
+    return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue()));
 }
 
 void ErrorPrototype::init(ExecutionEngine *engine, const Value &ctor, Object *obj)
index a5a6bba..774e9e8 100644 (file)
@@ -119,7 +119,7 @@ struct ErrorCtor: FunctionObject
     ErrorCtor(ExecutionContext *scope);
     ErrorCtor(ExecutionContext *scope, String *name);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
@@ -130,7 +130,7 @@ struct EvalErrorCtor: ErrorCtor
 {
     EvalErrorCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
 
 protected:
     static const ManagedVTable static_vtbl;
@@ -140,7 +140,7 @@ struct RangeErrorCtor: ErrorCtor
 {
     RangeErrorCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
 
 protected:
     static const ManagedVTable static_vtbl;
@@ -150,7 +150,7 @@ struct ReferenceErrorCtor: ErrorCtor
 {
     ReferenceErrorCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
 
 protected:
     static const ManagedVTable static_vtbl;
@@ -160,7 +160,7 @@ struct SyntaxErrorCtor: ErrorCtor
 {
     SyntaxErrorCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
 
 protected:
     static const ManagedVTable static_vtbl;
@@ -170,7 +170,7 @@ struct TypeErrorCtor: ErrorCtor
 {
     TypeErrorCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
 
 protected:
     static const ManagedVTable static_vtbl;
@@ -180,7 +180,7 @@ struct URIErrorCtor: ErrorCtor
 {
     URIErrorCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
 
 protected:
     static const ManagedVTable static_vtbl;
index a27ac16..96ea4ee 100644 (file)
@@ -94,7 +94,7 @@ FunctionObject::FunctionObject(ExecutionContext *scope, String *name)
 
 Value FunctionObject::newInstance()
 {
-    return construct(internalClass->engine->current, 0, 0);
+    return construct(0, 0);
 }
 
 bool FunctionObject::hasInstance(Managed *that, const Value &value)
@@ -122,12 +122,13 @@ bool FunctionObject::hasInstance(Managed *that, const Value &value)
     return false;
 }
 
-Value FunctionObject::construct(Managed *that, ExecutionContext *context, Value *, int)
+Value FunctionObject::construct(Managed *that, Value *, int)
 {
     FunctionObject *f = static_cast<FunctionObject *>(that);
+    ExecutionEngine *v4 = f->engine();
 
-    Object *obj = context->engine->newObject();
-    Value proto = f->get(context->engine->id_prototype);
+    Object *obj = v4->newObject();
+    Value proto = f->get(v4->id_prototype);
     if (proto.isObject())
         obj->prototype = proto.objectValue();
     return Value::fromObject(obj);
@@ -165,11 +166,12 @@ FunctionCtor::FunctionCtor(ExecutionContext *scope)
 }
 
 // 15.3.2
-Value FunctionCtor::construct(Managed *that, ExecutionContext *ctx, Value *args, int argc)
+Value FunctionCtor::construct(Managed *that, Value *args, int argc)
 {
     FunctionCtor *f = static_cast<FunctionCtor *>(that);
-    MemoryManager::GCBlocker gcBlocker(ctx->engine->memoryManager);
+    MemoryManager::GCBlocker gcBlocker(f->engine()->memoryManager);
 
+    ExecutionContext *ctx = f->engine()->current;
     QString arguments;
     QString body;
     if (argc > 0) {
@@ -191,28 +193,29 @@ Value FunctionCtor::construct(Managed *that, ExecutionContext *ctx, Value *args,
     const bool parsed = parser.parseExpression();
 
     if (!parsed)
-        ctx->throwSyntaxError(0);
+        f->engine()->current->throwSyntaxError(0);
 
     using namespace QQmlJS::AST;
     FunctionExpression *fe = QQmlJS::AST::cast<FunctionExpression *>(parser.rootNode());
+    ExecutionEngine *v4 = f->engine();
     if (!fe)
-        ctx->throwSyntaxError(0);
+        v4->current->throwSyntaxError(0);
 
     QQmlJS::V4IR::Module module;
 
-    QQmlJS::Codegen cg(ctx, f->strictMode);
+    QQmlJS::Codegen cg(v4->current, f->strictMode);
     QQmlJS::V4IR::Function *irf = cg(QString(), function, fe, &module);
 
-    QScopedPointer<QQmlJS::EvalInstructionSelection> isel(ctx->engine->iselFactory->create(ctx->engine, &module));
+    QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(v4, &module));
     QV4::Function *vmf = isel->vmFunction(irf);
 
-    return Value::fromObject(ctx->engine->newScriptFunction(ctx->engine->rootContext, vmf));
+    return Value::fromObject(v4->newScriptFunction(v4->rootContext, vmf));
 }
 
 // 15.3.1: This is equivalent to new Function(...)
 Value FunctionCtor::call(Managed *that, ExecutionContext *context, const Value &thisObject, Value *args, int argc)
 {
-    return construct(that, context, args, argc);
+    return construct(that, args, argc);
 }
 
 FunctionPrototype::FunctionPrototype(ExecutionContext *ctx)
@@ -346,17 +349,19 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
     }
 }
 
-Value ScriptFunction::construct(Managed *that, ExecutionContext *context, Value *args, int argc)
+Value ScriptFunction::construct(Managed *that, Value *args, int argc)
 {
     ScriptFunction *f = static_cast<ScriptFunction *>(that);
     assert(f->function->code);
-    Object *obj = context->engine->newObject();
-    Value proto = f->get(context->engine->id_prototype);
+    ExecutionEngine *v4 = f->engine();
+    Object *obj = v4->newObject();
+    Value proto = f->get(v4->id_prototype);
     if (proto.isObject())
         obj->prototype = proto.objectValue();
 
+    ExecutionContext *context = v4->current;
     quintptr stackSpace[stackContextSize/sizeof(quintptr)];
-    ExecutionContext *ctx = context->engine->newCallContext(stackSpace, f, Value::fromObject(obj), args, argc);
+    ExecutionContext *ctx = v4->newCallContext(stackSpace, f, Value::fromObject(obj), args, argc);
 
     Value result;
     try {
@@ -410,9 +415,9 @@ BuiltinFunctionOld::BuiltinFunctionOld(ExecutionContext *scope, String *name, Va
     isBuiltinFunction = true;
 }
 
-Value BuiltinFunctionOld::construct(Managed *, ExecutionContext *ctx, Value *, int)
+Value BuiltinFunctionOld::construct(Managed *f, Value *, int)
 {
-    ctx->throwTypeError();
+    f->engine()->current->throwTypeError();
     return Value::undefinedValue();
 }
 
@@ -517,14 +522,14 @@ Value BoundFunction::call(Managed *that, ExecutionContext *context, const Value
     return f->target->call(context, f->boundThis, newArgs, f->boundArgs.size() + argc);
 }
 
-Value BoundFunction::construct(Managed *that, ExecutionContext *context, Value *args, int argc)
+Value BoundFunction::construct(Managed *that, Value *args, int argc)
 {
     BoundFunction *f = static_cast<BoundFunction *>(that);
     Value *newArgs = static_cast<Value *>(alloca(sizeof(Value)*(f->boundArgs.size() + argc)));
     memcpy(newArgs, f->boundArgs.constData(), f->boundArgs.size()*sizeof(Value));
     memcpy(newArgs + f->boundArgs.size(), args, argc*sizeof(Value));
 
-    return f->target->construct(context, newArgs, f->boundArgs.size() + argc);
+    return f->target->construct(newArgs, f->boundArgs.size() + argc);
 }
 
 bool BoundFunction::hasInstance(Managed *that, const Value &value)
index 09b31c0..9616052 100644 (file)
@@ -114,13 +114,10 @@ struct Q_QML_EXPORT FunctionObject: Object {
 
     Value newInstance();
 
-    static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *that, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
-    inline Value construct(ExecutionContext *context, Value *args, int argc) {
-        return vtbl->construct(this, context, args, argc);
-    }
     inline Value construct(Value *args, int argc) {
-        return vtbl->construct(this, engine()->current, args, argc);
+        return vtbl->construct(this, args, argc);
     }
     inline Value call(ExecutionContext *context, const Value &thisObject, Value *args, int argc) {
         return vtbl->call(this, context, thisObject, args, argc);
@@ -139,7 +136,7 @@ struct FunctionCtor: FunctionObject
 {
     FunctionCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *that, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
@@ -162,7 +159,7 @@ struct BuiltinFunctionOld: FunctionObject {
 
     BuiltinFunctionOld(ExecutionContext *scope, String *name, Value (*code)(SimpleCallContext *));
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
@@ -185,9 +182,9 @@ struct IndexedBuiltinFunction: FunctionObject
         isBuiltinFunction = true;
     }
 
-    static Value construct(Managed *, ExecutionContext *ctx, Value *, int)
+    static Value construct(Managed *m, Value *, int)
     {
-        ctx->throwTypeError();
+        m->engine()->current->throwTypeError();
         return Value::undefinedValue();
     }
 
@@ -198,7 +195,7 @@ struct IndexedBuiltinFunction: FunctionObject
 struct ScriptFunction: FunctionObject {
     ScriptFunction(ExecutionContext *scope, Function *function);
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
@@ -214,7 +211,7 @@ struct BoundFunction: FunctionObject {
     ~BoundFunction() {}
 
 
-    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
     static const ManagedVTable static_vtbl;
index 6372719..545f88b 100644 (file)
@@ -176,9 +176,9 @@ bool Managed::hasInstance(Managed *m, const Value &)
     m->engine()->current->throwTypeError();
 }
 
-Value Managed::construct(Managed *, ExecutionContext *context, Value *, int)
+Value Managed::construct(Managed *m, Value *, int)
 {
-    context->throwTypeError();
+    m->engine()->current->throwTypeError();
 }
 
 Value Managed::call(Managed *, ExecutionContext *context, const Value &, Value *, int)
index 2f88478..39b7f0c 100644 (file)
@@ -100,7 +100,7 @@ struct GCDeletable
 struct ManagedVTable
 {
     Value (*call)(Managed *, ExecutionContext *context, const Value &thisObject, Value *args, int argc);
-    Value (*construct)(Managed *, ExecutionContext *context, Value *args, int argc);
+    Value (*construct)(Managed *, Value *args, int argc);
     void (*markObjects)(Managed *);
     void (*destroy)(Managed *);
     void (*collectDeletables)(Managed *, GCDeletable **deletable);
@@ -260,7 +260,7 @@ public:
     inline bool hasInstance(const Value &v) {
         return vtbl->hasInstance(this, v);
     }
-    Value construct(ExecutionContext *context, Value *args, int argc);
+    Value construct(Value *args, int argc);
     Value call(ExecutionContext *context, const Value &thisObject, Value *args, int argc);
     Value get(String *name, bool *hasProperty = 0);
     Value getIndexed(uint index, bool *hasProperty = 0);
@@ -289,7 +289,7 @@ public:
 
     static void destroy(Managed *that) { that->_data = 0; }
     static bool hasInstance(Managed *that, const Value &value);
-    static Value construct(Managed *, ExecutionContext *context, Value *, int);
+    static Value construct(Managed *m, Value *, int);
     static Value call(Managed *, ExecutionContext *, const Value &, Value *, int);
     static void getLookup(Managed *m, Lookup *, Value *);
     static void setLookup(Managed *m, Lookup *l, const Value &v);
index 6bd03ab..2e5ed49 100644 (file)
@@ -56,10 +56,10 @@ NumberCtor::NumberCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value NumberCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+Value NumberCtor::construct(Managed *m, Value *args, int argc)
 {
     double d = argc ? args[0].toNumber() : 0.;
-    return Value::fromObject(ctx->engine->newNumberObject(Value::fromDouble(d)));
+    return Value::fromObject(m->engine()->newNumberObject(Value::fromDouble(d)));
 }
 
 Value NumberCtor::call(Managed *m, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc)
index f7f5ed7..2cc3c0b 100644 (file)
@@ -53,7 +53,7 @@ struct NumberCtor: FunctionObject
 {
     NumberCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *that, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
index 1d6eda4..b1d1a9e 100644 (file)
@@ -79,17 +79,18 @@ ObjectCtor::ObjectCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value ObjectCtor::construct(Managed *that, ExecutionContext *ctx, Value *args, int argc)
+Value ObjectCtor::construct(Managed *that, Value *args, int argc)
 {
     ObjectCtor *ctor = static_cast<ObjectCtor *>(that);
+    ExecutionEngine *v4 = that->engine();
     if (!argc || args[0].isUndefined() || args[0].isNull()) {
-        Object *obj = ctx->engine->newObject();
-        Value proto = ctor->get(ctx->engine->id_prototype);
+        Object *obj = v4->newObject();
+        Value proto = ctor->get(v4->id_prototype);
         if (proto.isObject())
             obj->prototype = proto.objectValue();
         return Value::fromObject(obj);
     }
-    return __qmljs_to_object(ctx, args[0]);
+    return __qmljs_to_object(v4->current, args[0]);
 }
 
 Value ObjectCtor::call(Managed *, ExecutionContext *ctx, const Value &/*thisObject*/, Value *args, int argc)
index 84bc715..e16f554 100644 (file)
@@ -53,7 +53,7 @@ struct ObjectCtor: FunctionObject
 {
     ObjectCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *that, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
index fc6ffd2..a346f9e 100644 (file)
@@ -218,10 +218,11 @@ RegExpCtor::RegExpCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value RegExpCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int argc)
+Value RegExpCtor::construct(Managed *m, Value *argv, int argc)
 {
     Value r = argc > 0 ? argv[0] : Value::undefinedValue();
     Value f = argc > 1 ? argv[1] : Value::undefinedValue();
+    ExecutionContext *ctx = m->engine()->current;
     if (RegExpObject *re = r.as<RegExpObject>()) {
         if (!f.isUndefined())
             ctx->throwTypeError();
@@ -268,7 +269,7 @@ Value RegExpCtor::call(Managed *that, ExecutionContext *ctx, const Value &thisOb
             return argv[0];
     }
 
-    return construct(that, ctx, argv, argc);
+    return construct(that, argv, argc);
 }
 
 void RegExpPrototype::init(ExecutionContext *ctx, const Value &ctor)
@@ -346,7 +347,7 @@ Value RegExpPrototype::method_compile(SimpleCallContext *ctx)
     if (!r)
         ctx->throwTypeError();
 
-    RegExpObject *re = ctx->engine->regExpCtor.asFunctionObject()->construct(ctx, ctx->arguments, ctx->argumentCount).as<RegExpObject>();
+    RegExpObject *re = ctx->engine->regExpCtor.asFunctionObject()->construct(ctx->arguments, ctx->argumentCount).as<RegExpObject>();
 
     r->value = re->value;
     r->global = re->global;
index 8589d1e..7fb520c 100644 (file)
@@ -98,7 +98,7 @@ struct RegExpCtor: FunctionObject
 {
     RegExpCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
index 774abb6..22e43ca 100644 (file)
@@ -889,7 +889,7 @@ void __qmljs_construct_global_lookup(ExecutionContext *context, Value *result, u
     l->globalGetter(l, context, &func);
 
     if (Object *f = func.asObject()) {
-        Value res = f->construct(context, args, argc);
+        Value res = f->construct(args, argc);
         if (result)
             *result = res;
         return;
@@ -908,7 +908,7 @@ void __qmljs_construct_activation_property(ExecutionContext *context, Value *res
 void __qmljs_construct_value(ExecutionContext *context, Value *result, const Value &func, Value *args, int argc)
 {
     if (Object *f = func.asObject()) {
-        Value res = f->construct(context, args, argc);
+        Value res = f->construct(args, argc);
         if (result)
             *result = res;
         return;
@@ -923,7 +923,7 @@ void __qmljs_construct_property(ExecutionContext *context, Value *result, const
 
     Value func = thisObject->get(name);
     if (Object *f = func.asObject()) {
-        Value res = f->construct(context, args, argc);
+        Value res = f->construct(args, argc);
         if (result)
             *result = res;
         return;
index 350a2c4..8845e63 100644 (file)
@@ -149,14 +149,14 @@ StringCtor::StringCtor(ExecutionContext *scope)
     vtbl = &static_vtbl;
 }
 
-Value StringCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int argc)
+Value StringCtor::construct(Managed *m, Value *argv, int argc)
 {
     Value value;
     if (argc)
-        value = Value::fromString(argv[0].toString(ctx));
+        value = Value::fromString(argv[0].toString(m->engine()->current));
     else
-        value = Value::fromString(ctx, QString());
-    return Value::fromObject(ctx->engine->newStringObject(value));
+        value = Value::fromString(m->engine()->current, QString());
+    return Value::fromObject(m->engine()->newStringObject(value));
 }
 
 Value StringCtor::call(Managed *, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc)
@@ -342,7 +342,7 @@ Value StringPrototype::method_match(SimpleCallContext *context)
     Value regexp = context->argumentCount ? context->arguments[0] : Value::undefinedValue();
     RegExpObject *rx = regexp.as<RegExpObject>();
     if (!rx)
-        rx = context->engine->regExpCtor.asFunctionObject()->construct(context, &regexp, 1).as<RegExpObject>();
+        rx = context->engine->regExpCtor.asFunctionObject()->construct(&regexp, 1).as<RegExpObject>();
 
     if (!rx)
         // ### CHECK
@@ -530,7 +530,7 @@ Value StringPrototype::method_search(SimpleCallContext *ctx)
     Value regExpValue = ctx->argument(0);
     RegExpObject *regExp = regExpValue.as<RegExpObject>();
     if (!regExp) {
-        regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(ctx, &regExpValue, 1);
+        regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(&regExpValue, 1);
         regExp = regExpValue.as<RegExpObject>();
     }
     uint* matchOffsets = (uint*)alloca(regExp->value->captureCount() * 2 * sizeof(uint));
index 442cfa0..1a7a466 100644 (file)
@@ -69,7 +69,7 @@ struct StringCtor: FunctionObject
 {
     StringCtor(ExecutionContext *scope);
 
-    static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc);
+    static Value construct(Managed *m, Value *args, int argc);
     static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
 
 protected:
index c9c4bba..2441a9a 100644 (file)
@@ -553,8 +553,8 @@ inline ErrorObject *Value::asErrorObject() const
 }
 
 // ###
-inline Value Managed::construct(ExecutionContext *context, Value *args, int argc) {
-    return vtbl->construct(this, context, args, argc);
+inline Value Managed::construct(Value *args, int argc) {
+    return vtbl->construct(this, args, argc);
 }
 inline Value Managed::call(ExecutionContext *context, const Value &thisObject, Value *args, int argc) {
     return vtbl->call(this, context, thisObject, args, argc);
index 036cdc8..a21a1cc 100644 (file)
@@ -619,7 +619,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
     Value result;
     QV4::ExecutionContext *ctx = engine->current;
     try {
-        result = f->construct(ctx, arguments.data(), arguments.size());
+        result = f->construct(arguments.data(), arguments.size());
     } catch (Exception &e) {
         e.accept(ctx);
         result = e.value();
index 8926615..bbac92a 100644 (file)
@@ -75,9 +75,9 @@ struct DelegateModelGroupFunction: QV4::FunctionObject
         isBuiltinFunction = true;
     }
 
-    static QV4::Value construct(QV4::Managed *, QV4::ExecutionContext *ctx, QV4::Value *, int)
+    static QV4::Value construct(QV4::Managed *m, QV4::Value *, int)
     {
-        ctx->throwTypeError();
+        m->engine()->current->throwTypeError();
         return QV4::Value::undefinedValue();
     }