Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2456 virtual bool Equals(const Instance& other) const; | 2456 virtual bool Equals(const Instance& other) const; |
| 2457 | 2457 |
| 2458 intptr_t CompareTo(const String& other) const; | 2458 intptr_t CompareTo(const String& other) const; |
| 2459 | 2459 |
| 2460 bool StartsWith(const String& other) const; | 2460 bool StartsWith(const String& other) const; |
| 2461 | 2461 |
| 2462 virtual RawInstance* Canonicalize() const; | 2462 virtual RawInstance* Canonicalize() const; |
| 2463 | 2463 |
| 2464 bool IsSymbol() const; | 2464 bool IsSymbol() const; |
| 2465 | 2465 |
| 2466 virtual bool IsExternal() const { return false; } | |
| 2467 virtual void* GetPeer() const { | |
| 2468 UNREACHABLE(); | |
| 2469 return NULL; | |
| 2470 } | |
| 2471 | |
| 2466 static RawString* New(const char* str, Heap::Space space = Heap::kNew); | 2472 static RawString* New(const char* str, Heap::Space space = Heap::kNew); |
| 2467 static RawString* New(const uint8_t* characters, | 2473 static RawString* New(const uint8_t* characters, |
| 2468 intptr_t len, | 2474 intptr_t len, |
| 2469 Heap::Space space = Heap::kNew); | 2475 Heap::Space space = Heap::kNew); |
| 2470 static RawString* New(const uint16_t* characters, | 2476 static RawString* New(const uint16_t* characters, |
| 2471 intptr_t len, | 2477 intptr_t len, |
| 2472 Heap::Space space = Heap::kNew); | 2478 Heap::Space space = Heap::kNew); |
| 2473 static RawString* New(const uint32_t* characters, | 2479 static RawString* New(const uint32_t* characters, |
| 2474 intptr_t len, | 2480 intptr_t len, |
| 2475 Heap::Space space = Heap::kNew); | 2481 Heap::Space space = Heap::kNew); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2736 } | 2742 } |
| 2737 | 2743 |
| 2738 virtual intptr_t CharSize() const { | 2744 virtual intptr_t CharSize() const { |
| 2739 return kOneByteChar; | 2745 return kOneByteChar; |
| 2740 } | 2746 } |
| 2741 | 2747 |
| 2742 static intptr_t InstanceSize() { | 2748 static intptr_t InstanceSize() { |
| 2743 return RoundedAllocationSize(sizeof(RawExternalOneByteString)); | 2749 return RoundedAllocationSize(sizeof(RawExternalOneByteString)); |
| 2744 } | 2750 } |
| 2745 | 2751 |
| 2752 virtual bool IsExternal() const { return true; } | |
| 2753 virtual void* GetPeer() const { | |
| 2754 return raw_ptr()->external_data_->peer_; | |
|
siva
2011/12/02 01:53:01
Not sure what the official C++ style guide says bu
turnidge
2011/12/05 17:54:28
Done.
| |
| 2755 } | |
| 2756 | |
| 2746 static RawExternalOneByteString* New(const uint8_t* characters, | 2757 static RawExternalOneByteString* New(const uint8_t* characters, |
| 2747 intptr_t len, | 2758 intptr_t len, |
| 2748 void* peer, | 2759 void* peer, |
| 2749 PeerFinalizer callback, | 2760 PeerFinalizer callback, |
| 2750 Heap::Space space); | 2761 Heap::Space space); |
| 2751 | 2762 |
| 2752 private: | 2763 private: |
| 2753 const uint8_t* CharAddr(intptr_t index) const { | 2764 const uint8_t* CharAddr(intptr_t index) const { |
| 2754 // TODO(iposva): Determine if we should throw an exception here. | 2765 // TODO(iposva): Determine if we should throw an exception here. |
| 2755 ASSERT((index >= 0) && (index < Length())); | 2766 ASSERT((index >= 0) && (index < Length())); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2773 } | 2784 } |
| 2774 | 2785 |
| 2775 virtual intptr_t CharSize() const { | 2786 virtual intptr_t CharSize() const { |
| 2776 return kTwoByteChar; | 2787 return kTwoByteChar; |
| 2777 } | 2788 } |
| 2778 | 2789 |
| 2779 static intptr_t InstanceSize() { | 2790 static intptr_t InstanceSize() { |
| 2780 return RoundedAllocationSize(sizeof(RawExternalTwoByteString)); | 2791 return RoundedAllocationSize(sizeof(RawExternalTwoByteString)); |
| 2781 } | 2792 } |
| 2782 | 2793 |
| 2794 virtual bool IsExternal() const { return true; } | |
| 2795 virtual void* GetPeer() const { | |
| 2796 return raw_ptr()->external_data_->peer_; | |
| 2797 } | |
| 2798 | |
| 2783 static RawExternalTwoByteString* New(const uint16_t* characters, | 2799 static RawExternalTwoByteString* New(const uint16_t* characters, |
| 2784 intptr_t len, | 2800 intptr_t len, |
| 2785 void* peer, | 2801 void* peer, |
| 2786 PeerFinalizer callback, | 2802 PeerFinalizer callback, |
| 2787 Heap::Space space = Heap::kNew); | 2803 Heap::Space space = Heap::kNew); |
| 2788 | 2804 |
| 2789 private: | 2805 private: |
| 2790 const uint16_t* CharAddr(intptr_t index) const { | 2806 const uint16_t* CharAddr(intptr_t index) const { |
| 2791 // TODO(iposva): Determine if we should throw an exception here. | 2807 // TODO(iposva): Determine if we should throw an exception here. |
| 2792 ASSERT((index >= 0) && (index < Length())); | 2808 ASSERT((index >= 0) && (index < Length())); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2810 } | 2826 } |
| 2811 | 2827 |
| 2812 virtual intptr_t CharSize() const { | 2828 virtual intptr_t CharSize() const { |
| 2813 return kFourByteChar; | 2829 return kFourByteChar; |
| 2814 } | 2830 } |
| 2815 | 2831 |
| 2816 static intptr_t InstanceSize() { | 2832 static intptr_t InstanceSize() { |
| 2817 return RoundedAllocationSize(sizeof(RawExternalFourByteString)); | 2833 return RoundedAllocationSize(sizeof(RawExternalFourByteString)); |
| 2818 } | 2834 } |
| 2819 | 2835 |
| 2836 virtual bool IsExternal() const { return true; } | |
| 2837 virtual void* GetPeer() const { | |
| 2838 return raw_ptr()->external_data_->peer_; | |
| 2839 } | |
| 2840 | |
| 2820 static RawExternalFourByteString* New(const uint32_t* characters, | 2841 static RawExternalFourByteString* New(const uint32_t* characters, |
| 2821 intptr_t len, | 2842 intptr_t len, |
| 2822 void* peer, | 2843 void* peer, |
| 2823 PeerFinalizer callback, | 2844 PeerFinalizer callback, |
| 2824 Heap::Space space = Heap::kNew); | 2845 Heap::Space space = Heap::kNew); |
| 2825 | 2846 |
| 2826 private: | 2847 private: |
| 2827 const uint32_t* CharAddr(intptr_t index) const { | 2848 const uint32_t* CharAddr(intptr_t index) const { |
| 2828 // TODO(iposva): Determine if we should throw an exception here. | 2849 // TODO(iposva): Determine if we should throw an exception here. |
| 2829 ASSERT((index >= 0) && (index < Length())); | 2850 ASSERT((index >= 0) && (index < Length())); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3235 } | 3256 } |
| 3236 | 3257 |
| 3237 | 3258 |
| 3238 void Context::SetAt(intptr_t index, const Instance& value) const { | 3259 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 3239 StorePointer(InstanceAddr(index), value.raw()); | 3260 StorePointer(InstanceAddr(index), value.raw()); |
| 3240 } | 3261 } |
| 3241 | 3262 |
| 3242 } // namespace dart | 3263 } // namespace dart |
| 3243 | 3264 |
| 3244 #endif // VM_OBJECT_H_ | 3265 #endif // VM_OBJECT_H_ |
| OLD | NEW |