Use an isel factory instead of MASM in FunctionCTor.
authorErik Verbruggen <erik.verbruggen@digia.com>
Tue, 20 Nov 2012 12:24:24 +0000 (13:24 +0100)
committerLars Knoll <lars.knoll@digia.com>
Tue, 20 Nov 2012 12:31:05 +0000 (13:31 +0100)
Change-Id: I070f056411f16d837ff5eac191fac11cd0bd3c47
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qmljs_engine.cpp
qmljs_engine.h
qv4ecmaobjects.cpp
qv4ecmaobjects_p.h

index 31ed260..6bb8937 100644 (file)
@@ -92,7 +92,7 @@ ExecutionEngine::ExecutionEngine(EValISelFactory *factory)
     numberCtor = Value::fromObject(new NumberCtor(rootContext));
     booleanCtor = Value::fromObject(new BooleanCtor(rootContext));
     arrayCtor = Value::fromObject(new ArrayCtor(rootContext));
-    functionCtor = Value::fromObject(new FunctionCtor(rootContext));
+    functionCtor = Value::fromObject(new FunctionCtor(rootContext, factory));
     dateCtor = Value::fromObject(new DateCtor(rootContext));
     regExpCtor = Value::fromObject(new RegExpCtor(rootContext));
     errorCtor = Value::fromObject(new ErrorCtor(rootContext));
@@ -258,11 +258,6 @@ Object *ExecutionEngine::newFunctionObject(ExecutionContext *ctx)
     return object;
 }
 
-FunctionObject *ExecutionEngine::newFunctionCtor(ExecutionContext *ctx)
-{
-    return new FunctionCtor(ctx);
-}
-
 Object *ExecutionEngine::newArrayObject()
 {
     ArrayObject *object = new ArrayObject();
index 2404ebd..862ad57 100644 (file)
@@ -161,7 +161,6 @@ struct ExecutionEngine
     FunctionObject *newBooleanCtor(ExecutionContext *ctx);
 
     Object *newFunctionObject(ExecutionContext *ctx);
-    FunctionObject *newFunctionCtor(ExecutionContext *ctx);
 
     Object *newArrayObject();
     Object *newArrayObject(const Array &value);
index 2cabb0e..514b04d 100644 (file)
@@ -1732,8 +1732,9 @@ Value ArrayPrototype::method_reduceRight(ExecutionContext *ctx)
 //
 // Function object
 //
-FunctionCtor::FunctionCtor(ExecutionContext *scope)
+FunctionCtor::FunctionCtor(ExecutionContext *scope, EValISelFactory *factory)
     : FunctionObject(scope)
+    , _factory(factory)
 {
 }
 
@@ -1775,9 +1776,9 @@ Value FunctionCtor::construct(ExecutionContext *ctx)
     Codegen cg;
     IR::Function *irf = cg(fe, &module);
 
-    // FIXME: this mixes MASM and MOTH
-    MASM::InstructionSelection isel(ctx->engine);
-    isel(irf);
+    EvalInstructionSelection *isel = _factory->create(ctx->engine);
+    isel->run(irf);
+    delete isel;
 
     ctx->thisObject = Value::fromObject(new ScriptFunction(ctx->engine->rootContext, irf));
     return ctx->thisObject;
index d94c979..354d9fc 100644 (file)
@@ -194,10 +194,13 @@ struct ArrayPrototype: ArrayObject
 
 struct FunctionCtor: FunctionObject
 {
-    FunctionCtor(ExecutionContext *scope);
+    FunctionCtor(ExecutionContext *scope, EValISelFactory *factory);
 
     virtual Value construct(ExecutionContext *ctx);
     virtual Value call(ExecutionContext *ctx);
+
+private:
+    EValISelFactory *_factory;
 };
 
 struct FunctionPrototype: FunctionObject