aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_runtime.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2012-11-17 21:54:26 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-11-19 10:29:07 +0100
commit65724ce3e7ae798c6efad3a039072356063f3e4c (patch)
tree22351544391f2ebc38b3ce32c53d1236a82a8375 /qmljs_runtime.cpp
parentd7416a80faa4e8b32824975b712f6756eda7b18f (diff)
Move the engine and context classes into their own files
Change-Id: Ie20138990908a921ca3d7475618275ed82d9cb5c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'qmljs_runtime.cpp')
-rw-r--r--qmljs_runtime.cpp132
1 files changed, 0 insertions, 132 deletions
diff --git a/qmljs_runtime.cpp b/qmljs_runtime.cpp
index ec97864192..d660aaf87b 100644
--- a/qmljs_runtime.cpp
+++ b/qmljs_runtime.cpp
@@ -230,138 +230,6 @@ Value Value::property(ExecutionContext *ctx, String *name) const
return isObject() ? objectValue()->__get__(ctx, name) : undefinedValue();
}
-void ExecutionContext::init(ExecutionEngine *eng)
-{
- engine = eng;
- parent = 0;
- arguments = 0;
- argumentCount = 0;
- locals = 0;
- activation = 0;
- thisObject = Value::nullValue();
- result = Value::undefinedValue();
- formals = 0;
- formalCount = 0;
- vars = 0;
- varCount = 0;
-}
-
-PropertyDescriptor *ExecutionContext::lookupPropertyDescriptor(String *name, PropertyDescriptor *tmp)
-{
- for (ExecutionContext *ctx = this; ctx; ctx = ctx->parent) {
- if (ctx->activation) {
- if (PropertyDescriptor *pd = ctx->activation->__getPropertyDescriptor__(this, name, tmp))
- return pd;
- }
- }
- return 0;
-}
-
-void ExecutionContext::inplaceBitOp(Value value, String *name, BinOp op)
-{
- for (ExecutionContext *ctx = this; ctx; ctx = ctx->parent) {
- if (ctx->activation) {
- if (ctx->activation->inplaceBinOp(value, name, op, this))
- return;
- }
- }
- throwReferenceError(Value::fromString(name));
-}
-
-void ExecutionContext::throwError(Value value)
-{
- result = value;
- __qmljs_builtin_throw(value, this);
-}
-
-void ExecutionContext::throwError(const QString &message)
-{
- Value v = Value::fromString(this, message);
- throwError(Value::fromObject(engine->newErrorObject(v)));
-}
-
-void ExecutionContext::throwTypeError()
-{
- Value v = Value::fromString(this, QStringLiteral("Type error"));
- throwError(Value::fromObject(engine->newErrorObject(v)));
-}
-
-void ExecutionContext::throwUnimplemented(const QString &message)
-{
- Value v = Value::fromString(this, QStringLiteral("Unimplemented ") + message);
- throwError(Value::fromObject(engine->newErrorObject(v)));
-}
-
-void ExecutionContext::throwReferenceError(Value value)
-{
- String *s = value.toString(this);
- QString msg = s->toQString() + QStringLiteral(" is not defined");
- throwError(Value::fromObject(engine->newErrorObject(Value::fromString(this, msg))));
-}
-
-void ExecutionContext::initCallContext(ExecutionContext *parent, const Value that, FunctionObject *f, Value *args, unsigned argc)
-{
- engine = parent->engine;
- this->parent = f->scope;
- assert(this->parent == f->scope);
- result = Value::undefinedValue();
-
- if (f->needsActivation)
- activation = engine->newActivationObject(this);
- else
- activation = 0;
-
- thisObject = that;
-
- formals = f->formalParameterList;
- formalCount = f->formalParameterCount;
- arguments = args;
- argumentCount = argc;
- if (f->needsActivation || argc < formalCount){
- arguments = new Value[qMax(argc, formalCount)];
- if (argc)
- std::copy(args, args + argc, arguments);
- if (argc < formalCount)
- std::fill(arguments + argc, arguments + formalCount, Value::undefinedValue());
- }
- vars = f->varList;
- varCount = f->varCount;
- locals = varCount ? new Value[varCount] : 0;
- if (varCount)
- std::fill(locals, locals + varCount, Value::undefinedValue());
-}
-
-void ExecutionContext::leaveCallContext()
-{
- if (activation) {
- delete[] locals;
- locals = 0;
- }
-}
-
-void ExecutionContext::initConstructorContext(ExecutionContext *parent, Value that, FunctionObject *f, Value *args, unsigned argc)
-{
- initCallContext(parent, that, f, args, argc);
-}
-
-void ExecutionContext::leaveConstructorContext(FunctionObject *f)
-{
- wireUpPrototype(f);
- leaveCallContext();
-}
-
-void ExecutionContext::wireUpPrototype(FunctionObject *f)
-{
- assert(thisObject.isObject());
- result = thisObject;
-
- Value proto = f->__get__(this, engine->id_prototype);
- thisObject.objectValue()->prototype = proto.objectValue();
- if (! thisObject.isObject())
- thisObject.objectValue()->prototype = engine->objectPrototype;
-
-}
-
extern "C" {
Value __qmljs_init_closure(IR::Function *clos, ExecutionContext *ctx)