| 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" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 dst_type_name, dst_name, type_error); | 75 dst_type_name, dst_name, type_error); |
| 76 UNREACHABLE(); | 76 UNREACHABLE(); |
| 77 return Object::null(); | 77 return Object::null(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 |
| 81 // Allocate and throw a new FallThroughError. | 81 // Allocate and throw a new FallThroughError. |
| 82 // Arg0: index of the case clause token into which we fall through. | 82 // Arg0: index of the case clause token into which we fall through. |
| 83 // Return value: none, throws an exception. | 83 // Return value: none, throws an exception. |
| 84 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) { | 84 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) { |
| 85 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); | 85 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); |
| 86 intptr_t fallthrough_pos = smi_pos.Value(); | 86 intptr_t fallthrough_pos = smi_pos.Value(); |
| 87 | 87 |
| 88 // Allocate a new instance of type FallThroughError. | 88 // Allocate a new instance of type FallThroughError. |
| 89 const Instance& fallthrough_error = Instance::Handle(Exceptions::NewInstance( | 89 const Instance& fallthrough_error = Instance::Handle(Exceptions::NewInstance( |
| 90 "FallThroughErrorImplementation")); | 90 "FallThroughErrorImplementation")); |
| 91 ASSERT(!fallthrough_error.IsNull()); | 91 ASSERT(!fallthrough_error.IsNull()); |
| 92 | 92 |
| 93 // Initialize 'url' and 'line' fields. | 93 // Initialize 'url' and 'line' fields. |
| 94 DartFrameIterator iterator; | 94 DartFrameIterator iterator; |
| 95 iterator.NextFrame(); // Skip native call. | 95 iterator.NextFrame(); // Skip native call. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 107 UNREACHABLE(); | 107 UNREACHABLE(); |
| 108 return Object::null(); | 108 return Object::null(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 // Allocate and throw a new AbstractClassInstantiationError. | 112 // Allocate and throw a new AbstractClassInstantiationError. |
| 113 // Arg0: Token position of allocation statement. | 113 // Arg0: Token position of allocation statement. |
| 114 // Arg1: class name of the abstract class that cannot be instantiated. | 114 // Arg1: class name of the abstract class that cannot be instantiated. |
| 115 // Return value: none, throws an exception. | 115 // Return value: none, throws an exception. |
| 116 DEFINE_NATIVE_ENTRY(AbstractClassInstantiationError_throwNew, 2) { | 116 DEFINE_NATIVE_ENTRY(AbstractClassInstantiationError_throwNew, 2) { |
| 117 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); | 117 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); |
| 118 GET_NATIVE_ARGUMENT(String, class_name, arguments->NativeArgAt(1)); | 118 GET_NON_NULL_NATIVE_ARGUMENT(String, class_name, arguments->NativeArgAt(1)); |
| 119 intptr_t error_pos = smi_pos.Value(); | 119 intptr_t error_pos = smi_pos.Value(); |
| 120 | 120 |
| 121 // Allocate a new instance of type AbstractClassInstantiationError. | 121 // Allocate a new instance of type AbstractClassInstantiationError. |
| 122 const Instance& error = Instance::Handle(Exceptions::NewInstance( | 122 const Instance& error = Instance::Handle(Exceptions::NewInstance( |
| 123 "AbstractClassInstantiationErrorImplementation")); | 123 "AbstractClassInstantiationErrorImplementation")); |
| 124 ASSERT(!error.IsNull()); | 124 ASSERT(!error.IsNull()); |
| 125 | 125 |
| 126 // Initialize 'url', 'line' and 'className' fields. | 126 // Initialize 'url', 'line' and 'className' fields. |
| 127 DartFrameIterator iterator; | 127 DartFrameIterator iterator; |
| 128 iterator.NextFrame(); // Skip native call. | 128 iterator.NextFrame(); // Skip native call. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 139 UNREACHABLE(); | 139 UNREACHABLE(); |
| 140 return Object::null(); | 140 return Object::null(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 | 143 |
| 144 // Allocate and throw NoSuchMethodError. | 144 // Allocate and throw NoSuchMethodError. |
| 145 // Arg0: index of the call that was not resolved at compile time. | 145 // Arg0: index of the call that was not resolved at compile time. |
| 146 // Arg1: name of the method that was not resolved at compile time. | 146 // Arg1: name of the method that was not resolved at compile time. |
| 147 // Return value: none, throws an exception. | 147 // Return value: none, throws an exception. |
| 148 DEFINE_NATIVE_ENTRY(NoSuchMethodError_throwNew, 2) { | 148 DEFINE_NATIVE_ENTRY(NoSuchMethodError_throwNew, 2) { |
| 149 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); | 149 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); |
| 150 GET_NATIVE_ARGUMENT(String, function_name, arguments->NativeArgAt(1)); | 150 GET_NON_NULL_NATIVE_ARGUMENT( |
| 151 String, function_name, arguments->NativeArgAt(1)); |
| 151 intptr_t call_pos = smi_pos.Value(); | 152 intptr_t call_pos = smi_pos.Value(); |
| 152 // Allocate a new instance of type NoSuchMethodError. | 153 // Allocate a new instance of type NoSuchMethodError. |
| 153 const Instance& error = Instance::Handle( | 154 const Instance& error = Instance::Handle( |
| 154 Exceptions::NewInstance("NoSuchMethodErrorImplementation")); | 155 Exceptions::NewInstance("NoSuchMethodErrorImplementation")); |
| 155 ASSERT(!error.IsNull()); | 156 ASSERT(!error.IsNull()); |
| 156 | 157 |
| 157 // Initialize 'url', 'line', and 'column' fields. | 158 // Initialize 'url', 'line', and 'column' fields. |
| 158 DartFrameIterator iterator; | 159 DartFrameIterator iterator; |
| 159 iterator.NextFrame(); // Skip native call. | 160 iterator.NextFrame(); // Skip native call. |
| 160 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); | 161 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); |
| 161 const Class& cls = Class::Handle(error.clazz()); | 162 const Class& cls = Class::Handle(error.clazz()); |
| 162 Exceptions::SetLocationFields(error, cls, script, call_pos); | 163 Exceptions::SetLocationFields(error, cls, script, call_pos); |
| 163 Exceptions::SetField(error, cls, "functionName", function_name); | 164 Exceptions::SetField(error, cls, "functionName", function_name); |
| 164 | 165 |
| 165 intptr_t line, column; | 166 intptr_t line, column; |
| 166 script.GetTokenLocation(call_pos, &line, &column); | 167 script.GetTokenLocation(call_pos, &line, &column); |
| 167 Exceptions::SetField(error, cls, "failedResolutionLine", | 168 Exceptions::SetField(error, cls, "failedResolutionLine", |
| 168 String::Handle(script.GetLine(line))); | 169 String::Handle(script.GetLine(line))); |
| 169 | 170 |
| 170 Exceptions::Throw(error); | 171 Exceptions::Throw(error); |
| 171 UNREACHABLE(); | 172 UNREACHABLE(); |
| 172 return Object::null(); | 173 return Object::null(); |
| 173 } | 174 } |
| 174 | 175 |
| 175 } // namespace dart | 176 } // namespace dart |
| OLD | NEW |