diff options
author | Lars Knoll <lars.knoll@digia.com> | 2012-12-14 13:53:22 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-12-14 13:54:37 +0100 |
commit | b41cf690e0ed48132a0c2c02f58fe0b2697bf77b (patch) | |
tree | ebe516c9ac67201e5c7f80908f956ce82f989fc8 /qmljs_objects.cpp | |
parent | e2b907a90e6aa87f70c83d5e24290f87980442ea (diff) |
Small cleanups for ArgumentsObject
Change-Id: Ib9a2f3ab23dd76f52bb4c41edf539f4fa0cd8929
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'qmljs_objects.cpp')
-rw-r--r-- | qmljs_objects.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/qmljs_objects.cpp b/qmljs_objects.cpp index 892286d9a5..3cbd0411f2 100644 --- a/qmljs_objects.cpp +++ b/qmljs_objects.cpp @@ -815,7 +815,7 @@ ArgumentsObject::ArgumentsObject(ExecutionContext *context) PropertyDescriptor pd = PropertyDescriptor::fromAccessor(get, set); pd.configurable = PropertyDescriptor::Enabled; pd.enumberable = PropertyDescriptor::Enabled; - for (int i = 0; i < context->argumentCount; ++i) + for (uint i = 0; i < context->argumentCount; ++i) __defineOwnProperty__(context, QString::number(i), &pd); defineDefaultProperty(context, QStringLiteral("callee"), Value::fromObject(context->function)); } @@ -823,10 +823,12 @@ ArgumentsObject::ArgumentsObject(ExecutionContext *context) Value ArgumentsObject::__get__(ExecutionContext *ctx, String *name, bool *hasProperty) { - bool ok = false; - currentIndex = name->toQString().toInt(&ok); - if (!ok) - currentIndex = -1; + if (!ctx->strictMode) { + bool ok = false; + currentIndex = name->toQString().toInt(&ok); + if (!ok) + currentIndex = -1; + } Value result = Object::__get__(ctx, name, hasProperty); currentIndex = -1; return result; @@ -834,10 +836,12 @@ Value ArgumentsObject::__get__(ExecutionContext *ctx, String *name, bool *hasPro void ArgumentsObject::__put__(ExecutionContext *ctx, String *name, Value value) { - bool ok = false; - currentIndex = name->toQString().toInt(&ok); - if (!ok) - currentIndex = -1; + if (!ctx->strictMode) { + bool ok = false; + currentIndex = name->toQString().toInt(&ok); + if (!ok) + currentIndex = -1; + } Object::__put__(ctx, name, value); currentIndex = -1; } @@ -852,7 +856,7 @@ Value ArgumentsObject::method_getArg(ExecutionContext *ctx) __qmljs_throw_type_error(ctx); assert(ctx != args->context); - assert(args->currentIndex >= 0 && args->currentIndex < args->context->argumentCount); + assert(args->currentIndex >= 0 && args->currentIndex < (int)args->context->argumentCount); return args->context->argument(args->currentIndex); } @@ -866,8 +870,9 @@ Value ArgumentsObject::method_setArg(ExecutionContext *ctx) __qmljs_throw_type_error(ctx); assert(ctx != args->context); - assert(args->currentIndex >= 0 && args->currentIndex < args->context->argumentCount); + assert(args->currentIndex >= 0 && args->currentIndex < (int)args->context->argumentCount); args->context->arguments[args->currentIndex] = ctx->arguments[0]; + return Value::undefinedValue(); } NativeFunction::NativeFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *)) |