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 RUNTIME_VM_EXCEPTIONS_H_ | 5 #ifndef RUNTIME_VM_EXCEPTIONS_H_ |
6 #define RUNTIME_VM_EXCEPTIONS_H_ | 6 #define RUNTIME_VM_EXCEPTIONS_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/token_position.h" | 9 #include "vm/token_position.h" |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 static RawInstance* NewInstance(const char* class_name); | 39 static RawInstance* NewInstance(const char* class_name); |
40 static void CreateAndThrowTypeError(TokenPosition location, | 40 static void CreateAndThrowTypeError(TokenPosition location, |
41 const AbstractType& src_type, | 41 const AbstractType& src_type, |
42 const AbstractType& dst_type, | 42 const AbstractType& dst_type, |
43 const String& dst_name, | 43 const String& dst_name, |
44 const String& bound_error_msg); | 44 const String& bound_error_msg); |
45 | 45 |
46 enum ExceptionType { | 46 enum ExceptionType { |
47 kNone, | 47 kNone, |
48 kRange, | 48 kRange, |
| 49 kRangeMsg, |
49 kArgument, | 50 kArgument, |
50 kArgumentValue, | 51 kArgumentValue, |
51 kNoSuchMethod, | 52 kNoSuchMethod, |
52 kFormat, | 53 kFormat, |
53 kUnsupported, | 54 kUnsupported, |
54 kStackOverflow, | 55 kStackOverflow, |
55 kOutOfMemory, | 56 kOutOfMemory, |
56 kNullThrown, | 57 kNullThrown, |
57 kIsolateSpawn, | 58 kIsolateSpawn, |
58 kAssertion, | 59 kAssertion, |
59 kCast, | 60 kCast, |
60 kType, | 61 kType, |
61 kFallThrough, | 62 kFallThrough, |
62 kAbstractClassInstantiation, | 63 kAbstractClassInstantiation, |
63 kCyclicInitializationError, | 64 kCyclicInitializationError, |
64 kCompileTimeError, | 65 kCompileTimeError, |
65 }; | 66 }; |
66 | 67 |
67 static void ThrowByType(ExceptionType type, const Array& arguments); | 68 static void ThrowByType(ExceptionType type, const Array& arguments); |
68 // Uses the preallocated out of memory exception to avoid calling | 69 // Uses the preallocated out of memory exception to avoid calling |
69 // into Dart code or allocating any code. | 70 // into Dart code or allocating any code. |
70 static void ThrowOOM(); | 71 static void ThrowOOM(); |
71 static void ThrowStackOverflow(); | 72 static void ThrowStackOverflow(); |
72 static void ThrowArgumentError(const Instance& arg); | 73 static void ThrowArgumentError(const Instance& arg); |
73 static void ThrowRangeError(const char* argument_name, | 74 static void ThrowRangeError(const char* argument_name, |
74 const Integer& argument_value, | 75 const Integer& argument_value, |
75 intptr_t expected_from, | 76 intptr_t expected_from, |
76 intptr_t expected_to); | 77 intptr_t expected_to); |
| 78 static void ThrowRangeErrorMsg(const char* msg); |
77 static void ThrowCompileTimeError(const LanguageError& error); | 79 static void ThrowCompileTimeError(const LanguageError& error); |
78 | 80 |
79 // Returns a RawInstance if the exception is successfully created, | 81 // Returns a RawInstance if the exception is successfully created, |
80 // otherwise returns a RawError. | 82 // otherwise returns a RawError. |
81 static RawObject* Create(ExceptionType type, const Array& arguments); | 83 static RawObject* Create(ExceptionType type, const Array& arguments); |
82 | 84 |
83 static void JumpToFrame(Thread* thread, | 85 static void JumpToFrame(Thread* thread, |
84 uword program_counter, | 86 uword program_counter, |
85 uword stack_pointer, | 87 uword stack_pointer, |
86 uword frame_pointer, | 88 uword frame_pointer, |
87 bool clear_deopt_at_target); | 89 bool clear_deopt_at_target); |
88 | 90 |
89 private: | 91 private: |
90 DISALLOW_COPY_AND_ASSIGN(Exceptions); | 92 DISALLOW_COPY_AND_ASSIGN(Exceptions); |
91 }; | 93 }; |
92 | 94 |
93 // The index into the ExceptionHandlers table corresponds to | 95 // The index into the ExceptionHandlers table corresponds to |
94 // the try_index of the handler. | 96 // the try_index of the handler. |
95 struct ExceptionHandlerInfo { | 97 struct ExceptionHandlerInfo { |
96 uint32_t handler_pc_offset; // PC offset value of handler. | 98 uint32_t handler_pc_offset; // PC offset value of handler. |
97 int16_t outer_try_index; // Try block index of enclosing try block. | 99 int16_t outer_try_index; // Try block index of enclosing try block. |
98 int8_t needs_stacktrace; // True if a stacktrace is needed. | 100 int8_t needs_stacktrace; // True if a stacktrace is needed. |
99 int8_t has_catch_all; // Catches all exceptions. | 101 int8_t has_catch_all; // Catches all exceptions. |
100 }; | 102 }; |
101 | 103 |
102 } // namespace dart | 104 } // namespace dart |
103 | 105 |
104 #endif // RUNTIME_VM_EXCEPTIONS_H_ | 106 #endif // RUNTIME_VM_EXCEPTIONS_H_ |
OLD | NEW |