OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 3742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3753 virtual const char* ToErrorCString() const; | 3753 virtual const char* ToErrorCString() const; |
3754 | 3754 |
3755 private: | 3755 private: |
3756 HEAP_OBJECT_IMPLEMENTATION(Error, Object); | 3756 HEAP_OBJECT_IMPLEMENTATION(Error, Object); |
3757 }; | 3757 }; |
3758 | 3758 |
3759 | 3759 |
3760 class ApiError : public Error { | 3760 class ApiError : public Error { |
3761 public: | 3761 public: |
3762 RawString* message() const { return raw_ptr()->message_; } | 3762 RawString* message() const { return raw_ptr()->message_; } |
3763 static intptr_t message_offset() { | |
3764 return OFFSET_OF(RawApiError, message_); | |
3765 } | |
3766 | 3763 |
3767 static intptr_t InstanceSize() { | 3764 static intptr_t InstanceSize() { |
3768 return RoundedAllocationSize(sizeof(RawApiError)); | 3765 return RoundedAllocationSize(sizeof(RawApiError)); |
3769 } | 3766 } |
3770 | 3767 |
3771 static RawApiError* New(const String& message, | 3768 static RawApiError* New(const String& message, |
3772 Heap::Space space = Heap::kNew); | 3769 Heap::Space space = Heap::kNew); |
3773 | 3770 |
3774 virtual const char* ToErrorCString() const; | 3771 virtual const char* ToErrorCString() const; |
3775 | 3772 |
3776 private: | 3773 private: |
3777 void set_message(const String& message) const; | 3774 void set_message(const String& message) const; |
3778 | 3775 |
3779 static RawApiError* New(); | 3776 static RawApiError* New(); |
3780 | 3777 |
3781 FINAL_HEAP_OBJECT_IMPLEMENTATION(ApiError, Error); | 3778 FINAL_HEAP_OBJECT_IMPLEMENTATION(ApiError, Error); |
3782 friend class Class; | 3779 friend class Class; |
3783 }; | 3780 }; |
3784 | 3781 |
3785 | 3782 |
3786 class LanguageError : public Error { | 3783 class LanguageError : public Error { |
3787 public: | 3784 public: |
3788 RawString* message() const { return raw_ptr()->message_; } | 3785 enum Kind { |
3789 static intptr_t message_offset() { | 3786 kWarning, |
3790 return OFFSET_OF(RawLanguageError, message_); | 3787 kError, |
3791 } | 3788 kMalformedType, |
| 3789 kMalboundedType, |
| 3790 }; |
| 3791 |
| 3792 // Build, cache, and return formatted message. |
| 3793 RawString* FormatMessage() const; |
3792 | 3794 |
3793 static intptr_t InstanceSize() { | 3795 static intptr_t InstanceSize() { |
3794 return RoundedAllocationSize(sizeof(RawLanguageError)); | 3796 return RoundedAllocationSize(sizeof(RawLanguageError)); |
3795 } | 3797 } |
3796 | 3798 |
3797 static RawLanguageError* New(const String& message, | 3799 // A null script means no source and a negative token_pos means no position. |
| 3800 static RawLanguageError* NewFormatted(const Error& prev_error, |
| 3801 const Script& script, |
| 3802 intptr_t token_pos, |
| 3803 Kind kind, |
| 3804 Heap::Space space, |
| 3805 const char* format, ...) |
| 3806 PRINTF_ATTRIBUTE(6, 7); |
| 3807 |
| 3808 static RawLanguageError* NewFormattedV(const Error& prev_error, |
| 3809 const Script& script, |
| 3810 intptr_t token_pos, |
| 3811 Kind kind, |
| 3812 Heap::Space space, |
| 3813 const char* format, va_list args); |
| 3814 |
| 3815 static RawLanguageError* New(const String& formatted_message, |
3798 Heap::Space space = Heap::kNew); | 3816 Heap::Space space = Heap::kNew); |
3799 | 3817 |
3800 virtual const char* ToErrorCString() const; | 3818 virtual const char* ToErrorCString() const; |
3801 | 3819 |
3802 private: | 3820 private: |
3803 void set_message(const String& message) const; | 3821 RawError* previous_error() const { |
| 3822 return raw_ptr()->previous_error_; |
| 3823 } |
| 3824 void set_previous_error(const Error& value) const; |
| 3825 |
| 3826 RawScript* script() const { return raw_ptr()->script_; } |
| 3827 void set_script(const Script& value) const; |
| 3828 |
| 3829 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 3830 void set_token_pos(intptr_t value) const; |
| 3831 |
| 3832 Kind kind() const { return static_cast<Kind>(raw_ptr()->kind_); } |
| 3833 void set_kind(uint8_t value) const; |
| 3834 |
| 3835 RawString* message() const { return raw_ptr()->message_; } |
| 3836 void set_message(const String& value) const; |
| 3837 |
| 3838 RawString* formatted_message() const { return raw_ptr()->formatted_message_; } |
| 3839 void set_formatted_message(const String& value) const; |
3804 | 3840 |
3805 static RawLanguageError* New(); | 3841 static RawLanguageError* New(); |
3806 | 3842 |
3807 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); | 3843 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); |
3808 friend class Class; | 3844 friend class Class; |
3809 }; | 3845 }; |
3810 | 3846 |
3811 | 3847 |
3812 class UnhandledException : public Error { | 3848 class UnhandledException : public Error { |
3813 public: | 3849 public: |
(...skipping 22 matching lines...) Expand all Loading... |
3836 void set_stacktrace(const Instance& stacktrace) const; | 3872 void set_stacktrace(const Instance& stacktrace) const; |
3837 | 3873 |
3838 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error); | 3874 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error); |
3839 friend class Class; | 3875 friend class Class; |
3840 }; | 3876 }; |
3841 | 3877 |
3842 | 3878 |
3843 class UnwindError : public Error { | 3879 class UnwindError : public Error { |
3844 public: | 3880 public: |
3845 RawString* message() const { return raw_ptr()->message_; } | 3881 RawString* message() const { return raw_ptr()->message_; } |
3846 static intptr_t message_offset() { | |
3847 return OFFSET_OF(RawUnwindError, message_); | |
3848 } | |
3849 | 3882 |
3850 static intptr_t InstanceSize() { | 3883 static intptr_t InstanceSize() { |
3851 return RoundedAllocationSize(sizeof(RawUnwindError)); | 3884 return RoundedAllocationSize(sizeof(RawUnwindError)); |
3852 } | 3885 } |
3853 | 3886 |
3854 static RawUnwindError* New(const String& message, | 3887 static RawUnwindError* New(const String& message, |
3855 Heap::Space space = Heap::kNew); | 3888 Heap::Space space = Heap::kNew); |
3856 | 3889 |
3857 virtual const char* ToErrorCString() const; | 3890 virtual const char* ToErrorCString() const; |
3858 | 3891 |
(...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6390 | 6423 |
6391 | 6424 |
6392 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6425 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6393 intptr_t index) { | 6426 intptr_t index) { |
6394 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6427 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6395 } | 6428 } |
6396 | 6429 |
6397 } // namespace dart | 6430 } // namespace dart |
6398 | 6431 |
6399 #endif // VM_OBJECT_H_ | 6432 #endif // VM_OBJECT_H_ |
OLD | NEW |