aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4context_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2014-11-01 23:24:13 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-11-08 16:39:15 +0100
commit84aae25c0b3003fb846568cf26a2c7150db14d9d (patch)
tree53a78f1a54f6605008668a1bbe21f81bec3e13e4 /src/qml/jsruntime/qv4context_p.h
parentec8f1f68d623ae68cc7d79e19067884532e3db6f (diff)
Refactor ExecutionContexts
Move the Data class out into the Heap namespace. Change-Id: I2b798deb53812a08155c92a0e6ef2dcd2ea137b8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4context_p.h')
-rw-r--r--src/qml/jsruntime/qv4context_p.h151
1 files changed, 82 insertions, 69 deletions
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index e45e82fda2..310fa6c576 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -51,12 +51,9 @@ struct CallContext;
struct CatchContext;
struct WithContext;
-struct Q_QML_EXPORT ExecutionContext : public Managed
-{
- enum {
- IsExecutionContext = true
- };
+namespace Heap {
+struct ExecutionContext : Base {
enum ContextType {
Type_GlobalContext = 0x1,
Type_CatchContext = 0x2,
@@ -71,40 +68,84 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
EvalCode *next;
};
- struct Data : Heap::Base {
- Data(ExecutionEngine *engine, ContextType t)
- : Heap::Base(engine->executionContextClass)
- , type(t)
- , strictMode(false)
- , engine(engine)
- , parent(engine->currentContext())
- , outer(0)
- , lookups(0)
- , compilationUnit(0)
- , currentEvalCode(0)
- , lineNumber(-1)
- {
- engine->current = reinterpret_cast<ExecutionContext *>(this);
- }
- ContextType type;
- bool strictMode;
-
- CallData *callData;
-
- ExecutionEngine *engine;
- ExecutionContext *parent;
- ExecutionContext *outer;
- Lookup *lookups;
- CompiledData::CompilationUnit *compilationUnit;
- EvalCode *currentEvalCode;
-
- int lineNumber;
+ ExecutionContext(ExecutionEngine *engine, ContextType t)
+ : Base(engine->executionContextClass)
+ , type(t)
+ , strictMode(false)
+ , engine(engine)
+ , parent(engine->currentContext())
+ , outer(0)
+ , lookups(0)
+ , compilationUnit(0)
+ , currentEvalCode(0)
+ , lineNumber(-1)
+ {
+ // ### GC
+ engine->current = reinterpret_cast<QV4::ExecutionContext *>(this);
+ }
+
+ ContextType type;
+ bool strictMode;
+
+ CallData *callData;
+
+ ExecutionEngine *engine;
+ // ### GC
+ QV4::ExecutionContext *parent;
+ QV4::ExecutionContext *outer;
+ Lookup *lookups;
+ CompiledData::CompilationUnit *compilationUnit;
+ EvalCode *currentEvalCode;
+
+ int lineNumber;
+
+};
+
+struct CallContext : ExecutionContext {
+ CallContext(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext)
+ : ExecutionContext(engine, t)
+ {
+ function = 0;
+ locals = 0;
+ activation = 0;
+ }
+ CallContext(ExecutionEngine *engine, Object *qml, QV4::FunctionObject *function);
+
+ FunctionObject *function;
+ int realArgumentCount;
+ Value *locals;
+ Object *activation;
+};
+struct GlobalContext : ExecutionContext {
+ GlobalContext(ExecutionEngine *engine);
+ Object *global;
+};
+
+struct CatchContext : ExecutionContext {
+ CatchContext(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue);
+ StringValue exceptionVarName;
+ Value exceptionValue;
+};
+
+struct WithContext : ExecutionContext {
+ WithContext(ExecutionEngine *engine, Object *with);
+ Object *withObject;
+};
+
+
+}
+
+struct Q_QML_EXPORT ExecutionContext : public Managed
+{
+ enum {
+ IsExecutionContext = true
};
- V4_MANAGED(Managed)
+
+ V4_MANAGED2(ExecutionContext, Managed)
Q_MANAGED_TYPE(ExecutionContext)
- ExecutionContext(ExecutionEngine *engine, ContextType t)
+ ExecutionContext(ExecutionEngine *engine, Heap::ExecutionContext::ContextType t)
: Managed(engine->executionContextClass)
{
d()->type = t;
@@ -142,22 +183,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
struct CallContext : public ExecutionContext
{
- struct Data : ExecutionContext::Data {
- Data(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext)
- : ExecutionContext::Data(engine, t)
- {
- function = 0;
- locals = 0;
- activation = 0;
- }
- Data(ExecutionEngine *engine, Object *qml, QV4::FunctionObject *function);
-
- FunctionObject *function;
- int realArgumentCount;
- Value *locals;
- Object *activation;
- };
- V4_MANAGED(ExecutionContext)
+ V4_MANAGED2(CallContext, ExecutionContext)
// formals are in reverse order
String * const *formals() const;
@@ -175,41 +201,28 @@ inline ReturnedValue CallContext::argument(int i) {
struct GlobalContext : public ExecutionContext
{
- struct Data : ExecutionContext::Data {
- Data(ExecutionEngine *engine);
- Object *global;
- };
- V4_MANAGED(ExecutionContext)
+ V4_MANAGED2(GlobalContext, ExecutionContext)
};
struct CatchContext : public ExecutionContext
{
- struct Data : ExecutionContext::Data {
- Data(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue);
- StringValue exceptionVarName;
- Value exceptionValue;
- };
- V4_MANAGED(ExecutionContext)
+ V4_MANAGED2(CatchContext, ExecutionContext)
};
struct WithContext : public ExecutionContext
{
- struct Data : ExecutionContext::Data {
- Data(ExecutionEngine *engine, Object *with);
- Object *withObject;
- };
- V4_MANAGED(ExecutionContext)
+ V4_MANAGED2(WithContext, ExecutionContext)
};
inline CallContext *ExecutionContext::asCallContext()
{
- return d()->type >= Type_SimpleCallContext ? static_cast<CallContext *>(this) : 0;
+ return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<CallContext *>(this) : 0;
}
inline const CallContext *ExecutionContext::asCallContext() const
{
- return d()->type >= Type_SimpleCallContext ? static_cast<const CallContext *>(this) : 0;
+ return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<const CallContext *>(this) : 0;
}