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 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 | 2520 |
2521 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyWithHandlerIfDefiningSetter( | 2521 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyWithHandlerIfDefiningSetter( |
2522 String* name_raw, | 2522 String* name_raw, |
2523 Object* value_raw, | 2523 Object* value_raw, |
2524 PropertyAttributes attributes, | 2524 PropertyAttributes attributes, |
2525 StrictModeFlag strict_mode, | 2525 StrictModeFlag strict_mode, |
2526 bool* found) { | 2526 bool* found) { |
2527 *found = true; // except where defined otherwise... | 2527 *found = true; // except where defined otherwise... |
2528 Isolate* isolate = GetHeap()->isolate(); | 2528 Isolate* isolate = GetHeap()->isolate(); |
2529 Handle<JSProxy> proxy(this); | 2529 Handle<JSProxy> proxy(this); |
| 2530 Handle<Object> handler(this->handler()); // Trap might morph proxy. |
2530 Handle<String> name(name_raw); | 2531 Handle<String> name(name_raw); |
2531 Handle<Object> value(value_raw); | 2532 Handle<Object> value(value_raw); |
2532 Handle<Object> args[] = { name }; | 2533 Handle<Object> args[] = { name }; |
2533 Handle<Object> result = proxy->CallTrap( | 2534 Handle<Object> result = proxy->CallTrap( |
2534 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); | 2535 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); |
2535 if (isolate->has_pending_exception()) return Failure::Exception(); | 2536 if (isolate->has_pending_exception()) return Failure::Exception(); |
2536 | 2537 |
2537 if (!result->IsUndefined()) { | 2538 if (!result->IsUndefined()) { |
2538 // The proxy handler cares about this property. | 2539 // The proxy handler cares about this property. |
2539 // Check whether it is virtualized as an accessor. | 2540 // Check whether it is virtualized as an accessor. |
2540 // Emulate [[GetProperty]] semantics for proxies. | 2541 // Emulate [[GetProperty]] semantics for proxies. |
2541 bool has_pending_exception; | 2542 bool has_pending_exception; |
2542 Handle<Object> argv[] = { result }; | 2543 Handle<Object> argv[] = { result }; |
2543 Handle<Object> desc = | 2544 Handle<Object> desc = |
2544 Execution::Call(isolate->to_complete_property_descriptor(), result, | 2545 Execution::Call(isolate->to_complete_property_descriptor(), result, |
2545 ARRAY_SIZE(argv), argv, &has_pending_exception); | 2546 ARRAY_SIZE(argv), argv, &has_pending_exception); |
2546 if (has_pending_exception) return Failure::Exception(); | 2547 if (has_pending_exception) return Failure::Exception(); |
2547 | 2548 |
2548 Handle<String> conf_name = | 2549 Handle<String> conf_name = |
2549 isolate->factory()->LookupAsciiSymbol("configurable_"); | 2550 isolate->factory()->LookupAsciiSymbol("configurable_"); |
2550 Handle<Object> configurable(v8::internal::GetProperty(desc, conf_name)); | 2551 Handle<Object> configurable(v8::internal::GetProperty(desc, conf_name)); |
2551 ASSERT(!isolate->has_pending_exception()); | 2552 ASSERT(!isolate->has_pending_exception()); |
2552 if (configurable->IsFalse()) { | 2553 if (configurable->IsFalse()) { |
2553 Handle<Object> args[] = { Handle<Object>(proxy->handler()), proxy, name }; | 2554 Handle<String> trap = |
| 2555 isolate->factory()->LookupAsciiSymbol("getPropertyDescriptor"); |
| 2556 Handle<Object> args[] = { handler, trap, name }; |
2554 Handle<Object> error = isolate->factory()->NewTypeError( | 2557 Handle<Object> error = isolate->factory()->NewTypeError( |
2555 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); | 2558 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); |
2556 return isolate->Throw(*error); | 2559 return isolate->Throw(*error); |
2557 } | 2560 } |
2558 ASSERT(configurable->IsTrue()); | 2561 ASSERT(configurable->IsTrue()); |
2559 | 2562 |
2560 // Check for AccessorDescriptor. | 2563 // Check for AccessorDescriptor. |
2561 Handle<String> set_name = isolate->factory()->LookupAsciiSymbol("set_"); | 2564 Handle<String> set_name = isolate->factory()->LookupAsciiSymbol("set_"); |
2562 Handle<Object> setter(v8::internal::GetProperty(desc, set_name)); | 2565 Handle<Object> setter(v8::internal::GetProperty(desc, set_name)); |
2563 ASSERT(!isolate->has_pending_exception()); | 2566 ASSERT(!isolate->has_pending_exception()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2623 return JSProxy::DeletePropertyWithHandler(*name, mode); | 2626 return JSProxy::DeletePropertyWithHandler(*name, mode); |
2624 } | 2627 } |
2625 | 2628 |
2626 | 2629 |
2627 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( | 2630 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( |
2628 JSReceiver* receiver_raw, | 2631 JSReceiver* receiver_raw, |
2629 String* name_raw) { | 2632 String* name_raw) { |
2630 Isolate* isolate = GetIsolate(); | 2633 Isolate* isolate = GetIsolate(); |
2631 HandleScope scope(isolate); | 2634 HandleScope scope(isolate); |
2632 Handle<JSProxy> proxy(this); | 2635 Handle<JSProxy> proxy(this); |
| 2636 Handle<Object> handler(this->handler()); // Trap might morph proxy. |
2633 Handle<JSReceiver> receiver(receiver_raw); | 2637 Handle<JSReceiver> receiver(receiver_raw); |
2634 Handle<Object> name(name_raw); | 2638 Handle<Object> name(name_raw); |
2635 | 2639 |
2636 Handle<Object> args[] = { name }; | 2640 Handle<Object> args[] = { name }; |
2637 Handle<Object> result = CallTrap( | 2641 Handle<Object> result = CallTrap( |
2638 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); | 2642 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); |
2639 if (isolate->has_pending_exception()) return NONE; | 2643 if (isolate->has_pending_exception()) return NONE; |
2640 | 2644 |
2641 if (result->IsUndefined()) return ABSENT; | 2645 if (result->IsUndefined()) return ABSENT; |
2642 | 2646 |
2643 bool has_pending_exception; | 2647 bool has_pending_exception; |
2644 Handle<Object> argv[] = { result }; | 2648 Handle<Object> argv[] = { result }; |
2645 Handle<Object> desc = | 2649 Handle<Object> desc = |
2646 Execution::Call(isolate->to_complete_property_descriptor(), result, | 2650 Execution::Call(isolate->to_complete_property_descriptor(), result, |
2647 ARRAY_SIZE(argv), argv, &has_pending_exception); | 2651 ARRAY_SIZE(argv), argv, &has_pending_exception); |
2648 if (has_pending_exception) return NONE; | 2652 if (has_pending_exception) return NONE; |
2649 | 2653 |
2650 // Convert result to PropertyAttributes. | 2654 // Convert result to PropertyAttributes. |
2651 Handle<String> enum_n = isolate->factory()->LookupAsciiSymbol("enumerable"); | 2655 Handle<String> enum_n = isolate->factory()->LookupAsciiSymbol("enumerable"); |
2652 Handle<Object> enumerable(v8::internal::GetProperty(desc, enum_n)); | 2656 Handle<Object> enumerable(v8::internal::GetProperty(desc, enum_n)); |
2653 if (isolate->has_pending_exception()) return NONE; | 2657 if (isolate->has_pending_exception()) return NONE; |
2654 Handle<String> conf_n = isolate->factory()->LookupAsciiSymbol("configurable"); | 2658 Handle<String> conf_n = isolate->factory()->LookupAsciiSymbol("configurable"); |
2655 Handle<Object> configurable(v8::internal::GetProperty(desc, conf_n)); | 2659 Handle<Object> configurable(v8::internal::GetProperty(desc, conf_n)); |
2656 if (isolate->has_pending_exception()) return NONE; | 2660 if (isolate->has_pending_exception()) return NONE; |
2657 Handle<String> writ_n = isolate->factory()->LookupAsciiSymbol("writable"); | 2661 Handle<String> writ_n = isolate->factory()->LookupAsciiSymbol("writable"); |
2658 Handle<Object> writable(v8::internal::GetProperty(desc, writ_n)); | 2662 Handle<Object> writable(v8::internal::GetProperty(desc, writ_n)); |
2659 if (isolate->has_pending_exception()) return NONE; | 2663 if (isolate->has_pending_exception()) return NONE; |
2660 | 2664 |
2661 if (configurable->IsFalse()) { | 2665 if (configurable->IsFalse()) { |
2662 Handle<Object> args[] = { Handle<Object>(proxy->handler()), proxy, name }; | 2666 Handle<String> trap = |
| 2667 isolate->factory()->LookupAsciiSymbol("getPropertyDescriptor"); |
| 2668 Handle<Object> args[] = { handler, trap, name }; |
2663 Handle<Object> error = isolate->factory()->NewTypeError( | 2669 Handle<Object> error = isolate->factory()->NewTypeError( |
2664 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); | 2670 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); |
2665 isolate->Throw(*error); | 2671 isolate->Throw(*error); |
2666 return NONE; | 2672 return NONE; |
2667 } | 2673 } |
2668 | 2674 |
2669 int attributes = NONE; | 2675 int attributes = NONE; |
2670 if (enumerable->ToBoolean()->IsFalse()) attributes |= DONT_ENUM; | 2676 if (enumerable->ToBoolean()->IsFalse()) attributes |= DONT_ENUM; |
2671 if (configurable->ToBoolean()->IsFalse()) attributes |= DONT_DELETE; | 2677 if (configurable->ToBoolean()->IsFalse()) attributes |= DONT_DELETE; |
2672 if (writable->ToBoolean()->IsFalse()) attributes |= READ_ONLY; | 2678 if (writable->ToBoolean()->IsFalse()) attributes |= READ_ONLY; |
(...skipping 9589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12262 if (break_point_objects()->IsUndefined()) return 0; | 12268 if (break_point_objects()->IsUndefined()) return 0; |
12263 // Single break point. | 12269 // Single break point. |
12264 if (!break_point_objects()->IsFixedArray()) return 1; | 12270 if (!break_point_objects()->IsFixedArray()) return 1; |
12265 // Multiple break points. | 12271 // Multiple break points. |
12266 return FixedArray::cast(break_point_objects())->length(); | 12272 return FixedArray::cast(break_point_objects())->length(); |
12267 } | 12273 } |
12268 #endif // ENABLE_DEBUGGER_SUPPORT | 12274 #endif // ENABLE_DEBUGGER_SUPPORT |
12269 | 12275 |
12270 | 12276 |
12271 } } // namespace v8::internal | 12277 } } // namespace v8::internal |
OLD | NEW |