Make LLVM backend compile again.
authorErik Verbruggen <erik.verbruggen@digia.com>
Tue, 20 Nov 2012 08:47:18 +0000 (09:47 +0100)
committerLars Knoll <lars.knoll@digia.com>
Tue, 20 Nov 2012 11:04:10 +0000 (12:04 +0100)
Moved common code into a separate function.

Change-Id: Iaa96c27214659a23b3df70b80560fb8f42792b38
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
main.cpp

index c9e3170..4753279 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -106,6 +106,14 @@ struct TestHarnessError: FunctionObject
 
 } // builtins
 
+static void showException(QQmlJS::VM::ExecutionContext *ctx)
+{
+    if (QQmlJS::VM::ErrorObject *e = ctx->engine->exception.asErrorObject())
+        std::cerr << "Uncaught exception: " << qPrintable(e->value.toString(ctx)->toQString()) << std::endl;
+    else
+        std::cerr << "Uncaught exception: " << qPrintable(ctx->engine->exception.toString(ctx)->toQString()) << std::endl;
+}
+
 #ifndef QMLJS_NO_LLVM
 int executeLLVMCode(void *codePtr)
 {
@@ -125,10 +133,7 @@ int executeLLVMCode(void *codePtr)
 
     void * buf = __qmljs_create_exception_handler(ctx);
     if (setjmp(*(jmp_buf *)buf)) {
-        if (VM::ErrorObject *e = ctx->result.asErrorObject())
-            std::cerr << "Uncaught exception: " << qPrintable(e->value.toString(ctx)->toQString()) << std::endl;
-        else
-            std::cerr << "Uncaught exception: " << qPrintable(ctx->result.toString(ctx)->toQString()) << std::endl;
+        showException(ctx);
         return EXIT_FAILURE;
     }
 
@@ -309,10 +314,7 @@ int main(int argc, char *argv[])
 
                 void * buf = __qmljs_create_exception_handler(ctx);
                 if (setjmp(*(jmp_buf *)buf)) {
-                    if (QQmlJS::VM::ErrorObject *e = ctx->engine->exception.asErrorObject())
-                        std::cerr << "Uncaught exception: " << qPrintable(e->value.toString(ctx)->toQString()) << std::endl;
-                    else
-                        std::cerr << "Uncaught exception: " << qPrintable(ctx->engine->exception.toString(ctx)->toQString()) << std::endl;
+                    showException(ctx);
                     return EXIT_FAILURE;
                 }