| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 script.GetTokenLocation(error_pos, &line, &column); | 133 script.GetTokenLocation(error_pos, &line, &column); |
| 134 Exceptions::SetField(error, cls, "line", Smi::Handle(Smi::New(line))); | 134 Exceptions::SetField(error, cls, "line", Smi::Handle(Smi::New(line))); |
| 135 Exceptions::SetField(error, cls, "className", class_name); | 135 Exceptions::SetField(error, cls, "className", class_name); |
| 136 | 136 |
| 137 // Throw AbstractClassInstantiationError instance. | 137 // Throw AbstractClassInstantiationError instance. |
| 138 Exceptions::Throw(error); | 138 Exceptions::Throw(error); |
| 139 UNREACHABLE(); | 139 UNREACHABLE(); |
| 140 return Object::null(); | 140 return Object::null(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 | |
| 144 // TODO(regis): This helper is used to compile a throw when a call cannot be | |
| 145 // resolved at compile time. The thrown instance of NoSuchMethodError is of a | |
| 146 // different type than a NoSuchMethodError thrown at runtime. This should be | |
| 147 // merged. | |
| 148 // | |
| 149 // Allocate and throw NoSuchMethodError. | |
| 150 // Arg0: index of the call that was not resolved at compile time. | |
| 151 // Arg1: name of the method that was not resolved at compile time. | |
| 152 // Return value: none, throws an exception. | |
| 153 DEFINE_NATIVE_ENTRY(NoSuchMethodError_throwNew, 2) { | |
| 154 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); | |
| 155 GET_NON_NULL_NATIVE_ARGUMENT( | |
| 156 String, function_name, arguments->NativeArgAt(1)); | |
| 157 intptr_t call_pos = smi_pos.Value(); | |
| 158 // Allocate a new instance of type NoSuchMethodError. | |
| 159 const Instance& error = Instance::Handle( | |
| 160 Exceptions::NewInstance("NoSuchMethodErrorImplementation")); | |
| 161 ASSERT(!error.IsNull()); | |
| 162 | |
| 163 // Initialize 'url', 'line', and 'column' fields. | |
| 164 DartFrameIterator iterator; | |
| 165 iterator.NextFrame(); // Skip native call. | |
| 166 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); | |
| 167 const Class& cls = Class::Handle(error.clazz()); | |
| 168 Exceptions::SetLocationFields(error, cls, script, call_pos); | |
| 169 Exceptions::SetField(error, cls, "functionName", function_name); | |
| 170 | |
| 171 intptr_t line, column; | |
| 172 script.GetTokenLocation(call_pos, &line, &column); | |
| 173 Exceptions::SetField(error, cls, "failedResolutionLine", | |
| 174 String::Handle(script.GetLine(line))); | |
| 175 | |
| 176 Exceptions::Throw(error); | |
| 177 UNREACHABLE(); | |
| 178 return Object::null(); | |
| 179 } | |
| 180 | |
| 181 } // namespace dart | 143 } // namespace dart |
| OLD | NEW |