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 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 #include "vm/exceptions.h" | 6 #include "vm/exceptions.h" |
7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
8 #include "vm/runtime_entry.h" | 8 #include "vm/runtime_entry.h" |
9 #include "vm/stack_frame.h" | 9 #include "vm/stack_frame.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 // Allocate and throw a new AssertionError. | 13 // Allocate and throw a new AssertionError. |
14 // Arg0: index of the first token of the failed assertion. | 14 // Arg0: index of the first token of the failed assertion. |
15 // Arg1: index of the first token after the failed assertion. | 15 // Arg1: index of the first token after the failed assertion. |
16 // Return value: none, throws an exception. | 16 // Return value: none, throws an exception. |
17 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) { | 17 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) { |
18 // No need to type check the arguments. This function can only be called | 18 // No need to type check the arguments. This function can only be called |
19 // internally from the VM. | 19 // internally from the VM. |
20 const TokenPosition assertion_start = | 20 const TokenPosition assertion_start = |
21 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value()); | 21 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value()); |
22 const TokenPosition assertion_end = | 22 const TokenPosition assertion_end = |
23 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(1)).Value()); | 23 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(1)).Value()); |
24 | 24 |
25 const Array& args = Array::Handle(Array::New(4)); | 25 const Array& args = Array::Handle(Array::New(4)); |
26 | 26 |
27 DartFrameIterator iterator; | 27 DartFrameIterator iterator; |
28 iterator.NextFrame(); // Skip native call. | 28 iterator.NextFrame(); // Skip native call. |
| 29 iterator.NextFrame(); // Skip _AssertionError._checkAssertion frame |
29 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); | 30 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); |
30 | 31 |
31 // Initialize argument 'failed_assertion' with source snippet. | 32 // Initialize argument 'failed_assertion' with source snippet. |
32 intptr_t from_line, from_column; | 33 intptr_t from_line, from_column; |
33 script.GetTokenLocation(assertion_start, &from_line, &from_column); | 34 script.GetTokenLocation(assertion_start, &from_line, &from_column); |
34 intptr_t to_line, to_column; | 35 intptr_t to_line, to_column; |
35 script.GetTokenLocation(assertion_end, &to_line, &to_column); | 36 script.GetTokenLocation(assertion_end, &to_line, &to_column); |
36 // The snippet will extract the correct assertion code even if the source | 37 // The snippet will extract the correct assertion code even if the source |
37 // is generated. | 38 // is generated. |
38 args.SetAt(0, String::Handle( | 39 args.SetAt(0, String::Handle( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 // Rethrow an error with a stacktrace. | 130 // Rethrow an error with a stacktrace. |
130 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { | 131 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { |
131 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); | 132 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); |
132 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); | 133 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); |
133 Exceptions::ReThrow(thread, error, stacktrace); | 134 Exceptions::ReThrow(thread, error, stacktrace); |
134 return Object::null(); | 135 return Object::null(); |
135 } | 136 } |
136 | 137 |
137 } // namespace dart | 138 } // namespace dart |
OLD | NEW |