Keep the EvalISelFactory in the ExecutionEngine.
authorErik Verbruggen <erik.verbruggen@digia.com>
Tue, 20 Nov 2012 12:41:49 +0000 (13:41 +0100)
committerLars Knoll <lars.knoll@digia.com>
Wed, 21 Nov 2012 14:47:14 +0000 (15:47 +0100)
Also corrected the class name cApiTaliSatiOn.

Change-Id: I131566e904c8ee575686a469f16d098dd512d865
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
main.cpp
moth/qv4isel_moth_p.h
qmljs_engine.cpp
qmljs_engine.h
qmljs_objects.cpp
qmljs_objects.h
qv4ecmaobjects.cpp
qv4ecmaobjects_p.h
qv4isel_masm_p.h
qv4isel_p.cpp
qv4isel_p.h

index 4753279..f703cbc 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -123,7 +123,7 @@ int executeLLVMCode(void *codePtr)
         return EXIT_FAILURE;
     void (*code)(VM::ExecutionContext *) = (void (*)(VM::ExecutionContext *)) codePtr;
 
-    QScopedPointer<QQmlJS::EValISelFactory> iSelFactory(new QQmlJS::Moth::ISelFactory);
+    QScopedPointer<QQmlJS::EvalISelFactory> iSelFactory(new QQmlJS::Moth::ISelFactory);
     VM::ExecutionEngine vm(iSelFactory.data());
     VM::ExecutionContext *ctx = vm.rootContext;
 
@@ -289,7 +289,7 @@ int main(int argc, char *argv[])
 #endif // QMLJS_NO_LLVM
     case use_masm:
     case use_moth: {
-        QScopedPointer<QQmlJS::EValISelFactory> iSelFactory;
+        QScopedPointer<QQmlJS::EvalISelFactory> iSelFactory;
         if (mode == use_moth)
             iSelFactory.reset(new QQmlJS::Moth::ISelFactory);
         else
@@ -318,7 +318,7 @@ int main(int argc, char *argv[])
                     return EXIT_FAILURE;
                 }
 
-                QQmlJS::VM::Value result = QQmlJS::VM::EvalFunction::evaluate(vm.rootContext, fn, code, iSelFactory.data(), QQmlJS::Codegen::GlobalCode);
+                QQmlJS::VM::Value result = QQmlJS::VM::EvalFunction::evaluate(vm.rootContext, fn, code, QQmlJS::Codegen::GlobalCode);
                 if (!result.isUndefined()) {
                     if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
                         std::cout << "exit value: " << qPrintable(result.toString(ctx)->toQString()) << std::endl;
index b181f79..043958b 100644 (file)
@@ -60,7 +60,7 @@ private:
     uchar *_ccode;
 };
 
