aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2012-06-26 15:17:31 +0200
committerRoberto Raggi <roberto.raggi@nokia.com>2012-06-26 15:17:31 +0200
commit48a0b3c96b67ab2afd8c7f23c0afd946dabdca73 (patch)
treeb368d4880bcc25d31bb9bebf6e7e1f5680140a6d /main.cpp
parent6053a2d22f7b605a98050ba1b9c1a18d1ecb0b92 (diff)
Do not try to optimize the `global object'.
This should simplify the implementation of `eval' and `with'.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/main.cpp b/main.cpp
index 924a7a95dc..c9afd49914 100644
--- a/main.cpp
+++ b/main.cpp
@@ -224,15 +224,7 @@ void evaluate(QQmlJS::VM::ExecutionEngine *vm, const QString &fileName, const QS
}
VM::Context *ctx = vm->rootContext;
-
- ctx->varCount = globalCode->locals.size();
- if (ctx->varCount) {
- ctx->locals = new VM::Value[ctx->varCount];
- ctx->vars = new VM::String*[ctx->varCount];
- std::fill(ctx->locals, ctx->locals + ctx->varCount, VM::Value::undefinedValue());
- for (unsigned int i = 0; i < ctx->varCount; ++i)
- ctx->vars[i] = ctx->engine->identifier(*globalCode->locals.at(i));
- }
+ ctx->hasUncaughtException = false;
if (useMoth) {
Moth::VME vme;
@@ -250,9 +242,6 @@ void evaluate(QQmlJS::VM::ExecutionEngine *vm, const QString &fileName, const QS
if (! qgetenv("SHOW_EXIT_VALUE").isNull())
std::cout << "exit value: " << qPrintable(ctx->result.toString(ctx)->toQString()) << std::endl;
}
-
- delete[] ctx->locals;
- delete[] ctx->vars;
}
int main(int argc, char *argv[])
@@ -276,17 +265,18 @@ int main(int argc, char *argv[])
}
#endif
+ QQmlJS::VM::ExecutionEngine vm;
+ QQmlJS::VM::Context *ctx = vm.rootContext;
+
+ QQmlJS::VM::Object *globalObject = vm.globalObject.objectValue;
+ globalObject->setProperty(ctx, vm.identifier(QStringLiteral("print")),
+ QQmlJS::VM::Value::fromObject(new builtins::Print(ctx)));
+
foreach (const QString &fn, args) {
QFile file(fn);
if (file.open(QFile::ReadOnly)) {
const QString code = QString::fromUtf8(file.readAll());
file.close();
- QQmlJS::VM::ExecutionEngine vm;
- QQmlJS::VM::Context *ctx = vm.rootContext;
-
- QQmlJS::VM::Object *globalObject = vm.globalObject.objectValue;
- globalObject->setProperty(ctx, vm.identifier(QStringLiteral("print")),
- QQmlJS::VM::Value::fromObject(new builtins::Print(ctx)));
evaluate(&vm, fn, code);
}