Commit 2a90f8ff authored by andersca's avatar andersca

2005-12-30 Anders Carlsson <andersca@mac.com>

        Reviewed by Maciej.

		- Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6298
		Getter setter test is failing

        * kjs/object.cpp:
        (KJS::JSObject::put):
		Rework the getter setter part. We now walk the prototype chain, checking for
		getter/setter properties and only take the slow path if any are found.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a4aa18fc
2005-12-30 Anders Carlsson <andersca@mac.com>
Reviewed by Maciej.
- Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6298
Getter setter test is failing
* kjs/object.cpp:
(KJS::JSObject::put):
Rework the getter setter part. We now walk the prototype chain, checking for
getter/setter properties and only take the slow path if any are found.
2005-12-30 Maks Orlovich <maksim@kde.org>
Reviewed and committed by Maciej.
......
......@@ -218,37 +218,53 @@ void JSObject::put(ExecState *exec, const Identifier &propertyName, JSValue *val
return;
}
// Check if there are any setters or getters in the prototype chain
JSObject *obj = this;
bool hasGettersOrSetters = false;
while (true) {
JSValue *gs;
int attributes;
if (obj->_prop.hasGetterSetterProperties() && (gs = obj->_prop.get(propertyName, attributes))) {
if (attributes & GetterSetter) {
JSObject *setterFunc = static_cast<GetterSetterImp *>(gs)->getSetter();
if (obj->_prop.hasGetterSetterProperties()) {
hasGettersOrSetters = true;
break;
}
if (!obj->_proto->isObject())
break;
obj = static_cast<JSObject *>(obj->_proto);
}
if (hasGettersOrSetters) {
obj = this;
while (true) {
int attributes;
if (JSValue *gs = obj->_prop.get(propertyName, attributes)) {
if (attributes & GetterSetter) {
JSObject *setterFunc = static_cast<GetterSetterImp *>(gs)->getSetter();
if (!setterFunc) {
throwSetterError(exec);
return;
}
if (!setterFunc) {
throwSetterError(exec);
List args;
args.append(value);
setterFunc->call(exec, this, args);
return;
} else {
// If there's an existing property on the object or one of its
// prototype it should be replaced, so we just break here.
break;
}
List args;
args.append(value);
setterFunc->call(exec, this, args);
return;
} else {
// If there's an existing property on the object or one of its
// prototype it should be replaced, so we just break here.
break;
}
}
if (!obj->_proto->isObject())
break;
if (!obj->_proto->isObject())
break;
obj = static_cast<JSObject *>(obj->_proto);
obj = static_cast<JSObject *>(obj->_proto);
}
}
_prop.put(propertyName,value,attr);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment