aboutsummaryrefslogtreecommitdiffstats
path: root/tools/v4/main.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-21 10:28:33 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-22 10:00:04 +0200
commitc7e7a650cd0a3cdcfd48b83c8d80c9d210a2662f (patch)
treeeabf5c6aab34021f61168ecc3e8ee98b2f49616d /tools/v4/main.cpp
parentca8b72040349f60df45c6070ed617d4462c25779 (diff)
Rename v4 to qmljs
We don't want to officially support this binary in our release builds, so give it a "safer" name and enable it only in developer builds. Change-Id: Iaa007bc2ccdb133635161aae01d140efe0f44e23 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tools/v4/main.cpp')
-rw-r--r--tools/v4/main.cpp230
1 files changed, 0 insertions, 230 deletions
diff --git a/tools/v4/main.cpp b/tools/v4/main.cpp
deleted file mode 100644
index e6ab56b513..0000000000
--- a/tools/v4/main.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the V4VM module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "private/qv4object_p.h"
-#include "private/qv4runtime_p.h"
-#include "private/qv4functionobject_p.h"
-#include "private/qv4errorobject_p.h"
-#include "private/qv4globalobject_p.h"
-#include "private/qv4codegen_p.h"
-#include "private/qv4isel_moth_p.h"
-#include "private/qv4vme_moth_p.h"
-#include "private/qv4objectproto_p.h"
-#include "private/qv4isel_p.h"
-#include "private/qv4mm_p.h"
-#include "private/qv4context_p.h"
-#include "private/qv4script_p.h"
-
-#ifdef V4_ENABLE_JIT
-# include "private/qv4isel_masm_p.h"
-#endif // V4_ENABLE_JIT
-
-#include <QtCore>
-#include <private/qqmljsengine_p.h>
-#include <private/qqmljslexer_p.h>
-#include <private/qqmljsparser_p.h>
-#include <private/qqmljsast_p.h>
-
-#include <iostream>
-
-namespace builtins {
-
-using namespace QV4;
-
-struct Print: FunctionObject
-{
- Print(ExecutionContext *scope): FunctionObject(scope, QStringLiteral("print")) {
- vtbl = &static_vtbl;
- }
-
- static ReturnedValue call(Managed *, CallData *callData)
- {
- for (int i = 0; i < callData->argc; ++i) {
- QString s = callData->args[i].toQStringNoThrow();
- if (i)
- std::cout << ' ';
- std::cout << qPrintable(s);
- }
- std::cout << std::endl;
- return Encode::undefined();
- }
-
- static const ManagedVTable static_vtbl;
-};
-
-DEFINE_MANAGED_VTABLE(Print);
-
-struct GC: public FunctionObject
-{
- GC(ExecutionContext* scope)
- : FunctionObject(scope, QStringLiteral("gc"))
- {
- vtbl = &static_vtbl;
- }
- static ReturnedValue call(Managed *m, CallData *)
- {
- m->engine()->memoryManager->runGC();
- return Encode::undefined();
- }
-
- static const ManagedVTable static_vtbl;
-};
-
-DEFINE_MANAGED_VTABLE(GC);
-
-} // builtins
-
-static void showException(QV4::ExecutionContext *ctx, const QV4::ValueRef exception, const QV4::StackTrace &trace)
-{
- QV4::Scope scope(ctx);
- QV4::ScopedValue ex(scope, *exception);
- QV4::ErrorObject *e = ex->asErrorObject();
- if (!e) {
- std::cerr << "Uncaught exception: " << qPrintable(ex->toString(ctx)->toQString()) << std::endl;
- } else {
- QV4::ScopedString m(scope, ctx->engine->newString(QStringLiteral("message")));
- QV4::ScopedValue message(scope, e->get(m));
- std::cerr << "Uncaught exception: " << qPrintable(message->toQStringNoThrow()) << std::endl;
- }
-
- foreach (const QV4::StackFrame &frame, trace) {
- std::cerr << " at " << qPrintable(frame.function) << " (" << qPrintable(frame.source);
- if (frame.line >= 0)
- std::cerr << ":" << frame.line;
- std::cerr << ")" << std::endl;
- }
-}
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
- QStringList args = app.arguments();
- args.removeFirst();
-
- enum {
- use_masm,
- use_moth
- } mode;
-#ifdef V4_ENABLE_JIT
- mode = use_masm;
-#else
- mode = use_moth;
-#endif
-
- bool runAsQml = false;
-
- if (!args.isEmpty()) {
- if (args.first() == QLatin1String("--jit")) {
- mode = use_masm;
- args.removeFirst();
- }
-
- if (args.first() == QLatin1String("--interpret")) {
- mode = use_moth;
- args.removeFirst();
- }
-
- if (args.first() == QLatin1String("--qml")) {
- runAsQml = true;
- args.removeFirst();
- }
-
- if (args.first() == QLatin1String("--help")) {
- std::cerr << "Usage: v4 [|--debug|-d] [|--jit|--interpret|--compile|--aot|--llvm-jit] file..." << std::endl;
- return EXIT_SUCCESS;
- }
- }
-
- switch (mode) {
- case use_masm:
- case use_moth: {
- QQmlJS::EvalISelFactory* iSelFactory = 0;
- if (mode == use_moth) {
- iSelFactory = new QQmlJS::Moth::ISelFactory;
-#ifdef V4_ENABLE_JIT
- } else {
- iSelFactory = new QQmlJS::MASM::ISelFactory;
-#endif // V4_ENABLE_JIT
- }
-
- QV4::ExecutionEngine vm(iSelFactory);
-
- QV4::ExecutionContext *ctx = vm.rootContext;
- QV4::Scope scope(ctx);
-
- QV4::ScopedObject globalObject(scope, vm.globalObject);
- QV4::ScopedObject print(scope, new (ctx->engine->memoryManager) builtins::Print(ctx));
- globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))), print);
- QV4::ScopedObject gc(scope, new (ctx->engine->memoryManager) builtins::GC(ctx));
- globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))), gc);
-
- foreach (const QString &fn, args) {
- QFile file(fn);
- if (file.open(QFile::ReadOnly)) {
- const QString code = QString::fromUtf8(file.readAll());
- file.close();
-
- try {
- QV4::Script script(ctx, code, fn);
- script.parseAsBinding = runAsQml;
- script.parse();
- QV4::ScopedValue result(scope, script.run());
- if (!result->isUndefined()) {
- if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
- std::cout << "exit value: " << qPrintable(result->toString(ctx)->toQString()) << std::endl;
- }
- } catch (...) {
- QV4::StackTrace trace;
- QV4::ScopedValue ex(scope, ctx->catchException(&trace));
- showException(ctx, ex, trace);
- return EXIT_FAILURE;
- }
-
- } else {
- std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl;
- return EXIT_FAILURE;
- }
- }
-
- vm.memoryManager->dumpStats();
- } return EXIT_SUCCESS;
- } // switch (mode)
-}