OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 Handle<Object> result = CallTrap( | 227 Handle<Object> result = CallTrap( |
228 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args); | 228 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args); |
229 if (isolate->has_pending_exception()) return Failure::Exception(); | 229 if (isolate->has_pending_exception()) return Failure::Exception(); |
230 | 230 |
231 return *result; | 231 return *result; |
232 } | 232 } |
233 | 233 |
234 | 234 |
235 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, | 235 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, |
236 uint32_t index) { | 236 uint32_t index) { |
237 Heap* heap = GetHeap(); | |
238 Object* number; | |
239 MaybeObject* maybe = heap->NumberFromUint32(index); | |
240 if (!maybe->To<Object>(&number)) return maybe; | |
241 maybe = heap->NumberToString(number); | |
242 String* name; | 237 String* name; |
238 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | |
243 if (!maybe->To<String>(&name)) return maybe; | 239 if (!maybe->To<String>(&name)) return maybe; |
244 return GetPropertyWithHandler(receiver, name); | 240 return GetPropertyWithHandler(receiver, name); |
245 } | 241 } |
246 | 242 |
247 | 243 |
244 MaybeObject* JSProxy::SetElementWithHandler(uint32_t index, | |
245 Object* value, | |
246 StrictModeFlag strict_mode) { | |
247 String* name; | |
248 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | |
249 if (!maybe->To<String>(&name)) return maybe; | |
250 return SetPropertyWithHandler(name, value, NONE, strict_mode); | |
251 } | |
252 | |
253 | |
254 bool JSProxy::HasElementWithHandler(uint32_t index) { | |
255 String* name; | |
256 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | |
257 if (!maybe->To<String>(&name)) return maybe; | |
258 return HasPropertyWithHandler(name); | |
259 } | |
260 | |
261 | |
248 MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver, | 262 MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver, |
249 JSFunction* getter) { | 263 JSFunction* getter) { |
250 HandleScope scope; | 264 HandleScope scope; |
251 Handle<JSFunction> fun(JSFunction::cast(getter)); | 265 Handle<JSFunction> fun(JSFunction::cast(getter)); |
252 Handle<Object> self(receiver); | 266 Handle<Object> self(receiver); |
253 #ifdef ENABLE_DEBUGGER_SUPPORT | 267 #ifdef ENABLE_DEBUGGER_SUPPORT |
254 Debug* debug = fun->GetHeap()->isolate()->debug(); | 268 Debug* debug = fun->GetHeap()->isolate()->debug(); |
255 // Handle stepping into a getter if step into is active. | 269 // Handle stepping into a getter if step into is active. |
256 if (debug->StepInActive()) { | 270 if (debug->StepInActive()) { |
257 debug->HandleStepIn(fun, Handle<Object>::null(), 0, false); | 271 debug->HandleStepIn(fun, Handle<Object>::null(), 0, false); |
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1919 | 1933 |
1920 MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes( | 1934 MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes( |
1921 uint32_t index, | 1935 uint32_t index, |
1922 Object* value, | 1936 Object* value, |
1923 bool* found, | 1937 bool* found, |
1924 StrictModeFlag strict_mode) { | 1938 StrictModeFlag strict_mode) { |
1925 Heap* heap = GetHeap(); | 1939 Heap* heap = GetHeap(); |
1926 for (Object* pt = GetPrototype(); | 1940 for (Object* pt = GetPrototype(); |
1927 pt != heap->null_value(); | 1941 pt != heap->null_value(); |
1928 pt = pt->GetPrototype()) { | 1942 pt = pt->GetPrototype()) { |
1943 if (pt->IsJSProxy()) { | |
1944 String* name; | |
1945 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | |
1946 if (!maybe->To<String>(&name)) { | |
1947 *found = true; // Force abort | |
1948 return maybe; | |
1949 } | |
1950 return JSProxy::cast(pt)->SetPropertyWithHandlerDefiningSetter( | |
1951 name, value, NONE, strict_mode, found); | |
1952 } | |
1929 if (!JSObject::cast(pt)->HasDictionaryElements()) { | 1953 if (!JSObject::cast(pt)->HasDictionaryElements()) { |
1930 continue; | 1954 continue; |
1931 } | 1955 } |
1932 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary(); | 1956 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary(); |
1933 int entry = dictionary->FindEntry(index); | 1957 int entry = dictionary->FindEntry(index); |
1934 if (entry != NumberDictionary::kNotFound) { | 1958 if (entry != NumberDictionary::kNotFound) { |
1935 PropertyDetails details = dictionary->DetailsAt(entry); | 1959 PropertyDetails details = dictionary->DetailsAt(entry); |
1936 if (details.type() == CALLBACKS) { | 1960 if (details.type() == CALLBACKS) { |
1937 *found = true; | 1961 *found = true; |
1938 return SetElementWithCallback(dictionary->ValueAt(entry), | 1962 return SetElementWithCallback(dictionary->ValueAt(entry), |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2254 Handle<Object> value(value_raw); | 2278 Handle<Object> value(value_raw); |
2255 | 2279 |
2256 Handle<Object> args[] = { receiver, name, value }; | 2280 Handle<Object> args[] = { receiver, name, value }; |
2257 CallTrap("set", isolate->derived_set_trap(), ARRAY_SIZE(args), args); | 2281 CallTrap("set", isolate->derived_set_trap(), ARRAY_SIZE(args), args); |
2258 if (isolate->has_pending_exception()) return Failure::Exception(); | 2282 if (isolate->has_pending_exception()) return Failure::Exception(); |
2259 | 2283 |
2260 return *value; | 2284 return *value; |
2261 } | 2285 } |
2262 | 2286 |
2263 | 2287 |
2288 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyWithHandlerDefiningSetter( | |
2289 String* name, | |
2290 Object* value, | |
2291 PropertyAttributes attributes, | |
2292 StrictModeFlag strict_mode, | |
2293 bool* found) { | |
2294 *found = true; // except where defined otherwise... | |
2295 Isolate* isolate = GetHeap()->isolate(); | |
2296 Handle<JSProxy> proxy(this); | |
2297 Handle<String> hname(name); | |
2298 Handle<Object> hvalue(value); | |
2299 Handle<Object> args[] = { hname }; | |
2300 Handle<Object> result = proxy->CallTrap( | |
2301 "getOwnPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); | |
Rico
2011/09/12 11:21:18
4 space indention
rossberg
2011/09/13 16:10:25
Done.
| |
2302 if (isolate->has_pending_exception()) return Failure::Exception(); | |
2303 | |
2304 if (!result->IsUndefined()) { | |
2305 // The proxy handler cares about this property. | |
2306 // Check whether it is virtualized as an accessor. | |
2307 Handle<String> getter_name = | |
Rico
2011/09/12 11:21:18
We might as well lookup the setter first, and then
rossberg
2011/09/13 16:10:25
Done.
I also forgot to invoke ToCompletePropertyD
| |
2308 isolate->factory()->LookupAsciiSymbol("get"); | |
2309 Handle<Object> getter( | |
2310 v8::internal::GetProperty(result, getter_name)); | |
2311 if (isolate->has_pending_exception()) return Failure::Exception(); | |
2312 Handle<String> setter_name = | |
2313 isolate->factory()->LookupAsciiSymbol("set"); | |
2314 Handle<Object> setter( | |
2315 v8::internal::GetProperty(result, setter_name)); | |
2316 if (isolate->has_pending_exception()) return Failure::Exception(); | |
2317 | |
2318 if (!setter->IsUndefined()) { | |
2319 // We have a setter -- invoke it. | |
2320 if (setter->IsJSFunction()) { | |
2321 return proxy->SetPropertyWithDefinedSetter( | |
2322 JSFunction::cast(*setter), *hvalue); | |
2323 } | |
2324 Handle<Object> args[] = { setter }; | |
2325 Handle<Object> error = isolate->factory()->NewTypeError( | |
2326 "setter_must_be_callable", HandleVector(args, ARRAY_SIZE(args))); | |
Rico
2011/09/12 11:21:18
4 space indention
rossberg
2011/09/13 16:10:25
Done.
| |
2327 return isolate->Throw(*error); | |
2328 } else if (!getter->IsUndefined()) { | |
2329 // We have a getter but no setter -- the property may not be | |
2330 // written. In strict mode, throw an error. | |
2331 if (strict_mode == kNonStrictMode) return *hvalue; | |
2332 Handle<Object> args[] = { hname, proxy }; | |
2333 Handle<Object> error = isolate->factory()->NewTypeError( | |
2334 "no_setter_in_callback", HandleVector(args, ARRAY_SIZE(args))); | |
2335 return isolate->Throw(*error); | |
2336 } | |
2337 // Fall-through. | |
2338 } | |
2339 | |
2340 // The proxy does not define the property as an accessor. | |
2341 *found = false; | |
2342 return value; | |
2343 } | |
2344 | |
2345 | |
2264 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler( | 2346 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler( |
2265 String* name_raw, DeleteMode mode) { | 2347 String* name_raw, DeleteMode mode) { |
2266 Isolate* isolate = GetIsolate(); | 2348 Isolate* isolate = GetIsolate(); |
2267 HandleScope scope(isolate); | 2349 HandleScope scope(isolate); |
2268 Handle<Object> receiver(this); | 2350 Handle<Object> receiver(this); |
2269 Handle<Object> name(name_raw); | 2351 Handle<Object> name(name_raw); |
2270 | 2352 |
2271 Handle<Object> args[] = { name }; | 2353 Handle<Object> args[] = { name }; |
2272 Handle<Object> result = CallTrap( | 2354 Handle<Object> result = CallTrap( |
2273 "delete", Handle<Object>(), ARRAY_SIZE(args), args); | 2355 "delete", Handle<Object>(), ARRAY_SIZE(args), args); |
2274 if (isolate->has_pending_exception()) return Failure::Exception(); | 2356 if (isolate->has_pending_exception()) return Failure::Exception(); |
2275 | 2357 |
2276 Object* bool_result = result->ToBoolean(); | 2358 Object* bool_result = result->ToBoolean(); |
2277 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) { | 2359 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) { |
2278 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete"); | 2360 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete"); |
2279 Handle<Object> args[] = { Handle<Object>(handler()), trap_name }; | 2361 Handle<Object> args[] = { Handle<Object>(handler()), trap_name }; |
2280 Handle<Object> error = isolate->factory()->NewTypeError( | 2362 Handle<Object> error = isolate->factory()->NewTypeError( |
2281 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); | 2363 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); |
2282 isolate->Throw(*error); | 2364 isolate->Throw(*error); |
2283 return Failure::Exception(); | 2365 return Failure::Exception(); |
2284 } | 2366 } |
2285 return bool_result; | 2367 return bool_result; |
2286 } | 2368 } |
2287 | 2369 |
2288 | 2370 |
2371 MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler( | |
2372 uint32_t index, DeleteMode mode) { | |
Rico
2011/09/12 11:21:18
parameters on separate lines to be consistent
rossberg
2011/09/13 16:10:25
Done.
| |
2373 String* name; | |
2374 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | |
2375 if (!maybe->To<String>(&name)) return maybe; | |
2376 return JSProxy::DeletePropertyWithHandler(name, mode); | |
2377 } | |
2378 | |
2379 | |
2289 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( | 2380 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( |
2290 JSReceiver* receiver_raw, | 2381 JSReceiver* receiver_raw, |
2291 String* name_raw) { | 2382 String* name_raw) { |
2292 Isolate* isolate = GetIsolate(); | 2383 Isolate* isolate = GetIsolate(); |
2293 HandleScope scope(isolate); | 2384 HandleScope scope(isolate); |
2294 Handle<JSReceiver> receiver(receiver_raw); | 2385 Handle<JSReceiver> receiver(receiver_raw); |
2295 Handle<Object> name(name_raw); | 2386 Handle<Object> name(name_raw); |
2296 | 2387 |
2297 Handle<Object> args[] = { name }; | 2388 Handle<Object> args[] = { name }; |
2298 Handle<Object> result = CallTrap( | 2389 Handle<Object> result = CallTrap( |
(...skipping 21 matching lines...) Expand all Loading... | |
2320 if (isolate->has_pending_exception()) return NONE; | 2411 if (isolate->has_pending_exception()) return NONE; |
2321 | 2412 |
2322 int attributes = NONE; | 2413 int attributes = NONE; |
2323 if (enumerable->ToBoolean()->IsFalse()) attributes |= DONT_ENUM; | 2414 if (enumerable->ToBoolean()->IsFalse()) attributes |= DONT_ENUM; |
2324 if (configurable->ToBoolean()->IsFalse()) attributes |= DONT_DELETE; | 2415 if (configurable->ToBoolean()->IsFalse()) attributes |= DONT_DELETE; |
2325 if (writable->ToBoolean()->IsFalse()) attributes |= READ_ONLY; | 2416 if (writable->ToBoolean()->IsFalse()) attributes |= READ_ONLY; |
2326 return static_cast<PropertyAttributes>(attributes); | 2417 return static_cast<PropertyAttributes>(attributes); |
2327 } | 2418 } |
2328 | 2419 |
2329 | 2420 |
2421 MUST_USE_RESULT PropertyAttributes JSProxy::GetElementAttributeWithHandler( | |
2422 JSReceiver* receiver, | |
2423 uint32_t index) { | |
2424 String* name; | |
2425 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | |
2426 if (!maybe->To<String>(&name)) return NONE; | |
Rico
2011/09/12 11:21:18
Why do we return NONE here if allocation fails?
rossberg
2011/09/13 16:10:25
Fixed by introducing a factory method.
| |
2427 return GetPropertyAttributeWithHandler(receiver, name); | |
2428 } | |
2429 | |
2430 | |
2330 void JSProxy::Fix() { | 2431 void JSProxy::Fix() { |
2331 Isolate* isolate = GetIsolate(); | 2432 Isolate* isolate = GetIsolate(); |
2332 HandleScope scope(isolate); | 2433 HandleScope scope(isolate); |
2333 Handle<JSProxy> self(this); | 2434 Handle<JSProxy> self(this); |
2334 | 2435 |
2335 if (IsJSFunctionProxy()) { | 2436 if (IsJSFunctionProxy()) { |
2336 isolate->factory()->BecomeJSFunction(self); | 2437 isolate->factory()->BecomeJSFunction(self); |
2337 // Code will be set on the JavaScript side. | 2438 // Code will be set on the JavaScript side. |
2338 } else { | 2439 } else { |
2339 isolate->factory()->BecomeJSObject(self); | 2440 isolate->factory()->BecomeJSObject(self); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2417 if (accessor_result.IsFound()) { | 2518 if (accessor_result.IsFound()) { |
2418 if (accessor_result.type() == CALLBACKS) { | 2519 if (accessor_result.type() == CALLBACKS) { |
2419 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), | 2520 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
2420 name, | 2521 name, |
2421 value, | 2522 value, |
2422 accessor_result.holder(), | 2523 accessor_result.holder(), |
2423 strict_mode); | 2524 strict_mode); |
2424 } else if (accessor_result.type() == HANDLER) { | 2525 } else if (accessor_result.type() == HANDLER) { |
2425 // There is a proxy in the prototype chain. Invoke its | 2526 // There is a proxy in the prototype chain. Invoke its |
2426 // getOwnPropertyDescriptor trap. | 2527 // getOwnPropertyDescriptor trap. |
2528 bool found = false; | |
2529 Handle<JSObject> self(this); | |
2530 Handle<String> hname(name); | |
2531 Handle<Object> hvalue(value); | |
2532 MaybeObject* result = | |
2533 accessor_result.proxy()->SetPropertyWithHandlerDefiningSetter( | |
2534 name, value, attributes, strict_mode, &found); | |
2535 if (found) return result; | |
2536 // The proxy does not define the property as an accessor. | |
2537 // Consequently, it has no effect on setting the receiver. | |
2538 return self->AddProperty(*hname, *hvalue, attributes, strict_mode); | |
2539 /* | |
Rico
2011/09/12 11:21:18
If this code is not needed anymore please delete i
rossberg
2011/09/13 16:10:25
Oops.
| |
2427 Isolate* isolate = heap->isolate(); | 2540 Isolate* isolate = heap->isolate(); |
2428 Handle<JSObject> self(this); | 2541 Handle<JSObject> self(this); |
2429 Handle<String> hname(name); | 2542 Handle<String> hname(name); |
2430 Handle<Object> hvalue(value); | 2543 Handle<Object> hvalue(value); |
2431 Handle<JSProxy> proxy(accessor_result.proxy()); | 2544 Handle<JSProxy> proxy(accessor_result.proxy()); |
2432 Handle<Object> args[] = { hname }; | 2545 Handle<Object> args[] = { hname }; |
2433 Handle<Object> result = proxy->CallTrap( | 2546 Handle<Object> result = proxy->CallTrap( |
2434 "getOwnPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); | 2547 "getOwnPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); |
2435 if (isolate->has_pending_exception()) return Failure::Exception(); | 2548 if (isolate->has_pending_exception()) return Failure::Exception(); |
2436 | 2549 |
(...skipping 27 matching lines...) Expand all Loading... | |
2464 if (strict_mode == kNonStrictMode) return *hvalue; | 2577 if (strict_mode == kNonStrictMode) return *hvalue; |
2465 Handle<Object> args[] = { hname, proxy }; | 2578 Handle<Object> args[] = { hname, proxy }; |
2466 Handle<Object> error = isolate->factory()->NewTypeError( | 2579 Handle<Object> error = isolate->factory()->NewTypeError( |
2467 "no_setter_in_callback", HandleVector(args, ARRAY_SIZE(args))); | 2580 "no_setter_in_callback", HandleVector(args, ARRAY_SIZE(args))); |
2468 return isolate->Throw(*error); | 2581 return isolate->Throw(*error); |
2469 } | 2582 } |
2470 // The proxy does not define the property as an accessor. | 2583 // The proxy does not define the property as an accessor. |
2471 // Consequently, it has no effect on setting the receiver. | 2584 // Consequently, it has no effect on setting the receiver. |
2472 return self->AddProperty(*hname, *hvalue, attributes, strict_mode); | 2585 return self->AddProperty(*hname, *hvalue, attributes, strict_mode); |
2473 } | 2586 } |
2587 */ | |
2474 } | 2588 } |
2475 } | 2589 } |
2476 } | 2590 } |
2477 | 2591 |
2478 // At this point, no GC should have happened, as this would invalidate | 2592 // At this point, no GC should have happened, as this would invalidate |
2479 // 'result', which we cannot handlify! | 2593 // 'result', which we cannot handlify! |
2480 | 2594 |
2481 if (!result->IsFound()) { | 2595 if (!result->IsFound()) { |
2482 // Neither properties nor transitions found. | 2596 // Neither properties nor transitions found. |
2483 return AddProperty(name, value, attributes, strict_mode); | 2597 return AddProperty(name, value, attributes, strict_mode); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2710 *name_handle, | 2824 *name_handle, |
2711 continue_search); | 2825 continue_search); |
2712 } | 2826 } |
2713 | 2827 |
2714 | 2828 |
2715 PropertyAttributes JSReceiver::GetPropertyAttributeWithReceiver( | 2829 PropertyAttributes JSReceiver::GetPropertyAttributeWithReceiver( |
2716 JSReceiver* receiver, | 2830 JSReceiver* receiver, |
2717 String* key) { | 2831 String* key) { |
2718 uint32_t index = 0; | 2832 uint32_t index = 0; |
2719 if (IsJSObject() && key->AsArrayIndex(&index)) { | 2833 if (IsJSObject() && key->AsArrayIndex(&index)) { |
2720 if (JSObject::cast(this)->HasElementWithReceiver(receiver, index)) | 2834 return JSObject::cast(this)->HasElementWithReceiver(receiver, index) |
2721 return NONE; | 2835 ? NONE : ABSENT; |
2722 return ABSENT; | |
2723 } | 2836 } |
2724 // Named property. | 2837 // Named property. |
2725 LookupResult result; | 2838 LookupResult result; |
2726 Lookup(key, &result); | 2839 Lookup(key, &result); |
2727 return GetPropertyAttribute(receiver, &result, key, true); | 2840 return GetPropertyAttribute(receiver, &result, key, true); |
2728 } | 2841 } |
2729 | 2842 |
2730 | 2843 |
2731 PropertyAttributes JSReceiver::GetPropertyAttribute(JSReceiver* receiver, | 2844 PropertyAttributes JSReceiver::GetPropertyAttribute(JSReceiver* receiver, |
2732 LookupResult* result, | 2845 LookupResult* result, |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3245 mode = JSReceiver::FORCE_DELETION; | 3358 mode = JSReceiver::FORCE_DELETION; |
3246 } | 3359 } |
3247 | 3360 |
3248 return GetElementsAccessor()->Delete(this, index, mode); | 3361 return GetElementsAccessor()->Delete(this, index, mode); |
3249 } | 3362 } |
3250 | 3363 |
3251 | 3364 |
3252 MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) { | 3365 MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) { |
3253 if (IsJSProxy()) { | 3366 if (IsJSProxy()) { |
3254 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode); | 3367 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode); |
3255 } else { | |
3256 return JSObject::cast(this)->DeleteProperty(name, mode); | |
3257 } | 3368 } |
3369 return JSObject::cast(this)->DeleteProperty(name, mode); | |
3258 } | 3370 } |
3259 | 3371 |
3260 | 3372 |
3373 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) { | |
3374 if (IsJSProxy()) { | |
3375 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode); | |
3376 } | |
3377 return JSObject::cast(this)->DeleteElement(index, mode); | |
3378 } | |
3379 | |
3380 | |
3261 MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) { | 3381 MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) { |
3262 Isolate* isolate = GetIsolate(); | 3382 Isolate* isolate = GetIsolate(); |
3263 // ECMA-262, 3rd, 8.6.2.5 | 3383 // ECMA-262, 3rd, 8.6.2.5 |
3264 ASSERT(name->IsString()); | 3384 ASSERT(name->IsString()); |
3265 | 3385 |
3266 // Check access rights if needed. | 3386 // Check access rights if needed. |
3267 if (IsAccessCheckNeeded() && | 3387 if (IsAccessCheckNeeded() && |
3268 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { | 3388 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { |
3269 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); | 3389 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); |
3270 return isolate->heap()->false_value(); | 3390 return isolate->heap()->false_value(); |
(...skipping 4609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7880 case NON_STRICT_ARGUMENTS_ELEMENTS: | 8000 case NON_STRICT_ARGUMENTS_ELEMENTS: |
7881 UNREACHABLE(); | 8001 UNREACHABLE(); |
7882 break; | 8002 break; |
7883 } | 8003 } |
7884 | 8004 |
7885 // Handle [] on String objects. | 8005 // Handle [] on String objects. |
7886 if (this->IsStringObjectWithCharacterAt(index)) return true; | 8006 if (this->IsStringObjectWithCharacterAt(index)) return true; |
7887 | 8007 |
7888 Object* pt = GetPrototype(); | 8008 Object* pt = GetPrototype(); |
7889 if (pt->IsNull()) return false; | 8009 if (pt->IsNull()) return false; |
8010 if (pt->IsJSProxy()) { | |
8011 // We need to follow the spec and simulate a call to [[GetOwnProperty]]. | |
8012 return JSProxy::cast(pt)->GetElementAttributeWithHandler( | |
8013 receiver, index) != ABSENT; | |
8014 } | |
7890 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); | 8015 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); |
7891 } | 8016 } |
7892 | 8017 |
7893 | 8018 |
7894 bool JSObject::HasElementWithInterceptor(JSReceiver* receiver, uint32_t index) { | 8019 bool JSObject::HasElementWithInterceptor(JSReceiver* receiver, uint32_t index) { |
7895 Isolate* isolate = GetIsolate(); | 8020 Isolate* isolate = GetIsolate(); |
7896 // Make sure that the top context does not change when doing | 8021 // Make sure that the top context does not change when doing |
7897 // callbacks or interceptor calls. | 8022 // callbacks or interceptor calls. |
7898 AssertNoContextChange ncc; | 8023 AssertNoContextChange ncc; |
7899 HandleScope scope(isolate); | 8024 HandleScope scope(isolate); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8136 if (HasElementInElements(arguments, kind, index)) return true; | 8261 if (HasElementInElements(arguments, kind, index)) return true; |
8137 break; | 8262 break; |
8138 } | 8263 } |
8139 } | 8264 } |
8140 | 8265 |
8141 // Handle [] on String objects. | 8266 // Handle [] on String objects. |
8142 if (this->IsStringObjectWithCharacterAt(index)) return true; | 8267 if (this->IsStringObjectWithCharacterAt(index)) return true; |
8143 | 8268 |
8144 Object* pt = GetPrototype(); | 8269 Object* pt = GetPrototype(); |
8145 if (pt->IsNull()) return false; | 8270 if (pt->IsNull()) return false; |
8271 if (pt->IsJSProxy()) { | |
8272 // We need to follow the spec and simulate a call to [[GetOwnProperty]]. | |
8273 return JSProxy::cast(pt)->GetElementAttributeWithHandler( | |
8274 receiver, index) != ABSENT; | |
8275 } | |
8146 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); | 8276 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); |
8147 } | 8277 } |
8148 | 8278 |
8149 | 8279 |
8150 MaybeObject* JSObject::SetElementWithInterceptor(uint32_t index, | 8280 MaybeObject* JSObject::SetElementWithInterceptor(uint32_t index, |
8151 Object* value, | 8281 Object* value, |
8152 StrictModeFlag strict_mode, | 8282 StrictModeFlag strict_mode, |
8153 bool check_prototype) { | 8283 bool check_prototype) { |
8154 Isolate* isolate = GetIsolate(); | 8284 Isolate* isolate = GetIsolate(); |
8155 // Make sure that the top context does not change when doing | 8285 // Make sure that the top context does not change when doing |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8568 ASSERT(elements()->IsFixedDoubleArray()); | 8698 ASSERT(elements()->IsFixedDoubleArray()); |
8569 Object* obj; | 8699 Object* obj; |
8570 { MaybeObject* maybe_obj = NormalizeElements(); | 8700 { MaybeObject* maybe_obj = NormalizeElements(); |
8571 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 8701 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
8572 } | 8702 } |
8573 ASSERT(HasDictionaryElements()); | 8703 ASSERT(HasDictionaryElements()); |
8574 return SetElement(index, value, strict_mode, check_prototype); | 8704 return SetElement(index, value, strict_mode, check_prototype); |
8575 } | 8705 } |
8576 | 8706 |
8577 | 8707 |
8708 MaybeObject* JSReceiver::SetElement(uint32_t index, | |
8709 Object* value, | |
8710 StrictModeFlag strict_mode, | |
8711 bool check_proto) { | |
8712 return IsJSProxy() | |
8713 ? JSProxy::cast(this)->SetElementWithHandler(index, value, strict_mode) | |
Rico
2011/09/12 11:21:18
4 space indention
rossberg
2011/09/13 16:10:25
Done.
| |
8714 : JSObject::cast(this)->SetElement(index, value, strict_mode, check_proto); | |
8715 } | |
8716 | |
8717 | |
8578 MaybeObject* JSObject::SetElement(uint32_t index, | 8718 MaybeObject* JSObject::SetElement(uint32_t index, |
8579 Object* value, | 8719 Object* value, |
8580 StrictModeFlag strict_mode, | 8720 StrictModeFlag strict_mode, |
8581 bool check_prototype) { | 8721 bool check_prototype) { |
8582 // Check access rights if needed. | 8722 // Check access rights if needed. |
8583 if (IsAccessCheckNeeded()) { | 8723 if (IsAccessCheckNeeded()) { |
8584 Heap* heap = GetHeap(); | 8724 Heap* heap = GetHeap(); |
8585 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) { | 8725 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) { |
8586 HandleScope scope(heap->isolate()); | 8726 HandleScope scope(heap->isolate()); |
8587 Handle<Object> value_handle(value); | 8727 Handle<Object> value_handle(value); |
(...skipping 3038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11626 if (break_point_objects()->IsUndefined()) return 0; | 11766 if (break_point_objects()->IsUndefined()) return 0; |
11627 // Single break point. | 11767 // Single break point. |
11628 if (!break_point_objects()->IsFixedArray()) return 1; | 11768 if (!break_point_objects()->IsFixedArray()) return 1; |
11629 // Multiple break points. | 11769 // Multiple break points. |
11630 return FixedArray::cast(break_point_objects())->length(); | 11770 return FixedArray::cast(break_point_objects())->length(); |
11631 } | 11771 } |
11632 #endif | 11772 #endif |
11633 | 11773 |
11634 | 11774 |
11635 } } // namespace v8::internal | 11775 } } // namespace v8::internal |
OLD | NEW |