Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index 469059ba21a3981a8e1c6b9d5e9db057f74f098d..0a42a5197558cb23ace828679610fc95fc6548fc 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -399,6 +399,23 @@ function ToPropertyDescriptor(obj) { |
| } |
| +// For Harmony proxies. |
| +function ToCompletePropertyDescriptor(obj) { |
| + var desc = ToPropertyDescriptor(obj) |
| + if (IsGenericDescriptor(desc) || IsDataDescriptor(desc)) { |
| + if (!("value" in desc)) desc.value = undefined |
|
Kevin Millikin (Chromium)
2011/06/01 15:14:31
undefined ==> void 0
|
| + if (!("writable" in desc)) desc.writable = false |
| + } else { |
| + // Is accessor descriptor. |
| + if (!("get" in desc)) desc.get = undefined |
| + if (!("set" in desc)) desc.set = undefined |
| + } |
| + if (!("enumerable" in desc)) desc.enumerable = false |
| + if (!("configurable" in desc)) desc.configurable = false |
| + return desc |
| +} |
| + |
| + |
| function PropertyDescriptor() { |
| // Initialize here so they are all in-object and have the same map. |
| // Default values from ES5 8.6.1. |
| @@ -547,9 +564,23 @@ function ConvertDescriptorArrayToDescriptor(desc_array) { |
| // ES5 section 8.12.2. |
| function GetProperty(obj, p) { |
| + if (%IsJSProxy(obj)) { |
| + var handler = %GetHandler(obj) |
| + var getProperty = handler.getPropertyDescriptor |
| + if (IS_UNDEFINED(getProperty)) |
| + throw MakeTypeError("handler_trap_missing", |
| + [handler, "getPropertyDescriptor"]) |
| + var descriptor = getProperty.call(handler, p) |
| + if (IS_UNDEFINED(descriptor)) return descriptor |
| + var desc = ToCompletePropertyDescriptor(descriptor) |
| + if (!desc.configurable) |
| + throw MakeTypeError("proxy_prop_not_configurable", |
| + [handler, "getPropertyDescriptor", p, descriptor]) |
| + return desc |
| + } |
| var prop = GetOwnProperty(obj); |
| if (!IS_UNDEFINED(prop)) return prop; |
| - var proto = obj.__proto__; |
| + var proto = %GetPrototype(obj); |
| if (IS_NULL(proto)) return void 0; |
| return GetProperty(proto, p); |
| } |
| @@ -557,6 +588,12 @@ function GetProperty(obj, p) { |
| // ES5 section 8.12.6 |
| function HasProperty(obj, p) { |
| + if (%IsJSProxy(obj)) { |
| + var handler = %GetHandler(obj) |
| + var has = handler.has |
| + if (IS_UNDEFINED(has)) has = DerivedHasTrap |
| + return ToBoolean(has.call(handler, obj, p)) |
| + } |
| var desc = GetProperty(obj, p); |
| return IS_UNDEFINED(desc) ? false : true; |
| } |
| @@ -745,7 +782,7 @@ function DefineOwnProperty(obj, p, desc, should_throw) { |
| function ObjectGetPrototypeOf(obj) { |
| if (!IS_SPEC_OBJECT(obj)) |
| throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]); |
| - return obj.__proto__; |
| + return %GetPrototype(obj); |
| } |