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 "platform/address_sanitizer.h" | 7 #include "platform/address_sanitizer.h" |
8 | 8 |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 const Array& args = Array::Handle(Array::New(1)); | 554 const Array& args = Array::Handle(Array::New(1)); |
555 args.SetAt(0, arg); | 555 args.SetAt(0, arg); |
556 Exceptions::ThrowByType(Exceptions::kArgument, args); | 556 Exceptions::ThrowByType(Exceptions::kArgument, args); |
557 } | 557 } |
558 | 558 |
559 | 559 |
560 void Exceptions::ThrowRangeError(const char* argument_name, | 560 void Exceptions::ThrowRangeError(const char* argument_name, |
561 const Integer& argument_value, | 561 const Integer& argument_value, |
562 intptr_t expected_from, | 562 intptr_t expected_from, |
563 intptr_t expected_to) { | 563 intptr_t expected_to) { |
564 const String& error = String::Handle(String::NewFormatted( | 564 const Array& args = Array::Handle(Array::New(4)); |
565 "%s (%s) must be in the range [%" Pd "..%" Pd ")", | 565 args.SetAt(0, argument_value); |
566 argument_name, | 566 args.SetAt(1, Integer::Handle(Integer::New(expected_from))); |
567 argument_value.ToCString(), | 567 args.SetAt(2, Integer::Handle(Integer::New(expected_to))); |
568 expected_from, | 568 args.SetAt(3, String::Handle(String::New(argument_name))); |
569 expected_to)); | 569 Exceptions::ThrowByType(Exceptions::kRangeRange, args); |
570 | |
571 const Array& args = Array::Handle(Array::New(1)); | |
572 args.SetAt(0, error); | |
573 Exceptions::ThrowByType(Exceptions::kRange, args); | |
574 } | 570 } |
575 | 571 |
576 | 572 |
577 RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) { | 573 RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) { |
578 Library& library = Library::Handle(); | 574 Library& library = Library::Handle(); |
579 const String* class_name = NULL; | 575 const String* class_name = NULL; |
580 const String* constructor_name = &Symbols::Dot(); | 576 const String* constructor_name = &Symbols::Dot(); |
581 switch (type) { | 577 switch (type) { |
582 case kNone: | 578 case kNone: |
583 case kStackOverflow: | 579 case kStackOverflow: |
584 case kOutOfMemory: | 580 case kOutOfMemory: |
585 UNREACHABLE(); | 581 UNREACHABLE(); |
586 break; | 582 break; |
587 case kRange: | 583 case kRange: |
588 library = Library::CoreLibrary(); | 584 library = Library::CoreLibrary(); |
589 class_name = &Symbols::RangeError(); | 585 class_name = &Symbols::RangeError(); |
590 break; | 586 break; |
| 587 case kRangeRange: |
| 588 library = Library::CoreLibrary(); |
| 589 class_name = &Symbols::RangeError(); |
| 590 constructor_name = &Symbols::DotRange(); |
| 591 break; |
591 case kArgument: | 592 case kArgument: |
592 library = Library::CoreLibrary(); | 593 library = Library::CoreLibrary(); |
593 class_name = &Symbols::ArgumentError(); | 594 class_name = &Symbols::ArgumentError(); |
594 break; | 595 break; |
595 case kNoSuchMethod: | 596 case kNoSuchMethod: |
596 library = Library::CoreLibrary(); | 597 library = Library::CoreLibrary(); |
597 class_name = &Symbols::NoSuchMethodError(); | 598 class_name = &Symbols::NoSuchMethodError(); |
598 constructor_name = &Symbols::DotWithType(); | 599 constructor_name = &Symbols::DotWithType(); |
599 break; | 600 break; |
600 case kFormat: | 601 case kFormat: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 | 665 |
665 // Throw JavascriptCompatibilityError exception. | 666 // Throw JavascriptCompatibilityError exception. |
666 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { | 667 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { |
667 const Array& exc_args = Array::Handle(Array::New(1)); | 668 const Array& exc_args = Array::Handle(Array::New(1)); |
668 const String& msg_str = String::Handle(String::New(msg)); | 669 const String& msg_str = String::Handle(String::New(msg)); |
669 exc_args.SetAt(0, msg_str); | 670 exc_args.SetAt(0, msg_str); |
670 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); | 671 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); |
671 } | 672 } |
672 | 673 |
673 } // namespace dart | 674 } // namespace dart |
OLD | NEW |