Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(920)

Side by Side Diff: src/property.h

Issue 93066: Built-in JSON support (Closed)
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 bool IsProperty() { 238 bool IsProperty() {
239 return IsValid() && type() < FIRST_PHANTOM_PROPERTY_TYPE; 239 return IsValid() && type() < FIRST_PHANTOM_PROPERTY_TYPE;
240 } 240 }
241 241
242 bool IsCacheable() { return cacheable_; } 242 bool IsCacheable() { return cacheable_; }
243 void DisallowCaching() { cacheable_ = false; } 243 void DisallowCaching() { cacheable_ = false; }
244 244
245 // Tells whether the value needs to be loaded. 245 // Tells whether the value needs to be loaded.
246 bool IsLoaded() { 246 bool IsLoaded() {
247 if (lookup_type_ == DESCRIPTOR_TYPE || lookup_type_ == DICTIONARY_TYPE) { 247 if (lookup_type_ == DESCRIPTOR_TYPE || lookup_type_ == DICTIONARY_TYPE) {
248 Object* value = GetValue(); 248 Object* target = GetLazyValue();
249 if (value->IsJSFunction()) { 249 return !target->IsJSObject() || JSObject::cast(target)->IsLoaded();
250 return JSFunction::cast(value)->IsLoaded();
251 }
252 } 250 }
253 return true; 251 return true;
254 } 252 }
255 253
254 Object* GetLazyValue() {
255 switch (type()) {
256 case FIELD:
257 return holder()->FastPropertyAt(GetFieldIndex());
258 case NORMAL:
259 return holder()->property_dictionary()->ValueAt(GetDictionaryEntry());
260 case CONSTANT_FUNCTION:
261 return GetConstantFunction();
262 default:
263 return Smi::FromInt(0);
264 }
265 }
266
256 Map* GetTransitionMap() { 267 Map* GetTransitionMap() {
257 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 268 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
258 ASSERT(type() == MAP_TRANSITION); 269 ASSERT(type() == MAP_TRANSITION);
259 return Map::cast(GetValue()); 270 return Map::cast(GetValue());
260 } 271 }
261 272
262 int GetFieldIndex() { 273 int GetFieldIndex() {
263 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 274 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
264 ASSERT(type() == FIELD); 275 ASSERT(type() == FIELD);
265 return Descriptor::IndexFromValue(GetValue()); 276 return Descriptor::IndexFromValue(GetValue());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 398
388 // Append a descriptor to this stream. 399 // Append a descriptor to this stream.
389 void Write(Descriptor* desc); 400 void Write(Descriptor* desc);
390 // Read a descriptor from the reader and append it to this stream. 401 // Read a descriptor from the reader and append it to this stream.
391 void WriteFrom(DescriptorReader* reader); 402 void WriteFrom(DescriptorReader* reader);
392 }; 403 };
393 404
394 } } // namespace v8::internal 405 } } // namespace v8::internal
395 406
396 #endif // V8_PROPERTY_H_ 407 #endif // V8_PROPERTY_H_
OLDNEW
« src/objects.h ('K') | « src/objects-inl.h ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698