OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 7503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7514 | 7514 |
7515 Object* JSMapIterator::CurrentValue() { | 7515 Object* JSMapIterator::CurrentValue() { |
7516 OrderedHashMap* table(OrderedHashMap::cast(this->table())); | 7516 OrderedHashMap* table(OrderedHashMap::cast(this->table())); |
7517 int index = Smi::cast(this->index())->value(); | 7517 int index = Smi::cast(this->index())->value(); |
7518 Object* value = table->ValueAt(index); | 7518 Object* value = table->ValueAt(index); |
7519 DCHECK(!value->IsTheHole()); | 7519 DCHECK(!value->IsTheHole()); |
7520 return value; | 7520 return value; |
7521 } | 7521 } |
7522 | 7522 |
7523 | 7523 |
| 7524 class String::SubStringRange::iterator FINAL { |
| 7525 public: |
| 7526 typedef std::forward_iterator_tag iterator_category; |
| 7527 typedef int difference_type; |
| 7528 typedef uc16 value_type; |
| 7529 typedef uc16* pointer; |
| 7530 typedef uc16& reference; |
| 7531 |
| 7532 iterator(const iterator& other) |
| 7533 : content_(other.content_), offset_(other.offset_) {} |
| 7534 |
| 7535 uc16 operator*() { return content_.Get(offset_); } |
| 7536 bool operator==(const iterator& other) const { |
| 7537 return content_.UsesSameString(other.content_) && offset_ == other.offset_; |
| 7538 } |
| 7539 bool operator!=(const iterator& other) const { |
| 7540 return !content_.UsesSameString(other.content_) || offset_ != other.offset_; |
| 7541 } |
| 7542 iterator& operator++() { |
| 7543 ++offset_; |
| 7544 return *this; |
| 7545 } |
| 7546 iterator operator++(int); |
| 7547 |
| 7548 private: |
| 7549 friend class String; |
| 7550 iterator(String* from, int offset) |
| 7551 : content_(from->GetFlatContent()), offset_(offset) {} |
| 7552 String::FlatContent content_; |
| 7553 int offset_; |
| 7554 }; |
| 7555 |
| 7556 |
| 7557 String::SubStringRange::iterator String::SubStringRange::begin() { |
| 7558 return String::SubStringRange::iterator(string_, first_); |
| 7559 } |
| 7560 |
| 7561 |
| 7562 String::SubStringRange::iterator String::SubStringRange::end() { |
| 7563 return String::SubStringRange::iterator(string_, first_ + length_); |
| 7564 } |
| 7565 |
| 7566 |
7524 #undef TYPE_CHECKER | 7567 #undef TYPE_CHECKER |
7525 #undef CAST_ACCESSOR | 7568 #undef CAST_ACCESSOR |
7526 #undef INT_ACCESSORS | 7569 #undef INT_ACCESSORS |
7527 #undef ACCESSORS | 7570 #undef ACCESSORS |
7528 #undef ACCESSORS_TO_SMI | 7571 #undef ACCESSORS_TO_SMI |
7529 #undef SMI_ACCESSORS | 7572 #undef SMI_ACCESSORS |
7530 #undef SYNCHRONIZED_SMI_ACCESSORS | 7573 #undef SYNCHRONIZED_SMI_ACCESSORS |
7531 #undef NOBARRIER_SMI_ACCESSORS | 7574 #undef NOBARRIER_SMI_ACCESSORS |
7532 #undef BOOL_GETTER | 7575 #undef BOOL_GETTER |
7533 #undef BOOL_ACCESSORS | 7576 #undef BOOL_ACCESSORS |
(...skipping 16 matching lines...) Expand all Loading... |
7550 #undef READ_SHORT_FIELD | 7593 #undef READ_SHORT_FIELD |
7551 #undef WRITE_SHORT_FIELD | 7594 #undef WRITE_SHORT_FIELD |
7552 #undef READ_BYTE_FIELD | 7595 #undef READ_BYTE_FIELD |
7553 #undef WRITE_BYTE_FIELD | 7596 #undef WRITE_BYTE_FIELD |
7554 #undef NOBARRIER_READ_BYTE_FIELD | 7597 #undef NOBARRIER_READ_BYTE_FIELD |
7555 #undef NOBARRIER_WRITE_BYTE_FIELD | 7598 #undef NOBARRIER_WRITE_BYTE_FIELD |
7556 | 7599 |
7557 } } // namespace v8::internal | 7600 } } // namespace v8::internal |
7558 | 7601 |
7559 #endif // V8_OBJECTS_INL_H_ | 7602 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |