| OLD | NEW | 
|     1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |     1 // Copyright 2006-2008 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   140   ASSERT(holder != NULL);  // cannot handle null or undefined. |   140   ASSERT(holder != NULL);  // cannot handle null or undefined. | 
|   141   JSObject::cast(holder)->Lookup(name, result); |   141   JSObject::cast(holder)->Lookup(name, result); | 
|   142 } |   142 } | 
|   143  |   143  | 
|   144  |   144  | 
|   145 Object* Object::GetPropertyWithReceiver(Object* receiver, |   145 Object* Object::GetPropertyWithReceiver(Object* receiver, | 
|   146                                         String* name, |   146                                         String* name, | 
|   147                                         PropertyAttributes* attributes) { |   147                                         PropertyAttributes* attributes) { | 
|   148   LookupResult result; |   148   LookupResult result; | 
|   149   Lookup(name, &result); |   149   Lookup(name, &result); | 
|   150   return GetProperty(receiver, &result, name, attributes); |   150   Object* value = GetProperty(receiver, &result, name, attributes); | 
 |   151   ASSERT(*attributes <= ABSENT); | 
 |   152   return value; | 
|   151 } |   153 } | 
|   152  |   154  | 
|   153  |   155  | 
|   154 Object* Object::GetPropertyWithCallback(Object* receiver, |   156 Object* Object::GetPropertyWithCallback(Object* receiver, | 
|   155                                         Object* structure, |   157                                         Object* structure, | 
|   156                                         String* name, |   158                                         String* name, | 
|   157                                         Object* holder) { |   159                                         Object* holder) { | 
|   158   // To accommodate both the old and the new api we switch on the |   160   // To accommodate both the old and the new api we switch on the | 
|   159   // data structure used to store the callbacks.  Eventually proxy |   161   // data structure used to store the callbacks.  Eventually proxy | 
|   160   // callbacks should be phased out. |   162   // callbacks should be phased out. | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   208     // Getter is not a function. |   210     // Getter is not a function. | 
|   209     return Heap::undefined_value(); |   211     return Heap::undefined_value(); | 
|   210   } |   212   } | 
|   211  |   213  | 
|   212   UNREACHABLE(); |   214   UNREACHABLE(); | 
|   213   return 0; |   215   return 0; | 
|   214 } |   216 } | 
|   215  |   217  | 
|   216  |   218  | 
|   217 // Only deal with CALLBACKS and INTERCEPTOR |   219 // Only deal with CALLBACKS and INTERCEPTOR | 
|   218 Object* JSObject::GetPropertyWithFailedAccessCheck(Object* receiver, |   220 Object* JSObject::GetPropertyWithFailedAccessCheck( | 
|   219                                                    LookupResult* result, |   221     Object* receiver, | 
|   220                                                    String* name) { |   222     LookupResult* result, | 
 |   223     String* name, | 
 |   224     PropertyAttributes* attributes) { | 
|   221   if (result->IsValid()) { |   225   if (result->IsValid()) { | 
|   222     switch (result->type()) { |   226     switch (result->type()) { | 
|   223       case CALLBACKS: { |   227       case CALLBACKS: { | 
|   224         // Only allow API accessors. |   228         // Only allow API accessors. | 
|   225         Object* obj = result->GetCallbackObject(); |   229         Object* obj = result->GetCallbackObject(); | 
|   226         if (obj->IsAccessorInfo()) { |   230         if (obj->IsAccessorInfo()) { | 
|   227           AccessorInfo* info = AccessorInfo::cast(obj); |   231           AccessorInfo* info = AccessorInfo::cast(obj); | 
|   228           if (info->all_can_read()) { |   232           if (info->all_can_read()) { | 
 |   233             *attributes = result->GetAttributes(); | 
|   229             return GetPropertyWithCallback(receiver, |   234             return GetPropertyWithCallback(receiver, | 
|   230                                            result->GetCallbackObject(), |   235                                            result->GetCallbackObject(), | 
|   231                                            name, |   236                                            name, | 
|   232                                            result->holder()); |   237                                            result->holder()); | 
|   233           } |   238           } | 
|   234         } |   239         } | 
|   235         break; |   240         break; | 
|   236       } |   241       } | 
|   237       case NORMAL: |   242       case NORMAL: | 
|   238       case FIELD: |   243       case FIELD: | 
|   239       case CONSTANT_FUNCTION: { |   244       case CONSTANT_FUNCTION: { | 
|   240         // Search ALL_CAN_READ accessors in prototype chain. |   245         // Search ALL_CAN_READ accessors in prototype chain. | 
|   241         LookupResult r; |   246         LookupResult r; | 
|   242         result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); |   247         result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); | 
|   243         if (r.IsValid()) { |   248         if (r.IsValid()) { | 
|   244           return GetPropertyWithFailedAccessCheck(receiver, &r, name); |   249           return GetPropertyWithFailedAccessCheck(receiver, | 
 |   250                                                   &r, | 
 |   251                                                   name, | 
 |   252                                                   attributes); | 
|   245         } |   253         } | 
|   246         break; |   254         break; | 
|   247       } |   255       } | 
|   248       case INTERCEPTOR: { |   256       case INTERCEPTOR: { | 
|   249         // If the object has an interceptor, try real named properties. |   257         // If the object has an interceptor, try real named properties. | 
|   250         // No access check in GetPropertyAttributeWithInterceptor. |   258         // No access check in GetPropertyAttributeWithInterceptor. | 
|   251         LookupResult r; |   259         LookupResult r; | 
|   252         result->holder()->LookupRealNamedProperty(name, &r); |   260         result->holder()->LookupRealNamedProperty(name, &r); | 
|   253         if (r.IsValid()) { |   261         if (r.IsValid()) { | 
|   254           return GetPropertyWithFailedAccessCheck(receiver, &r, name); |   262           return GetPropertyWithFailedAccessCheck(receiver, | 
 |   263                                                   &r, | 
 |   264                                                   name, | 
 |   265                                                   attributes); | 
|   255         } |   266         } | 
|   256         break; |  | 
|   257       } |   267       } | 
|   258       default: { |   268       default: { | 
|   259         break; |   269         break; | 
|   260       } |   270       } | 
|   261     } |   271     } | 
|   262   } |   272   } | 
|   263  |   273  | 
 |   274   // No accessible property found. | 
 |   275   *attributes = ABSENT; | 
