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 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 if (result->IsFound() && result->type() == HANDLER) { | 2189 if (result->IsFound() && result->type() == HANDLER) { |
2190 return JSProxy::cast(this)->SetPropertyWithHandler( | 2190 return JSProxy::cast(this)->SetPropertyWithHandler( |
2191 key, value, attributes, strict_mode); | 2191 key, value, attributes, strict_mode); |
2192 } else { | 2192 } else { |
2193 return JSObject::cast(this)->SetPropertyForResult( | 2193 return JSObject::cast(this)->SetPropertyForResult( |
2194 result, key, value, attributes, strict_mode); | 2194 result, key, value, attributes, strict_mode); |
2195 } | 2195 } |
2196 } | 2196 } |
2197 | 2197 |
2198 | 2198 |
| 2199 bool JSProxy::HasPropertyWithHandler(String* name_raw) { |
| 2200 Isolate* isolate = GetIsolate(); |
| 2201 HandleScope scope(isolate); |
| 2202 Handle<Object> receiver(this); |
| 2203 Handle<Object> name(name_raw); |
| 2204 Handle<Object> handler(this->handler()); |
| 2205 |
| 2206 // Extract trap function. |
| 2207 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("has"); |
| 2208 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); |
| 2209 if (trap->IsUndefined()) { |
| 2210 trap = isolate->derived_has_trap(); |
| 2211 } |
| 2212 |
| 2213 // Call trap function. |
| 2214 Object** args[] = { name.location() }; |
| 2215 bool has_exception; |
| 2216 Handle<Object> result = |
| 2217 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception); |
| 2218 if (has_exception) return Failure::Exception(); |
| 2219 |
| 2220 return result->ToBoolean()->IsTrue(); |
| 2221 } |
| 2222 |
| 2223 |
2199 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyWithHandler( | 2224 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyWithHandler( |
2200 String* name_raw, | 2225 String* name_raw, |
2201 Object* value_raw, | 2226 Object* value_raw, |
2202 PropertyAttributes attributes, | 2227 PropertyAttributes attributes, |
2203 StrictModeFlag strict_mode) { | 2228 StrictModeFlag strict_mode) { |
2204 Isolate* isolate = GetIsolate(); | 2229 Isolate* isolate = GetIsolate(); |
2205 HandleScope scope(isolate); | 2230 HandleScope scope(isolate); |
2206 Handle<Object> receiver(this); | 2231 Handle<Object> receiver(this); |
2207 Handle<Object> name(name_raw); | 2232 Handle<Object> name(name_raw); |
2208 Handle<Object> value(value_raw); | 2233 Handle<Object> value(value_raw); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2294 Handle<Object> result = | 2319 Handle<Object> result = |
2295 Execution::Call(trap, handler, ARRAY_SIZE(args), args, has_exception); | 2320 Execution::Call(trap, handler, ARRAY_SIZE(args), args, has_exception); |
2296 if (has_exception) return NONE; | 2321 if (has_exception) return NONE; |
2297 | 2322 |
2298 // TODO(rossberg): convert result to PropertyAttributes | 2323 // TODO(rossberg): convert result to PropertyAttributes |
2299 USE(result); | 2324 USE(result); |
2300 return NONE; | 2325 return NONE; |
2301 } | 2326 } |
2302 | 2327 |
2303 | 2328 |
| 2329 void JSProxy::Fix() { |
| 2330 Isolate* isolate = GetIsolate(); |
| 2331 HandleScope scope(isolate); |
| 2332 Handle<JSProxy> self(this); |
| 2333 |
| 2334 isolate->factory()->BecomeJSObject(self); |
| 2335 ASSERT(IsJSObject()); |
| 2336 // TODO(rossberg): recognize function proxies. |
| 2337 } |
| 2338 |
| 2339 |
| 2340 |
2304 MaybeObject* JSObject::SetPropertyForResult(LookupResult* result, | 2341 MaybeObject* JSObject::SetPropertyForResult(LookupResult* result, |
2305 String* name, | 2342 String* name, |
2306 Object* value, | 2343 Object* value, |
2307 PropertyAttributes attributes, | 2344 PropertyAttributes attributes, |
2308 StrictModeFlag strict_mode) { | 2345 StrictModeFlag strict_mode) { |
2309 Heap* heap = GetHeap(); | 2346 Heap* heap = GetHeap(); |
2310 // Make sure that the top context does not change when doing callbacks or | 2347 // Make sure that the top context does not change when doing callbacks or |
2311 // interceptor calls. | 2348 // interceptor calls. |
2312 AssertNoContextChange ncc; | 2349 AssertNoContextChange ncc; |
2313 | 2350 |
(...skipping 9438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11752 if (break_point_objects()->IsUndefined()) return 0; | 11789 if (break_point_objects()->IsUndefined()) return 0; |
11753 // Single beak point. | 11790 // Single beak point. |
11754 if (!break_point_objects()->IsFixedArray()) return 1; | 11791 if (!break_point_objects()->IsFixedArray()) return 1; |
11755 // Multiple break points. | 11792 // Multiple break points. |
11756 return FixedArray::cast(break_point_objects())->length(); | 11793 return FixedArray::cast(break_point_objects())->length(); |
11757 } | 11794 } |
11758 #endif | 11795 #endif |
11759 | 11796 |
11760 | 11797 |
11761 } } // namespace v8::internal | 11798 } } // namespace v8::internal |
OLD | NEW |