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 #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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 intptr_t line, column; | 196 intptr_t line, column; |
197 script.GetTokenLocation(fallthrough_pos, &line, &column); | 197 script.GetTokenLocation(fallthrough_pos, &line, &column); |
198 SetField(fallthrough_error, cls, "line", Smi::Handle(Smi::New(line))); | 198 SetField(fallthrough_error, cls, "line", Smi::Handle(Smi::New(line))); |
199 | 199 |
200 // Throw FallThroughError instance. | 200 // Throw FallThroughError instance. |
201 Exceptions::Throw(fallthrough_error); | 201 Exceptions::Throw(fallthrough_error); |
202 UNREACHABLE(); | 202 UNREACHABLE(); |
203 } | 203 } |
204 | 204 |
205 | 205 |
| 206 // Allocate and throw StaticResolutionException. |
| 207 // Arg0: index of the static call that was not resolved at compile time. |
| 208 // Return value: none, throws an exception. |
| 209 DEFINE_NATIVE_ENTRY(StaticResolutionException_throwNew, 1) { |
| 210 GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->At(0)); |
| 211 intptr_t call_pos = smi_pos.Value(); |
| 212 // Allocate a new instance of type StaticResolutionException. |
| 213 const Instance& resolution_exception = |
| 214 Instance::Handle(NewInstance("StaticResolutionException")); |
| 215 ASSERT(!resolution_exception.IsNull()); |
| 216 |
| 217 // Initialize 'url', 'line', and 'column' fields. |
| 218 DartFrameIterator iterator; |
| 219 iterator.NextFrame(); // Skip native call. |
| 220 const Script& script = Script::Handle(GetCallerScript(&iterator)); |
| 221 const Class& cls = Class::Handle(resolution_exception.clazz()); |
| 222 SetLocationFields(resolution_exception, cls, script, call_pos); |
| 223 |
| 224 intptr_t line, column; |
| 225 script.GetTokenLocation(call_pos, &line, &column); |
| 226 SetField(resolution_exception, cls, "failedResolutionLine", |
| 227 String::Handle(script.GetLine(line))); |
| 228 |
| 229 Exceptions::Throw(resolution_exception); |
| 230 UNREACHABLE(); |
| 231 } |
| 232 |
| 233 |
206 // Check that the type of the given instance is assignable to the given type. | 234 // Check that the type of the given instance is assignable to the given type. |
207 // Arg0: index of the token of the assignment (source location). | 235 // Arg0: index of the token of the assignment (source location). |
208 // Arg1: instance being assigned. | 236 // Arg1: instance being assigned. |
209 // Arg2: type being assigned to. | 237 // Arg2: type being assigned to. |
210 // Arg3: type arguments of the instantiator of the type being assigned to. | 238 // Arg3: type arguments of the instantiator of the type being assigned to. |
211 // Arg4: name of instance being assigned to. | 239 // Arg4: name of instance being assigned to. |
212 // Return value: instance if assignable, otherwise throw a TypeError. | 240 // Return value: instance if assignable, otherwise throw a TypeError. |
213 DEFINE_RUNTIME_ENTRY(TypeCheck, 5) { | 241 DEFINE_RUNTIME_ENTRY(TypeCheck, 5) { |
214 ASSERT(arguments.Count() == kTypeCheckRuntimeEntry.argument_count()); | 242 ASSERT(arguments.Count() == kTypeCheckRuntimeEntry.argument_count()); |
215 intptr_t location = Smi::CheckedHandle(arguments.At(0)).Value(); | 243 intptr_t location = Smi::CheckedHandle(arguments.At(0)).Value(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 dst_type_name = element_type.Name(); | 355 dst_type_name = element_type.Name(); |
328 } | 356 } |
329 const String& dst_name = String::Handle(String::New(buf)); | 357 const String& dst_name = String::Handle(String::New(buf)); |
330 ThrowTypeError(location, src_type_name, dst_type_name, dst_name); | 358 ThrowTypeError(location, src_type_name, dst_type_name, dst_name); |
331 UNREACHABLE(); | 359 UNREACHABLE(); |
332 } | 360 } |
333 } | 361 } |
334 } | 362 } |
335 | 363 |
336 } // namespace dart | 364 } // namespace dart |
OLD | NEW |