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 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 // Forward declarations. | 13 // Forward declarations. |
14 class Error; | |
15 class Instance; | 14 class Instance; |
16 class Object; | 15 class Object; |
17 class RawObject; | 16 class RawInstance; |
18 | 17 |
19 class Exceptions : AllStatic { | 18 class Exceptions : AllStatic { |
20 public: | 19 public: |
21 static void Throw(const Instance& exception); | 20 static void Throw(const Instance& exception); |
22 static void ReThrow(const Instance& exception, const Instance& stacktrace); | 21 static void ReThrow(const Instance& exception, const Instance& stacktrace); |
23 static void PropagateError(const Object& obj); | |
24 | 22 |
25 enum ExceptionType { | 23 enum ExceptionType { |
26 kIndexOutOfRange, | 24 kIndexOutOfRange, |
27 kIllegalArgument, | 25 kIllegalArgument, |
28 kNoSuchMethod, | 26 kNoSuchMethod, |
29 kClosureArgumentMismatch, | 27 kClosureArgumentMismatch, |
30 kObjectNotClosure, | 28 kObjectNotClosure, |
31 kBadNumberFormat, | 29 kBadNumberFormat, |
32 kStackOverflow, | 30 kStackOverflow, |
33 kOutOfMemory, | 31 kOutOfMemory, |
34 kWrongArgumentCount, | 32 kWrongArgumentCount, |
35 kInternalError, | 33 kInternalError, |
36 kNullPointer, | 34 kNullPointer, |
37 kIllegalJSRegExp, | 35 kIllegalJSRegExp, |
38 }; | 36 }; |
39 | 37 |
40 static void ThrowByType(ExceptionType type, | 38 static void ThrowByType(ExceptionType type, |
41 const GrowableArray<const Object*>& arguments); | 39 const GrowableArray<const Object*>& arguments); |
42 // Returns a RawInstance if the exception is successfully created, | 40 static RawInstance* Create(ExceptionType type, |
43 // otherwise returns a RawError. | 41 const GrowableArray<const Object*>& arguments); |
44 static RawObject* Create(ExceptionType type, | |
45 const GrowableArray<const Object*>& arguments); | |
46 | 42 |
47 private: | 43 private: |
48 DISALLOW_COPY_AND_ASSIGN(Exceptions); | 44 DISALLOW_COPY_AND_ASSIGN(Exceptions); |
49 }; | 45 }; |
50 | 46 |
51 } // namespace dart | 47 } // namespace dart |
52 | 48 |
53 #endif // VM_EXCEPTIONS_H_ | 49 #endif // VM_EXCEPTIONS_H_ |
OLD | NEW |