From e49724a4435a2a5ae5f33901a26201222465dde9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 12 Apr 2013 14:43:58 +0200 Subject: Remove context arguments where they aren't required A bunch of methods took pointers to the current execution context even though they don't require it. Change-Id: I2a504a72069af16bb8bdbb62be438ee1cab723b0 Reviewed-by: Simon Hausmann --- src/v4/debugging.cpp | 2 +- src/v4/qv4context.cpp | 12 ++++++------ src/v4/qv4object.cpp | 28 ++++++++++++++-------------- src/v4/qv4object.h | 16 ++++++++-------- src/v4/qv4objectiterator.cpp | 2 +- src/v4/qv4objectproto.cpp | 18 +++++++++--------- src/v4/qv4runtime.cpp | 2 +- src/v4/qv4string.cpp | 4 ++-- src/v4/qv4stringobject.cpp | 4 ++-- src/v4/qv4stringobject.h | 2 +- src/v4/qv4v8.cpp | 8 ++++---- 11 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/v4/debugging.cpp b/src/v4/debugging.cpp index 30ab4a1ed9..6137e64f89 100644 --- a/src/v4/debugging.cpp +++ b/src/v4/debugging.cpp @@ -295,7 +295,7 @@ static void realDumpValue(VM::Value v, VM::ExecutionContext *ctx, std::string pr for (Value name = it.nextPropertyName(); !name.isNull(); name = it.nextPropertyName()) { cout << prefix << "\t\"" << qPrintable(name.stringValue()->toQString()) << "\"" << endl; PropertyAttributes attrs; - Property *d = o->__getOwnProperty__(ctx, name.stringValue(), &attrs); + Property *d = o->__getOwnProperty__(name.stringValue(), &attrs); Value pval = o->getValue(ctx, d, attrs); cout << prefix << "\tvalue:" << endl; realDumpValue(pval, ctx, prefix + "\t"); diff --git a/src/v4/qv4context.cpp b/src/v4/qv4context.cpp index 24a8563c14..e1ce0016dd 100644 --- a/src/v4/qv4context.cpp +++ b/src/v4/qv4context.cpp @@ -96,7 +96,7 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) ctx = ctx->outer; } - if (activation->__hasProperty__(this, name)) + if (activation->__hasProperty__(name)) return; Property desc = Property::fromValue(Value::undefinedValue()); PropertyAttributes attrs(Attr_Data); @@ -215,7 +215,7 @@ bool ExecutionContext::deleteProperty(String *name) if (ctx->type == Type_WithContext) { hasWith = true; WithContext *w = static_cast(ctx); - if (w->withObject->__hasProperty__(this, name)) + if (w->withObject->__hasProperty__(name)) return w->withObject->deleteProperty(this, name); } else if (ctx->type == Type_CatchContext) { CatchContext *c = static_cast(ctx); @@ -232,11 +232,11 @@ bool ExecutionContext::deleteProperty(String *name) if (f->formalParameterList[i]->isEqualTo(name)) return false; } - if (c->activation && c->activation->__hasProperty__(this, name)) + if (c->activation && c->activation->__hasProperty__(name)) return c->activation->deleteProperty(this, name); } else if (ctx->type == Type_GlobalContext) { GlobalContext *g = static_cast(ctx); - if (g->global->__hasProperty__(this, name)) + if (g->global->__hasProperty__(name)) return g->global->deleteProperty(this, name); } } @@ -292,7 +292,7 @@ void ExecutionContext::setProperty(String *name, const Value& value) for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { if (ctx->type == Type_WithContext) { Object *w = static_cast(ctx)->withObject; - if (w->__hasProperty__(ctx, name)) { + if (w->__hasProperty__(name)) { w->put(ctx, name, value); return; } @@ -318,7 +318,7 @@ void ExecutionContext::setProperty(String *name, const Value& value) activation = static_cast(ctx)->global; } - if (activation && (ctx->type == Type_QmlContext || activation->__hasProperty__(this, name))) { + if (activation && (ctx->type == Type_QmlContext || activation->__hasProperty__(name))) { activation->put(this, name, value); return; } diff --git a/src/v4/qv4object.cpp b/src/v4/qv4object.cpp index 0937a98cf6..b68c8de8be 100644 --- a/src/v4/qv4object.cpp +++ b/src/v4/qv4object.cpp @@ -236,11 +236,11 @@ Property *Object::insertMember(String *s, PropertyAttributes attributes) } // Section 8.12.1 -Property *Object::__getOwnProperty__(ExecutionContext *ctx, String *name, PropertyAttributes *attrs) +Property *Object::__getOwnProperty__(String *name, PropertyAttributes *attrs) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) - return __getOwnProperty__(ctx, idx, attrs); + return __getOwnProperty__(idx, attrs); uint member = internalClass->find(name); if (member < UINT_MAX) { @@ -254,7 +254,7 @@ Property *Object::__getOwnProperty__(ExecutionContext *ctx, String *name, Proper return 0; } -Property *Object::__getOwnProperty__(ExecutionContext *ctx, uint index, PropertyAttributes *attrs) +Property *Object::__getOwnProperty__(uint index, PropertyAttributes *attrs) { uint pidx = propertyIndexFromArrayIndex(index); if (pidx < UINT_MAX) { @@ -272,7 +272,7 @@ Property *Object::__getOwnProperty__(ExecutionContext *ctx, uint index, Property if (isStringObject()) { if (attrs) *attrs = Attr_NotConfigurable|Attr_NotWritable; - return static_cast(this)->getIndex(ctx, index); + return static_cast(this)->getIndex(index); } if (attrs) @@ -281,11 +281,11 @@ Property *Object::__getOwnProperty__(ExecutionContext *ctx, uint index, Property } // Section 8.12.2 -Property *Object::__getPropertyDescriptor__(const ExecutionContext *ctx, String *name, PropertyAttributes *attrs) const +Property *Object::__getPropertyDescriptor__(String *name, PropertyAttributes *attrs) const { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) - return __getPropertyDescriptor__(ctx, idx); + return __getPropertyDescriptor__(idx); const Object *o = this; @@ -304,7 +304,7 @@ Property *Object::__getPropertyDescriptor__(const ExecutionContext *ctx, String return 0; } -Property *Object::__getPropertyDescriptor__(const ExecutionContext *ctx, uint index, PropertyAttributes *attrs) const +Property *Object::__getPropertyDescriptor__(uint index, PropertyAttributes *attrs) const { const Object *o = this; while (o) { @@ -318,7 +318,7 @@ Property *Object::__getPropertyDescriptor__(const ExecutionContext *ctx, uint in } } if (o->isStringObject()) { - Property *p = static_cast(o)->getIndex(ctx, index); + Property *p = static_cast(o)->getIndex(index); if (p) { if (attrs) *attrs = (Attr_NotWritable|Attr_NotConfigurable); @@ -380,7 +380,7 @@ PropertyAttributes Object::queryIndexed(Managed *m, ExecutionContext *ctx, uint return Attr_Data; } if (o->isStringObject()) { - Property *p = static_cast(o)->getIndex(ctx, index); + Property *p = static_cast(o)->getIndex(index); if (p) return Attr_Data; } @@ -448,7 +448,7 @@ Value Object::internalGetIndexed(ExecutionContext *ctx, uint index, bool *hasPro } } if (o->isStringObject()) { - pd = static_cast(o)->getIndex(ctx, index); + pd = static_cast(o)->getIndex(index); if (pd) { attrs = (Attr_NotWritable|Attr_NotConfigurable); break; @@ -511,7 +511,7 @@ void Object::internalPut(ExecutionContext *ctx, String *name, const Value &value goto reject; } else { // clause 4 - if ((pd = prototype->__getPropertyDescriptor__(ctx, name, &attrs))) { + if ((pd = prototype->__getPropertyDescriptor__(name, &attrs))) { if (attrs.isAccessor()) { if (!pd->setter()) goto reject; @@ -562,7 +562,7 @@ void Object::internalPutIndexed(ExecutionContext *ctx, uint index, const Value & } if (!pd && isStringObject()) { - pd = static_cast(this)->getIndex(ctx, index); + pd = static_cast(this)->getIndex(index); if (pd) // not writable goto reject; @@ -584,7 +584,7 @@ void Object::internalPutIndexed(ExecutionContext *ctx, uint index, const Value & goto reject; } else { // clause 4 - if ((pd = prototype->__getPropertyDescriptor__(ctx, index, &attrs))) { + if ((pd = prototype->__getPropertyDescriptor__(index, &attrs))) { if (attrs.isAccessor()) { if (!pd->setter()) goto reject; @@ -742,7 +742,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Prop if (pidx < UINT_MAX && (!arrayAttributes || !arrayAttributes[pidx].isGeneric())) current = arrayData + pidx; if (!current && isStringObject()) - current = static_cast(this)->getIndex(ctx, index); + current = static_cast(this)->getIndex(index); } if (!current) { diff --git a/src/v4/qv4object.h b/src/v4/qv4object.h index 9919ce3ade..f82f953970 100644 --- a/src/v4/qv4object.h +++ b/src/v4/qv4object.h @@ -128,17 +128,17 @@ struct Q_V4_EXPORT Object: Managed { Object(ExecutionContext *context); ~Object(); - Property *__getOwnProperty__(ExecutionContext *ctx, String *name, PropertyAttributes *attrs = 0); - Property *__getOwnProperty__(ExecutionContext *ctx, uint index, PropertyAttributes *attrs = 0); + Property *__getOwnProperty__(String *name, PropertyAttributes *attrs = 0); + Property *__getOwnProperty__(uint index, PropertyAttributes *attrs = 0); - Property *__getPropertyDescriptor__(const ExecutionContext *ctx, String *name, PropertyAttributes *attrs = 0) const; - Property *__getPropertyDescriptor__(const ExecutionContext *ctx, uint index, PropertyAttributes *attrs = 0) const; + Property *__getPropertyDescriptor__(String *name, PropertyAttributes *attrs = 0) const; + Property *__getPropertyDescriptor__(uint index, PropertyAttributes *attrs = 0) const; - bool __hasProperty__(const ExecutionContext *ctx, String *name) const { - return __getPropertyDescriptor__(ctx, name); + bool __hasProperty__(String *name) const { + return __getPropertyDescriptor__(name); } - bool __hasProperty__(const ExecutionContext *ctx, uint index) const { - return __getPropertyDescriptor__(ctx, index); + bool __hasProperty__(uint index) const { + return __getPropertyDescriptor__(index); } bool __defineOwnProperty__(ExecutionContext *ctx, Property *current, String *member, const Property &p, PropertyAttributes attrs); diff --git a/src/v4/qv4objectiterator.cpp b/src/v4/qv4objectiterator.cpp index f7c211365e..44ba9efcaa 100644 --- a/src/v4/qv4objectiterator.cpp +++ b/src/v4/qv4objectiterator.cpp @@ -78,7 +78,7 @@ Property *ObjectIterator::next(String **name, uint *index, PropertyAttributes *a ++arrayIndex; if (attrs) *attrs = s->arrayAttributes ? s->arrayAttributes[arrayIndex] : PropertyAttributes(Attr_NotWritable|Attr_NotConfigurable); - return s->__getOwnProperty__(context, *index); + return s->__getOwnProperty__(*index); } flags &= ~CurrentIsString; arrayNode = current->sparseArrayBegin(); diff --git a/src/v4/qv4objectproto.cpp b/src/v4/qv4objectproto.cpp index b818d28821..df3d4c8e43 100644 --- a/src/v4/qv4objectproto.cpp +++ b/src/v4/qv4objectproto.cpp @@ -146,7 +146,7 @@ Value ObjectPrototype::method_getOwnPropertyDescriptor(SimpleCallContext *ctx) String *name = ctx->argument(1).toString(ctx); PropertyAttributes attrs; - Property *desc = O.objectValue()->__getOwnProperty__(ctx, name, &attrs); + Property *desc = O.objectValue()->__getOwnProperty__(name, &attrs); return fromPropertyDescriptor(ctx, desc, attrs); } @@ -408,7 +408,7 @@ Value ObjectPrototype::method_hasOwnProperty(SimpleCallContext *ctx) { String *P = ctx->argument(0).toString(ctx); Object *O = ctx->thisObject.toObject(ctx); - bool r = O->__getOwnProperty__(ctx, P) != 0; + bool r = O->__getOwnProperty__(P) != 0; return Value::fromBoolean(r); } @@ -434,7 +434,7 @@ Value ObjectPrototype::method_propertyIsEnumerable(SimpleCallContext *ctx) Object *o = ctx->thisObject.toObject(ctx); PropertyAttributes attrs; - o->__getOwnProperty__(ctx, p, &attrs); + o->__getOwnProperty__(p, &attrs); return Value::fromBoolean(attrs.isEnumerable()); } @@ -483,13 +483,13 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope desc->setGetter(0); desc->setSetter(0); - if (o->__hasProperty__(ctx, ctx->engine->id_enumerable)) + if (o->__hasProperty__(ctx->engine->id_enumerable)) attrs->setEnumerable(o->get(ctx, ctx->engine->id_enumerable).toBoolean()); - if (o->__hasProperty__(ctx, ctx->engine->id_configurable)) + if (o->__hasProperty__(ctx->engine->id_configurable)) attrs->setConfigurable(o->get(ctx, ctx->engine->id_configurable).toBoolean()); - if (o->__hasProperty__(ctx, ctx->engine->id_get)) { + if (o->__hasProperty__(ctx->engine->id_get)) { Value get = o->get(ctx, ctx->engine->id_get); FunctionObject *f = get.asFunctionObject(); if (f) { @@ -502,7 +502,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope attrs->setType(PropertyAttributes::Accessor); } - if (o->__hasProperty__(ctx, ctx->engine->id_set)) { + if (o->__hasProperty__(ctx->engine->id_set)) { Value set = o->get(ctx, ctx->engine->id_set); FunctionObject *f = set.asFunctionObject(); if (f) { @@ -515,7 +515,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope attrs->setType(PropertyAttributes::Accessor); } - if (o->__hasProperty__(ctx, ctx->engine->id_writable)) { + if (o->__hasProperty__(ctx->engine->id_writable)) { if (attrs->isAccessor()) ctx->throwTypeError(); attrs->setWritable(o->get(ctx, ctx->engine->id_writable).toBoolean()); @@ -523,7 +523,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope desc->value = Value::undefinedValue(); } - if (o->__hasProperty__(ctx, ctx->engine->id_value)) { + if (o->__hasProperty__(ctx->engine->id_value)) { if (attrs->isAccessor()) ctx->throwTypeError(); desc->value = o->get(ctx, ctx->engine->id_value); diff --git a/src/v4/qv4runtime.cpp b/src/v4/qv4runtime.cpp index fcc2b4f5a1..727aa6e4a8 100644 --- a/src/v4/qv4runtime.cpp +++ b/src/v4/qv4runtime.cpp @@ -246,7 +246,7 @@ void __qmljs_in(ExecutionContext *ctx, Value *result, const Value &left, const V if (!right.isObject()) ctx->throwTypeError(); String *s = left.toString(ctx); - bool r = right.objectValue()->__hasProperty__(ctx, s); + bool r = right.objectValue()->__hasProperty__(s); *result = Value::fromBoolean(r); } diff --git a/src/v4/qv4string.cpp b/src/v4/qv4string.cpp index 1fd50f4eab..cb17547f07 100644 --- a/src/v4/qv4string.cpp +++ b/src/v4/qv4string.cpp @@ -107,7 +107,7 @@ Value String::get(Managed *m, ExecutionContext *ctx, String *name, bool *hasProp return Value::fromInt32(that->_text.length()); } PropertyAttributes attrs; - Property *pd = ctx->engine->stringPrototype->__getPropertyDescriptor__(ctx, name, &attrs); + Property *pd = ctx->engine->stringPrototype->__getPropertyDescriptor__(name, &attrs); if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; @@ -127,7 +127,7 @@ Value String::getIndexed(Managed *m, ExecutionContext *ctx, uint index, bool *ha return Value::fromString(ctx, that->toQString().mid(index, 1)); } PropertyAttributes attrs; - Property *pd = ctx->engine->stringPrototype->__getPropertyDescriptor__(ctx, index, &attrs); + Property *pd = ctx->engine->stringPrototype->__getPropertyDescriptor__(index, &attrs); if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; diff --git a/src/v4/qv4stringobject.cpp b/src/v4/qv4stringobject.cpp index 6003f4a4e3..cd3e156840 100644 --- a/src/v4/qv4stringobject.cpp +++ b/src/v4/qv4stringobject.cpp @@ -89,12 +89,12 @@ StringObject::StringObject(ExecutionContext *ctx, const Value &value) defineReadonlyProperty(ctx->engine->id_length, Value::fromUInt32(value.stringValue()->toQString().length())); } -Property *StringObject::getIndex(const ExecutionContext *ctx, uint index) const +Property *StringObject::getIndex(uint index) const { QString str = value.stringValue()->toQString(); if (index >= (uint)str.length()) return 0; - String *result = ctx->engine->newString(str.mid(index, 1)); + String *result = internalClass->engine->newString(str.mid(index, 1)); tmpProperty.value = Value::fromString(result); return &tmpProperty; } diff --git a/src/v4/qv4stringobject.h b/src/v4/qv4stringobject.h index 54f9130a49..ded26c501b 100644 --- a/src/v4/qv4stringobject.h +++ b/src/v4/qv4stringobject.h @@ -55,7 +55,7 @@ struct StringObject: Object { mutable Property tmpProperty; StringObject(ExecutionContext *ctx, const Value &value); - Property *getIndex(const ExecutionContext *ctx, uint index) const; + Property *getIndex(uint index) const; protected: static const ManagedVTable static_vtbl; diff --git a/src/v4/qv4v8.cpp b/src/v4/qv4v8.cpp index db4c84e041..7630423f27 100644 --- a/src/v4/qv4v8.cpp +++ b/src/v4/qv4v8.cpp @@ -864,7 +864,7 @@ bool Object::Has(Handle key) { QQmlJS::VM::Object *o = ConstValuePtr(this)->asObject(); assert(o); - return o->__hasProperty__(currentEngine()->current, ValuePtr(&key)->asString()); + return o->__hasProperty__(ValuePtr(&key)->asString()); } bool Object::Delete(Handle key) @@ -887,7 +887,7 @@ bool Object::Has(uint32_t index) QQmlJS::VM::Object *o = ConstValuePtr(this)->asObject(); if (!o) return false; - return o->__hasProperty__(currentEngine()->current, index); + return o->__hasProperty__(index); } bool Object::Delete(uint32_t index) @@ -1012,7 +1012,7 @@ bool Object::HasOwnProperty(Handle key) QQmlJS::VM::Object *o = ConstValuePtr(this)->asObject(); assert(o); QQmlJS::VM::ExecutionContext *ctx = currentEngine()->current; - return o->__getOwnProperty__(ctx, ValuePtr(&key)->toString(ctx)); + return o->__getOwnProperty__(ValuePtr(&key)->toString(ctx)); } int Object::GetIdentityHash() @@ -1522,7 +1522,7 @@ protected: return; } PropertyAttributes attrs; - Property *pd = that->__getOwnProperty__(ctx, name, &attrs); + Property *pd = that->__getOwnProperty__(name, &attrs); if (pd) that->putValue(ctx, pd, attrs, value); else if (that->m_template->m_fallbackPropertySetter) -- cgit v1.2.3