| 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 "lib/error.h" | 5 #include "lib/error.h" |
| 6 | 6 |
| 7 #include "vm/bootstrap_natives.h" | 7 #include "vm/bootstrap_natives.h" |
| 8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
| 11 #include "vm/stack_frame.h" | 11 #include "vm/stack_frame.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 DEFINE_FLAG(bool, trace_type_checks, false, "Trace runtime type checks."); | 15 DEFINE_FLAG(bool, trace_type_checks, false, "Trace runtime type checks."); |
| 16 | 16 |
| 17 // Allocate and throw a new AssertionError. | 17 // Allocate and throw a new AssertionError. |
| 18 // Arg0: index of the first token of the failed assertion. | 18 // Arg0: index of the first token of the failed assertion. |
| 19 // Arg1: index of the first token after the failed assertion. | 19 // Arg1: index of the first token after the failed assertion. |
| 20 // Return value: none, throws an exception. | 20 // Return value: none, throws an exception. |
| 21 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) { | 21 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) { |
| 22 // No need to type check the arguments. This function can only be called | 22 // No need to type check the arguments. This function can only be called |
| 23 // internally from the VM. | 23 // internally from the VM. |
| 24 intptr_t assertion_start = Smi::CheckedHandle(arguments->At(0)).Value(); | 24 intptr_t assertion_start = Smi::CheckedHandle(arguments->At(0)).Value(); |
| 25 intptr_t assertion_end = Smi::CheckedHandle(arguments->At(1)).Value(); | 25 intptr_t assertion_end = Smi::CheckedHandle(arguments->At(1)).Value(); |
| 26 | 26 |
| 27 // Allocate a new instance of type AssertionError. | 27 // Allocate a new instance of type AssertionError. |
| 28 const Instance& assertion_error = Instance::Handle( | 28 const Instance& assertion_error = Instance::Handle( |
| 29 Exceptions::NewInstance("AssertionError")); | 29 Exceptions::NewInstance("AssertionErrorImplementation")); |
| 30 | 30 |
| 31 // Initialize 'url', 'line', and 'column' fields. | 31 // Initialize 'url', 'line', and 'column' fields. |
| 32 DartFrameIterator iterator; | 32 DartFrameIterator iterator; |
| 33 iterator.NextFrame(); // Skip native call. | 33 iterator.NextFrame(); // Skip native call. |
| 34 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); | 34 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); |
| 35 const Class& cls = Class::Handle(assertion_error.clazz()); | 35 const Class& cls = Class::Handle(assertion_error.clazz()); |
| 36 Exceptions::SetLocationFields(assertion_error, cls, script, assertion_start); | 36 Exceptions::SetLocationFields(assertion_error, cls, script, assertion_start); |
| 37 | 37 |
| 38 // Initialize field 'failed_assertion' with source snippet. | 38 // Initialize field 'failed_assertion' with source snippet. |
| 39 intptr_t from_line, from_column; | 39 intptr_t from_line, from_column; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 intptr_t line, column; | 122 intptr_t line, column; |
| 123 script.GetTokenLocation(call_pos, &line, &column); | 123 script.GetTokenLocation(call_pos, &line, &column); |
| 124 Exceptions::SetField(resolution_exception, cls, "failedResolutionLine", | 124 Exceptions::SetField(resolution_exception, cls, "failedResolutionLine", |
| 125 String::Handle(script.GetLine(line))); | 125 String::Handle(script.GetLine(line))); |
| 126 | 126 |
| 127 Exceptions::Throw(resolution_exception); | 127 Exceptions::Throw(resolution_exception); |
| 128 UNREACHABLE(); | 128 UNREACHABLE(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace dart | 131 } // namespace dart |
| OLD | NEW |