Chromium Code Reviews| 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* New(const Error& prev_error, | |
| 3801 const Script& script, | |
| 3802 intptr_t token_pos, | |
| 3803 Kind kind, | |
| 3804 const String& message, | |
| 3805 Heap::Space space = Heap::kNew); | |
|
Ivan Posva
2013/11/15 04:42:13
I find it a bit strange that the space parameter t
regis
2013/11/15 18:27:38
The space parameter is optional in most New calls
| |
| 3806 | |
| 3807 static RawLanguageError* NewFormatted(const Error& prev_error, | |
| 3808 const Script& script, | |
| 3809 intptr_t token_pos, | |
| 3810 Kind kind, | |
| 3811 Heap::Space space, | |
| 3812 const char* format, ...) | |
| 3813 PRINTF_ATTRIBUTE(6, 7); | |
| 3814 | |
| 3815 static RawLanguageError* NewFormattedV(const Error& prev_error, | |
| 3816 const Script& script, | |
| 3817 intptr_t token_pos, | |
| 3818 Kind kind, | |
| 3819 Heap::Space space, | |
| 3820 const char* format, va_list args); | |
| 3821 | |
| 3822 static RawLanguageError* New(const String& formatted_message, | |
| 3798 Heap::Space space = Heap::kNew); | 3823 Heap::Space space = Heap::kNew); |
| 3799 | 3824 |
| 3800 virtual const char* ToErrorCString() const; | 3825 virtual const char* ToErrorCString() const; |
| 3801 | 3826 |
| 3802 private: | 3827 private: |
| 3803 void set_message(const String& message) const; | 3828 RawError* previous_error() const { |
| 3829 return raw_ptr()->previous_error_; | |
| 3830 } | |
| 3831 void set_previous_error(const Error& value) const; | |
| 3832 | |
| 3833 RawScript* script() const { return raw_ptr()->script_; } | |
| 3834 void set_script(const Script& value) const; | |
| 3835 | |
| 3836 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | |
| 3837 void set_token_pos(intptr_t value) const; | |
| 3838 | |
| 3839 Kind kind() const { return static_cast<Kind>(raw_ptr()->kind_); } | |
| 3840 void set_kind(uint8_t value) const; | |
| 3841 | |
| 3842 RawString* message() const { return raw_ptr()->message_; } | |
| 3843 void set_message(const String& value) const; | |
| 3844 | |
| 3845 RawString* formatted_message() const { return raw_ptr()->formatted_message_; } | |
| 3846 void set_formatted_message(const String& value) const; | |
| 3804 | 3847 |
| 3805 static RawLanguageError* New(); | 3848 static RawLanguageError* New(); |
| 3806 | 3849 |
| 3807 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); | 3850 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); |
| 3808 friend class Class; | 3851 friend class Class; |
| 3809 }; | 3852 }; |
| 3810 | 3853 |
| 3811 | 3854 |
| 3812 class UnhandledException : public Error { | 3855 class UnhandledException : public Error { |
| 3813 public: | 3856 public: |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 3836 void set_stacktrace(const Instance& stacktrace) const; | 3879 void set_stacktrace(const Instance& stacktrace) const; |
| 3837 | 3880 |
| 3838 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error); | 3881 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error); |
| 3839 friend class Class; | 3882 friend class Class; |
| 3840 }; | 3883 }; |
| 3841 | 3884 |
| 3842 | 3885 |
| 3843 class UnwindError : public Error { | 3886 class UnwindError : public Error { |
| 3844 public: | 3887 public: |
| 3845 RawString* message() const { return raw_ptr()->message_; } | 3888 RawString* message() const { return raw_ptr()->message_; } |
| 3846 static intptr_t message_offset() { | |
| 3847 return OFFSET_OF(RawUnwindError, message_); | |
| 3848 } | |
| 3849 | 3889 |
| 3850 static intptr_t InstanceSize() { | 3890 static intptr_t InstanceSize() { |
| 3851 return RoundedAllocationSize(sizeof(RawUnwindError)); | 3891 return RoundedAllocationSize(sizeof(RawUnwindError)); |
| 3852 } | 3892 } |
| 3853 | 3893 |
| 3854 static RawUnwindError* New(const String& message, | 3894 static RawUnwindError* New(const String& message, |
| 3855 Heap::Space space = Heap::kNew); | 3895 Heap::Space space = Heap::kNew); |
| 3856 | 3896 |
| 3857 virtual const char* ToErrorCString() const; | 3897 virtual const char* ToErrorCString() const; |
| 3858 | 3898 |
| (...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6390 | 6430 |
| 6391 | 6431 |
| 6392 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6432 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6393 intptr_t index) { | 6433 intptr_t index) { |
| 6394 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6434 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6395 } | 6435 } |
| 6396 | 6436 |
| 6397 } // namespace dart | 6437 } // namespace dart |
| 6398 | 6438 |
| 6399 #endif // VM_OBJECT_H_ | 6439 #endif // VM_OBJECT_H_ |
| OLD | NEW |