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 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2226 }; | 2226 }; |
2227 bool has_exception; | 2227 bool has_exception; |
2228 Handle<Object> result = | 2228 Handle<Object> result = |
2229 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception); | 2229 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception); |
2230 if (has_exception) return Failure::Exception(); | 2230 if (has_exception) return Failure::Exception(); |
2231 | 2231 |
2232 return *value; | 2232 return *value; |
2233 } | 2233 } |
2234 | 2234 |
2235 | 2235 |
2236 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler( | |
2237 String* name_raw, DeleteMode mode) { | |
2238 Isolate* isolate = GetIsolate(); | |
2239 HandleScope scope; | |
Mads Ager (chromium)
2011/07/14 16:17:22
You should pass in the isolate to the HandleScope
rossberg
2011/07/15 08:47:40
Done, here and in a number of other places.
| |
2240 Handle<Object> receiver(this); | |
2241 Handle<Object> name(name_raw); | |
2242 Handle<Object> handler(this->handler()); | |
2243 | |
2244 // Extract trap function. | |
2245 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete"); | |
2246 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); | |
2247 if (trap->IsUndefined()) { | |
2248 Handle<Object> args[] = { handler, trap_name }; | |
2249 Handle<Object> error = isolate->factory()->NewTypeError( | |
2250 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); | |
2251 isolate->Throw(*error); | |
2252 return Failure::Exception(); | |
2253 } | |
2254 | |
2255 // Call trap function. | |
2256 Object** args[] = { name.location() }; | |
2257 bool has_exception; | |
2258 Handle<Object> result = | |
2259 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception); | |
2260 if (has_exception) return Failure::Exception(); | |
2261 | |
2262 Object* bool_result = result->ToBoolean(); | |
2263 if (mode != NORMAL_DELETION && bool_result == GetHeap()->false_value()) { | |
Mads Ager (chromium)
2011/07/14 16:17:22
Do we want this behavior for FORCE_DELETION as wel
rossberg
2011/07/15 08:47:40
Done.
| |
2264 Handle<Object> args[] = { handler, trap_name }; | |
2265 Handle<Object> error = isolate->factory()->NewTypeError( | |
2266 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); | |
2267 isolate->Throw(*error); | |
2268 return Failure::Exception(); | |
2269 } | |
2270 return bool_result; | |
2271 } | |
2272 | |
2273 | |
2236 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( | 2274 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( |
2237 JSReceiver* receiver_raw, | 2275 JSReceiver* receiver_raw, |
2238 String* name_raw, | 2276 String* name_raw, |
2239 bool* has_exception) { | 2277 bool* has_exception) { |
2240 Isolate* isolate = GetIsolate(); | 2278 Isolate* isolate = GetIsolate(); |
2241 HandleScope scope; | 2279 HandleScope scope; |
2242 Handle<JSReceiver> receiver(receiver_raw); | 2280 Handle<JSReceiver> receiver(receiver_raw); |
2243 Handle<Object> name(name_raw); | 2281 Handle<Object> name(name_raw); |
2244 Handle<Object> handler(this->handler()); | 2282 Handle<Object> handler(this->handler()); |
2245 | 2283 |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3172 return DeleteFastElement(index); | 3210 return DeleteFastElement(index); |
3173 } | 3211 } |
3174 } | 3212 } |
3175 break; | 3213 break; |
3176 } | 3214 } |
3177 } | 3215 } |
3178 return isolate->heap()->true_value(); | 3216 return isolate->heap()->true_value(); |
3179 } | 3217 } |
3180 | 3218 |
3181 | 3219 |
3220 MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) { | |
3221 if (IsJSProxy()) { | |
3222 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode); | |
3223 } else { | |
3224 return JSObject::cast(this)->DeleteProperty(name, mode); | |
3225 } | |
3226 } | |
3227 | |
3228 | |
3182 MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) { | 3229 MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) { |
3183 Isolate* isolate = GetIsolate(); | 3230 Isolate* isolate = GetIsolate(); |
3184 // ECMA-262, 3rd, 8.6.2.5 | 3231 // ECMA-262, 3rd, 8.6.2.5 |
3185 ASSERT(name->IsString()); | 3232 ASSERT(name->IsString()); |
3186 | 3233 |
3187 // Check access rights if needed. | 3234 // Check access rights if needed. |
3188 if (IsAccessCheckNeeded() && | 3235 if (IsAccessCheckNeeded() && |
3189 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { | 3236 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { |
3190 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); | 3237 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); |
3191 return isolate->heap()->false_value(); | 3238 return isolate->heap()->false_value(); |
(...skipping 7854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11046 } | 11093 } |
11047 } | 11094 } |
11048 | 11095 |
11049 // Update the number of elements. | 11096 // Update the number of elements. |
11050 ElementsRemoved(removed_entries); | 11097 ElementsRemoved(removed_entries); |
11051 } | 11098 } |
11052 | 11099 |
11053 | 11100 |
11054 template<typename Shape, typename Key> | 11101 template<typename Shape, typename Key> |
11055 Object* Dictionary<Shape, Key>::DeleteProperty(int entry, | 11102 Object* Dictionary<Shape, Key>::DeleteProperty(int entry, |
11056 JSObject::DeleteMode mode) { | 11103 JSReceiver::DeleteMode mode) { |
11057 Heap* heap = Dictionary<Shape, Key>::GetHeap(); | 11104 Heap* heap = Dictionary<Shape, Key>::GetHeap(); |
11058 PropertyDetails details = DetailsAt(entry); | 11105 PropertyDetails details = DetailsAt(entry); |
11059 // Ignore attributes if forcing a deletion. | 11106 // Ignore attributes if forcing a deletion. |
11060 if (details.IsDontDelete() && mode != JSObject::FORCE_DELETION) { | 11107 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) { |
11061 return heap->false_value(); | 11108 return heap->false_value(); |
11062 } | 11109 } |
11063 SetEntry(entry, heap->null_value(), heap->null_value()); | 11110 SetEntry(entry, heap->null_value(), heap->null_value()); |
11064 HashTable<Shape, Key>::ElementRemoved(); | 11111 HashTable<Shape, Key>::ElementRemoved(); |
11065 return heap->true_value(); | 11112 return heap->true_value(); |
11066 } | 11113 } |
11067 | 11114 |
11068 | 11115 |
11069 template<typename Shape, typename Key> | 11116 template<typename Shape, typename Key> |
11070 MaybeObject* Dictionary<Shape, Key>::Shrink(Key key) { | 11117 MaybeObject* Dictionary<Shape, Key>::Shrink(Key key) { |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11689 if (break_point_objects()->IsUndefined()) return 0; | 11736 if (break_point_objects()->IsUndefined()) return 0; |
11690 // Single beak point. | 11737 // Single beak point. |
11691 if (!break_point_objects()->IsFixedArray()) return 1; | 11738 if (!break_point_objects()->IsFixedArray()) return 1; |
11692 // Multiple break points. | 11739 // Multiple break points. |
11693 return FixedArray::cast(break_point_objects())->length(); | 11740 return FixedArray::cast(break_point_objects())->length(); |
11694 } | 11741 } |
11695 #endif | 11742 #endif |
11696 | 11743 |
11697 | 11744 |
11698 } } // namespace v8::internal | 11745 } } // namespace v8::internal |
OLD | NEW |