Make Context a POD value.

This commit is contained in:
Roberto Raggi 2012-05-08 10:34:57 +02:00
parent acc9293bd1
commit 02abaa637c
3 changed files with 10 additions and 9 deletions

View File

@ -126,11 +126,11 @@ void ScriptFunction::call(VM::Context *ctx)
function->code(ctx); function->code(ctx);
} }
Property *ArgumentsObject::getOwnProperty(String *name) Property *ArgumentsObject::getProperty(String *name)
{ {
if (Property *prop = Object::getOwnProperty(name)) if (Property *prop = Object::getProperty(name))
return prop; return prop;
else if (context && context->scope) else if (context && context->scope)
return context->scope->getOwnProperty(name); return context->scope->getProperty(name);
return 0; return 0;
} }

View File

@ -258,7 +258,7 @@ struct ErrorObject: Object {
struct ArgumentsObject: Object { struct ArgumentsObject: Object {
Context *context; Context *context;
ArgumentsObject(Context *context): context(context) {} ArgumentsObject(Context *context): context(context) {}
virtual Property *getOwnProperty(String *name); virtual Property *getProperty(String *name);
}; };
struct Context { struct Context {
@ -270,12 +270,12 @@ struct Context {
size_t argumentCount; size_t argumentCount;
Value result; Value result;
Context() void init()
: parent(0)
, scope(0)
, arguments(0)
, argumentCount(0)
{ {
parent = 0;
scope = 0;
arguments = 0;
argumentCount = 0;
activation.type = NULL_TYPE; activation.type = NULL_TYPE;
thisObject.type = NULL_TYPE; thisObject.type = NULL_TYPE;
result.type = UNDEFINED_TYPE; result.type = UNDEFINED_TYPE;

View File

@ -330,6 +330,7 @@ bool __qmljs_equal(Context *ctx, const Value *x, const Value *y)
Context *__qmljs_new_context(Context *current, Value *thisObject, size_t argc) Context *__qmljs_new_context(Context *current, Value *thisObject, size_t argc)
{ {
Context *ctx = new Context; Context *ctx = new Context;
ctx->init();
ctx->parent = current; ctx->parent = current;
ctx->scope = current->activation.objectValue; ctx->scope = current->activation.objectValue;
__qmljs_init_object(ctx, &ctx->activation, new ArgumentsObject(ctx)); __qmljs_init_object(ctx, &ctx->activation, new ArgumentsObject(ctx));