|   264   Top::ReportFailedAccessCheck(this, v8::ACCESS_GET); |   276   Top::ReportFailedAccessCheck(this, v8::ACCESS_GET); | 
|   265   return Heap::undefined_value(); |   277   return Heap::undefined_value(); | 
|   266 } |   278 } | 
|   267  |   279  | 
|   268  |   280  | 
|   269 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( |   281 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( | 
|   270     Object* receiver, |   282     Object* receiver, | 
|   271     LookupResult* result, |   283     LookupResult* result, | 
|   272     String* name, |   284     String* name, | 
|   273     bool continue_search) { |   285     bool continue_search) { | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   395   for (Object* current = this; true; current = current->GetPrototype()) { |   407   for (Object* current = this; true; current = current->GetPrototype()) { | 
|   396     if (current->IsAccessCheckNeeded()) { |   408     if (current->IsAccessCheckNeeded()) { | 
|   397       // Check if we're allowed to read from the current object. Note |   409       // Check if we're allowed to read from the current object. Note | 
|   398       // that even though we may not actually end up loading the named |   410       // that even though we may not actually end up loading the named | 
|   399       // property from the current object, we still check that we have |   411       // property from the current object, we still check that we have | 
|   400       // access to it. |   412       // access to it. | 
|   401       JSObject* checked = JSObject::cast(current); |   413       JSObject* checked = JSObject::cast(current); | 
|   402       if (!Top::MayNamedAccess(checked, name, v8::ACCESS_GET)) { |   414       if (!Top::MayNamedAccess(checked, name, v8::ACCESS_GET)) { | 
|   403         return checked->GetPropertyWithFailedAccessCheck(receiver, |   415         return checked->GetPropertyWithFailedAccessCheck(receiver, | 
|   404                                                          result, |   416                                                          result, | 
|   405                                                          name); |   417                                                          name, | 
 |   418                                                          attributes); | 
|   406       } |   419       } | 
|   407     } |   420     } | 
|   408     // Stop traversing the chain once we reach the last object in the |   421     // Stop traversing the chain once we reach the last object in the | 
|   409     // chain; either the holder of the result or null in case of an |   422     // chain; either the holder of the result or null in case of an | 
|   410     // absent property. |   423     // absent property. | 
|   411     if (current == last) break; |   424     if (current == last) break; | 
|   412   } |   425   } | 
|   413  |   426  | 
|   414   if (!result->IsProperty()) { |   427   if (!result->IsProperty()) { | 
|   415     *attributes = ABSENT; |   428     *attributes = ABSENT; | 
| (...skipping 6538 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  6954   // No break point. |  6967   // No break point. | 
|  6955   if (break_point_objects()->IsUndefined()) return 0; |  6968   if (break_point_objects()->IsUndefined()) return 0; | 
|  6956   // Single beak point. |  6969   // Single beak point. | 
|  6957   if (!break_point_objects()->IsFixedArray()) return 1; |  6970   if (!break_point_objects()->IsFixedArray()) return 1; | 
|  6958   // Multiple break points. |  6971   // Multiple break points. | 
|  6959   return FixedArray::cast(break_point_objects())->length(); |  6972   return FixedArray::cast(break_point_objects())->length(); | 
|  6960 } |  6973 } | 
|  6961  |  6974  | 
|  6962  |  6975  | 
|  6963 } }  // namespace v8::internal |  6976 } }  // namespace v8::internal | 
| OLD | NEW |