-class ISelFactory: public EValISelFactory
+class ISelFactory: public EvalISelFactory
 {
 public:
     virtual ~ISelFactory() {}
index 6bb8937..acf2213 100644 (file)
@@ -45,7 +45,8 @@
 namespace QQmlJS {
 namespace VM {
 
-ExecutionEngine::ExecutionEngine(EValISelFactory *factory)
+ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
+    : iselFactory(factory)
 {
     rootContext = newContext();
     rootContext->init(this);
@@ -92,7 +93,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, factory));
+    functionCtor = Value::fromObject(new FunctionCtor(rootContext));
     dateCtor = Value::fromObject(new DateCtor(rootContext));
     regExpCtor = Value::fromObject(new RegExpCtor(rootContext));
     errorCtor = Value::fromObject(new ErrorCtor(rootContext));
@@ -160,7 +161,7 @@ ExecutionEngine::ExecutionEngine(EValISelFactory *factory)
     glo->__put__(rootContext, identifier(QStringLiteral("undefined")), Value::undefinedValue());
     glo->__put__(rootContext, identifier(QStringLiteral("NaN")), Value::fromDouble(nan("")));
     glo->__put__(rootContext, identifier(QStringLiteral("Infinity")), Value::fromDouble(INFINITY));
-    glo->__put__(rootContext, identifier(QStringLiteral("eval")), Value::fromObject(new EvalFunction(rootContext, factory)));
+    glo->__put__(rootContext, identifier(QStringLiteral("eval")), Value::fromObject(new EvalFunction(rootContext)));
 
     // TODO: parseInt [15.1.2.2]
     // TODO: parseFloat [15.1.2.3]
index 862ad57..5460412 100644 (file)
@@ -83,6 +83,7 @@ struct URIErrorPrototype;
 
 struct ExecutionEngine
 {
+    EvalISelFactory *iselFactory;
     ExecutionContext *current;
     ExecutionContext *rootContext;
 
@@ -138,7 +139,7 @@ struct ExecutionEngine
     QVector<ExceptionHandler> unwindStack;
     Value exception;
 
-    ExecutionEngine(EValISelFactory *factory);
+    ExecutionEngine(EvalISelFactory *iselFactory);
 
     ExecutionContext *newContext();
 
index cbe5cba..d190403 100644 (file)
@@ -481,7 +481,7 @@ Value EvalFunction::call(ExecutionContext *context, Value /*thisObject*/, Value
         ctx = context;
     }
     // ##### inline and do this in the correct scope
-    Value result = evaluate(ctx, QStringLiteral("eval code"), code, _factory, QQmlJS::Codegen::EvalCode);
+    Value result = evaluate(ctx, QStringLiteral("eval code"), code, QQmlJS::Codegen::EvalCode);
 
     if (strictMode)
         ctx->leaveCallContext();
@@ -506,8 +506,7 @@ Value IsFiniteFunction::call(ExecutionContext * /*context*/, Value /*thisObject*
 }
 
 Value EvalFunction::evaluate(QQmlJS::VM::ExecutionContext *ctx, const QString &fileName,
-                           const QString &source, EValISelFactory *factory,
-                           QQmlJS::Codegen::Mode mode)
+                             const QString &source, QQmlJS::Codegen::Mode mode)
 {
     using namespace QQmlJS;
 
@@ -536,7 +535,7 @@ Value EvalFunction::evaluate(QQmlJS::VM::ExecutionContext *ctx, const QString &f
             globalCode = cg(program, &module, mode);
 
             foreach (IR::Function *function, module.functions) {
-                EvalInstructionSelection *isel = factory->create(vm);
+                EvalInstructionSelection *isel = ctx->engine->iselFactory->create(vm);
                 isel->run(function);
                 delete isel;
             }
index 6048e99..31d493a 100644 (file)
@@ -524,16 +524,13 @@ struct ScriptFunction: FunctionObject {
 
 struct EvalFunction : FunctionObject
 {
-    EvalFunction(ExecutionContext *scope, EValISelFactory *factory): FunctionObject(scope), _factory(factory) {}
+    EvalFunction(ExecutionContext *scope): FunctionObject(scope) {}
 
-    static Value evaluate(QQmlJS::VM::ExecutionContext *ctx, const QString &fileName,
-                        const QString &source, EValISelFactory *factory,
-                        QQmlJS::Codegen::Mode mode);
+    static Value evaluate(QQmlJS::VM::ExecutionContext *ctx,
+                          const QString &fileName, const QString &source,
+                          QQmlJS::Codegen::Mode mode);
 
     virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc, bool strictMode = false);
-
-private:
-    EValISelFactory *_factory;
 };
 
 struct IsNaNFunction: FunctionObject
index 514b04d..01c0d82 100644 (file)
@@ -1732,9 +1732,8 @@ Value ArrayPrototype::method_reduceRight(ExecutionContext *ctx)
 //
 // Function object
 //
-FunctionCtor::FunctionCtor(ExecutionContext *scope, EValISelFactory *factory)
+FunctionCtor::FunctionCtor(ExecutionContext *scope)
     : FunctionObject(scope)
-    , _factory(factory)
 {
 }
 
@@ -1776,7 +1775,7 @@ Value FunctionCtor::construct(ExecutionContext *ctx)
     Codegen cg;
     IR::Function *irf = cg(fe, &module);
 
-    EvalInstructionSelection *isel = _factory->create(ctx->engine);
+    EvalInstructionSelection *isel = ctx->engine->iselFactory->create(ctx->engine);
     isel->run(irf);
     delete isel;
 
index 354d9fc..d94c979 100644 (file)
@@ -194,13 +194,10 @@ struct ArrayPrototype: ArrayObject
 
 struct FunctionCtor: FunctionObject
 {
-    FunctionCtor(ExecutionContext *scope, EValISelFactory *factory);
+    FunctionCtor(ExecutionContext *scope);
 
     virtual Value construct(ExecutionContext *ctx);
     virtual Value call(ExecutionContext *ctx);
-
-private:
-    EValISelFactory *_factory;
 };
 
 struct FunctionPrototype: FunctionObject
index 6e0316e..53201c0 100644 (file)
@@ -631,7 +631,7 @@ private:
     QList<CallToLink> _callsToLink;
 };
 
-class ISelFactory: public EValISelFactory
+class ISelFactory: public EvalISelFactory
 {
 public:
     virtual ~ISelFactory() {}
index 294a22f..175cea5 100644 (file)
@@ -5,5 +5,5 @@ using namespace QQmlJS;
 EvalInstructionSelection::~EvalInstructionSelection()
 {}
 
-EValISelFactory::~EValISelFactory()
+EvalISelFactory::~EvalISelFactory()
 {}
index d50ebae..e8c6d38 100644 (file)
@@ -51,10 +51,10 @@ public:
     virtual void run(IR::Function *function) = 0;
 };
 
-class EValISelFactory
+class EvalISelFactory
 {
 public:
-    virtual ~EValISelFactory() = 0;
+    virtual ~EvalISelFactory() = 0;
     virtual EvalInstructionSelection *create(VM::ExecutionEngine *engine) = 0;
 };