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

Side by Side Diff: src/property.h

Issue 149458: Remove the descriptor stream abstractions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 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 | Annotate | Revision Log
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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 317 }
318 318
319 private: 319 private:
320 JSObject* holder_; 320 JSObject* holder_;
321 int number_; 321 int number_;
322 bool cacheable_; 322 bool cacheable_;
323 PropertyDetails details_; 323 PropertyDetails details_;
324 }; 324 };
325 325
326 326
327 // The DescriptorStream is an abstraction for iterating over a map's
328 // instance descriptors.
329 class DescriptorStream BASE_EMBEDDED {
330 public:
331 explicit DescriptorStream(DescriptorArray* descriptors, int pos) {
332 descriptors_ = descriptors;
333 pos_ = pos;
334 limit_ = descriptors_->number_of_descriptors();
335 }
336
337 // Tells whether we have reached the end of the steam.
338 bool eos() { return pos_ >= limit_; }
339
340 int next_position() { return pos_ + 1; }
341 void advance() { pos_ = next_position(); }
342
343 protected:
344 DescriptorArray* descriptors_;
345 int pos_; // Current position.
346 int limit_; // Limit for position.
347 };
348
349
350 class DescriptorReader: public DescriptorStream {
351 public:
352 explicit DescriptorReader(DescriptorArray* descriptors, int pos = 0)
353 : DescriptorStream(descriptors, pos) {}
354
355 String* GetKey() { return descriptors_->GetKey(pos_); }
356 Object* GetValue() { return descriptors_->GetValue(pos_); }
357 PropertyDetails GetDetails() {
358 return PropertyDetails(descriptors_->GetDetails(pos_));
359 }
360
361 int GetFieldIndex() { return Descriptor::IndexFromValue(GetValue()); }
362
363 bool IsDontEnum() { return GetDetails().IsDontEnum(); }
364
365 PropertyType type() { return GetDetails().type(); }
366
367 // Tells whether the type is a transition.
368 bool IsTransition() {
369 PropertyType t = type();
370 ASSERT(t != INTERCEPTOR);
371 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION;
372 }
373
374 bool IsNullDescriptor() {
375 return type() == NULL_DESCRIPTOR;
376 }
377
378 bool IsProperty() {
379 return type() < FIRST_PHANTOM_PROPERTY_TYPE;
380 }
381
382 JSFunction* GetConstantFunction() { return JSFunction::cast(GetValue()); }
383
384 AccessorDescriptor* GetCallbacks() {
385 ASSERT(type() == CALLBACKS);
386 Proxy* p = Proxy::cast(GetCallbacksObject());
387 return reinterpret_cast<AccessorDescriptor*>(p->proxy());
388 }
389
390 Object* GetCallbacksObject() {
391 ASSERT(type() == CALLBACKS);
392 return GetValue();
393 }
394
395 bool Equals(String* name) { return name->Equals(GetKey()); }
396
397 void Get(Descriptor* desc) {
398 descriptors_->Get(pos_, desc);
399 }
400 };
401
402 class DescriptorWriter: public DescriptorStream {
403 public:
404 explicit DescriptorWriter(DescriptorArray* descriptors)
405 : DescriptorStream(descriptors, 0) {}
406
407 // Append a descriptor to this stream.
408 void Write(Descriptor* desc);
409 // Read a descriptor from the reader and append it to this stream.
410 void WriteFrom(DescriptorReader* reader);
411 };
412
413 } } // namespace v8::internal 327 } } // namespace v8::internal
414 328
415 #endif // V8_PROPERTY_H_ 329 #endif // V8_PROPERTY_H_
OLDNEW
« src/factory.cc ('K') | « src/objects-inl.h ('k') | src/property.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698