| 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_EXCEPTIONS_H_ | 5 #ifndef VM_EXCEPTIONS_H_ |
| 6 #define VM_EXCEPTIONS_H_ | 6 #define VM_EXCEPTIONS_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 // Forward declarations. | 12 // Forward declarations. |
| 13 class Array; | 13 class Array; |
| 14 class Class; | 14 class Class; |
| 15 class DartFrameIterator; | 15 class DartFrameIterator; |
| 16 class Error; | 16 class Error; |
| 17 class Instance; | 17 class Instance; |
| 18 class Integer; | 18 class Integer; |
| 19 class Object; | 19 class Object; |
| 20 class RawInstance; | 20 class RawInstance; |
| 21 class RawObject; | 21 class RawObject; |
| 22 class RawScript; | 22 class RawScript; |
| 23 class RawStacktrace; | 23 class RawStacktrace; |
| 24 class RawString; | 24 class RawString; |
| 25 class Script; | 25 class Script; |
| 26 class StackFrame; | 26 class StackFrame; |
| 27 class Stacktrace; | 27 class Stacktrace; |
| 28 class String; | 28 class String; |
| 29 class Thread; |
| 29 | 30 |
| 30 class Exceptions : AllStatic { | 31 class Exceptions : AllStatic { |
| 31 public: | 32 public: |
| 32 static const char* kCastErrorDstName; | 33 static const char* kCastErrorDstName; |
| 33 | 34 |
| 34 static void Throw(Isolate* isolate, const Instance& exception); | 35 static void Throw(Thread* thread, const Instance& exception); |
| 35 static void ReThrow(Isolate* isolate, | 36 static void ReThrow(Thread* thread, |
| 36 const Instance& exception, | 37 const Instance& exception, |
| 37 const Instance& stacktrace); | 38 const Instance& stacktrace); |
| 38 static void PropagateError(const Error& error); | 39 static void PropagateError(const Error& error); |
| 39 | 40 |
| 40 // Helpers to create and throw errors. | 41 // Helpers to create and throw errors. |
| 41 static RawStacktrace* CurrentStacktrace(); | 42 static RawStacktrace* CurrentStacktrace(); |
| 42 static RawScript* GetCallerScript(DartFrameIterator* iterator); | 43 static RawScript* GetCallerScript(DartFrameIterator* iterator); |
| 43 static RawInstance* NewInstance(const char* class_name); | 44 static RawInstance* NewInstance(const char* class_name); |
| 44 static void CreateAndThrowTypeError(intptr_t location, | 45 static void CreateAndThrowTypeError(intptr_t location, |
| 45 const String& src_type_name, | 46 const String& src_type_name, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 kJavascriptCompatibilityError, | 64 kJavascriptCompatibilityError, |
| 64 kAssertion, | 65 kAssertion, |
| 65 kCast, | 66 kCast, |
| 66 kType, | 67 kType, |
| 67 kFallThrough, | 68 kFallThrough, |
| 68 kAbstractClassInstantiation, | 69 kAbstractClassInstantiation, |
| 69 kCyclicInitializationError, | 70 kCyclicInitializationError, |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 static void ThrowByType(ExceptionType type, const Array& arguments); | 73 static void ThrowByType(ExceptionType type, const Array& arguments); |
| 74 // Uses the preallocated out of memory exception to avoid calling |
| 75 // into Dart code or allocating any code. |
| 73 static void ThrowOOM(); | 76 static void ThrowOOM(); |
| 74 static void ThrowStackOverflow(); | 77 static void ThrowStackOverflow(); |
| 75 static void ThrowArgumentError(const Instance& arg); | 78 static void ThrowArgumentError(const Instance& arg); |
| 76 static void ThrowRangeError(const char* argument_name, | 79 static void ThrowRangeError(const char* argument_name, |
| 77 const Integer& argument_value, | 80 const Integer& argument_value, |
| 78 intptr_t expected_from, | 81 intptr_t expected_from, |
| 79 intptr_t expected_to); | 82 intptr_t expected_to); |
| 80 static void ThrowJavascriptCompatibilityError(const char* msg); | 83 static void ThrowJavascriptCompatibilityError(const char* msg); |
| 81 | 84 |
| 82 // Returns a RawInstance if the exception is successfully created, | 85 // Returns a RawInstance if the exception is successfully created, |
| 83 // otherwise returns a RawError. | 86 // otherwise returns a RawError. |
| 84 static RawObject* Create(ExceptionType type, const Array& arguments); | 87 static RawObject* Create(ExceptionType type, const Array& arguments); |
| 85 | 88 |
| 86 private: | 89 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(Exceptions); | 90 DISALLOW_COPY_AND_ASSIGN(Exceptions); |
| 88 }; | 91 }; |
| 89 | 92 |
| 90 } // namespace dart | 93 } // namespace dart |
| 91 | 94 |
| 92 #endif // VM_EXCEPTIONS_H_ | 95 #endif // VM_EXCEPTIONS_H_ |
| OLD | NEW |