| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4443 break; | 4443 break; |
| 4444 } | 4444 } |
| 4445 } | 4445 } |
| 4446 | 4446 |
| 4447 AccessorPair* accessors; | 4447 AccessorPair* accessors; |
| 4448 { MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair(); | 4448 { MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair(); |
| 4449 if (!maybe_accessors->To(&accessors)) return maybe_accessors; | 4449 if (!maybe_accessors->To(&accessors)) return maybe_accessors; |
| 4450 } | 4450 } |
| 4451 accessors->set(is_getter, fun); | 4451 accessors->set(is_getter, fun); |
| 4452 | 4452 |
| 4453 { MaybeObject* maybe_ok = SetElementCallback(index, accessors, attributes); | 4453 return SetElementCallback(index, accessors, attributes); |
| 4454 if (maybe_ok->IsFailure()) return maybe_ok; | |
| 4455 } | |
| 4456 return GetHeap()->undefined_value(); | |
| 4457 } | 4454 } |
| 4458 | 4455 |
| 4459 | 4456 |
| 4460 MaybeObject* JSObject::DefinePropertyAccessor(String* name, | 4457 MaybeObject* JSObject::DefinePropertyAccessor(String* name, |
| 4461 bool is_getter, | 4458 bool is_getter, |
| 4462 Object* fun, | 4459 Object* fun, |
| 4463 PropertyAttributes attributes) { | 4460 PropertyAttributes attributes) { |
| 4464 // Lookup the name. | 4461 // Lookup the name. |
| 4465 LookupResult result(GetHeap()->isolate()); | 4462 LookupResult result(GetHeap()->isolate()); |
| 4466 LocalLookupRealNamedProperty(name, &result); | 4463 LocalLookupRealNamedProperty(name, &result); |
| 4467 if (result.IsFound()) { | 4464 if (result.IsFound()) { |
| 4468 // TODO(mstarzinger): We should check for result.IsDontDelete() here once | 4465 // TODO(mstarzinger): We should check for result.IsDontDelete() here once |
| 4469 // we only call into the runtime once to set both getter and setter. | 4466 // we only call into the runtime once to set both getter and setter. |
| 4470 if (result.type() == CALLBACKS) { | 4467 if (result.type() == CALLBACKS) { |
| 4471 Object* obj = result.GetCallbackObject(); | 4468 Object* obj = result.GetCallbackObject(); |
| 4472 // Need to preserve old getters/setters. | 4469 // Need to preserve old getters/setters. |
| 4473 if (obj->IsAccessorPair()) { | 4470 if (obj->IsAccessorPair()) { |
| 4474 AccessorPair* copy; | 4471 AccessorPair* copy; |
| 4475 { MaybeObject* maybe_copy = | 4472 { MaybeObject* maybe_copy = |
| 4476 AccessorPair::cast(obj)->CopyWithoutTransitions(); | 4473 AccessorPair::cast(obj)->CopyWithoutTransitions(); |
| 4477 if (!maybe_copy->To(©)) return maybe_copy; | 4474 if (!maybe_copy->To(©)) return maybe_copy; |
| 4478 } | 4475 } |
| 4479 copy->set(is_getter, fun); | 4476 copy->set(is_getter, fun); |
| 4480 // Use set to update attributes. | 4477 // Use set to update attributes. |
| 4481 { MaybeObject* maybe_ok = SetPropertyCallback(name, copy, attributes); | 4478 return SetPropertyCallback(name, copy, attributes); |
| 4482 if (maybe_ok->IsFailure()) return maybe_ok; | |
| 4483 } | |
| 4484 return GetHeap()->undefined_value(); | |
| 4485 } | 4479 } |
| 4486 } | 4480 } |
| 4487 } | 4481 } |
| 4488 | 4482 |
| 4489 AccessorPair* accessors; | 4483 AccessorPair* accessors; |
| 4490 { MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair(); | 4484 { MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair(); |
| 4491 if (!maybe_accessors->To(&accessors)) return maybe_accessors; | 4485 if (!maybe_accessors->To(&accessors)) return maybe_accessors; |
| 4492 } | 4486 } |
| 4493 accessors->set(is_getter, fun); | 4487 accessors->set(is_getter, fun); |
| 4494 | 4488 |
| 4495 { MaybeObject* maybe_ok = SetPropertyCallback(name, accessors, attributes); | 4489 return SetPropertyCallback(name, accessors, attributes); |
| 4496 if (maybe_ok->IsFailure()) return maybe_ok; | |
| 4497 } | |
| 4498 return GetHeap()->undefined_value(); | |
| 4499 } | 4490 } |
| 4500 | 4491 |
| 4501 | 4492 |
| 4502 bool JSObject::CanSetCallback(String* name) { | 4493 bool JSObject::CanSetCallback(String* name) { |
| 4503 ASSERT(!IsAccessCheckNeeded() || | 4494 ASSERT(!IsAccessCheckNeeded() || |
| 4504 GetIsolate()->MayNamedAccess(this, name, v8::ACCESS_SET)); | 4495 GetIsolate()->MayNamedAccess(this, name, v8::ACCESS_SET)); |
| 4505 | 4496 |
| 4506 // Check if there is an API defined callback object which prohibits | 4497 // Check if there is an API defined callback object which prohibits |
| 4507 // callback overwriting in this object or it's prototype chain. | 4498 // callback overwriting in this object or it's prototype chain. |
| 4508 // This mechanism is needed for instance in a browser setting, where | 4499 // This mechanism is needed for instance in a browser setting, where |
| (...skipping 8634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13143 if (break_point_objects()->IsUndefined()) return 0; | 13134 if (break_point_objects()->IsUndefined()) return 0; |
| 13144 // Single break point. | 13135 // Single break point. |
| 13145 if (!break_point_objects()->IsFixedArray()) return 1; | 13136 if (!break_point_objects()->IsFixedArray()) return 1; |
| 13146 // Multiple break points. | 13137 // Multiple break points. |
| 13147 return FixedArray::cast(break_point_objects())->length(); | 13138 return FixedArray::cast(break_point_objects())->length(); |
| 13148 } | 13139 } |
| 13149 #endif // ENABLE_DEBUGGER_SUPPORT | 13140 #endif // ENABLE_DEBUGGER_SUPPORT |
| 13150 | 13141 |
| 13151 | 13142 |
| 13152 } } // namespace v8::internal | 13143 } } // namespace v8::internal |
| OLD | NEW |