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 "vm/exceptions.h" | 5 #include "vm/exceptions.h" |
6 | 6 |
7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 const String& dst_name, | 498 const String& dst_name, |
499 const String& bound_error) { | 499 const String& bound_error) { |
500 const Array& args = Array::Handle(Array::New(7)); | 500 const Array& args = Array::Handle(Array::New(7)); |
501 | 501 |
502 ExceptionType exception_type = | 502 ExceptionType exception_type = |
503 (bound_error.IsNull() && dst_name.Equals(kCastErrorDstName)) ? | 503 (bound_error.IsNull() && dst_name.Equals(kCastErrorDstName)) ? |
504 kCast : kType; | 504 kCast : kType; |
505 | 505 |
506 DartFrameIterator iterator; | 506 DartFrameIterator iterator; |
507 const Script& script = Script::Handle(GetCallerScript(&iterator)); | 507 const Script& script = Script::Handle(GetCallerScript(&iterator)); |
508 intptr_t line, column; | 508 intptr_t line; |
509 script.GetTokenLocation(location, &line, &column); | 509 intptr_t column = -1; |
| 510 if (script.HasSource()) { |
| 511 script.GetTokenLocation(location, &line, &column); |
| 512 } else { |
| 513 script.GetTokenLocation(location, &line, NULL); |
| 514 } |
510 // Initialize '_url', '_line', and '_column' arguments. | 515 // Initialize '_url', '_line', and '_column' arguments. |
511 args.SetAt(0, String::Handle(script.url())); | 516 args.SetAt(0, String::Handle(script.url())); |
512 args.SetAt(1, Smi::Handle(Smi::New(line))); | 517 args.SetAt(1, Smi::Handle(Smi::New(line))); |
513 args.SetAt(2, Smi::Handle(Smi::New(column))); | 518 args.SetAt(2, Smi::Handle(Smi::New(column))); |
514 | 519 |
515 // Initialize '_srcType', '_dstType', '_dstName', and '_boundError'. | 520 // Initialize '_srcType', '_dstType', '_dstName', and '_boundError'. |
516 args.SetAt(3, src_type_name); | 521 args.SetAt(3, src_type_name); |
517 args.SetAt(4, dst_type_name); | 522 args.SetAt(4, dst_type_name); |
518 args.SetAt(5, dst_name); | 523 args.SetAt(5, dst_name); |
519 args.SetAt(6, bound_error); | 524 args.SetAt(6, bound_error); |
520 | 525 |
521 // Type errors in the core library may be difficult to diagnose. | 526 // Type errors in the core library may be difficult to diagnose. |
522 // Print type error information before throwing the error when debugging. | 527 // Print type error information before throwing the error when debugging. |
523 if (FLAG_print_stacktrace_at_throw) { | 528 if (FLAG_print_stacktrace_at_throw) { |
524 if (!bound_error.IsNull()) { | 529 if (!bound_error.IsNull()) { |
525 OS::Print("%s\n", bound_error.ToCString()); | 530 OS::Print("%s\n", bound_error.ToCString()); |
526 } | 531 } |
527 intptr_t line, column; | |
528 script.GetTokenLocation(location, &line, &column); | |
529 OS::Print("'%s': Failed type check: line %" Pd " pos %" Pd ": ", | 532 OS::Print("'%s': Failed type check: line %" Pd " pos %" Pd ": ", |
530 String::Handle(script.url()).ToCString(), line, column); | 533 String::Handle(script.url()).ToCString(), line, column); |
531 if (!dst_name.IsNull() && (dst_name.Length() > 0)) { | 534 if (!dst_name.IsNull() && (dst_name.Length() > 0)) { |
532 OS::Print("type '%s' is not a subtype of type '%s' of '%s'.\n", | 535 OS::Print("type '%s' is not a subtype of type '%s' of '%s'.\n", |
533 src_type_name.ToCString(), | 536 src_type_name.ToCString(), |
534 dst_type_name.ToCString(), | 537 dst_type_name.ToCString(), |
535 dst_name.ToCString()); | 538 dst_name.ToCString()); |
536 } else { | 539 } else { |
537 OS::Print("malbounded type used.\n"); | 540 OS::Print("malbounded type used.\n"); |
538 } | 541 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 break; | 703 break; |
701 } | 704 } |
702 | 705 |
703 return DartLibraryCalls::InstanceCreate(library, | 706 return DartLibraryCalls::InstanceCreate(library, |
704 *class_name, | 707 *class_name, |
705 *constructor_name, | 708 *constructor_name, |
706 arguments); | 709 arguments); |
707 } | 710 } |
708 | 711 |
709 } // namespace dart | 712 } // namespace dart |
OLD | NEW |