| 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 "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "vm/deopt_instructions.h" | 25 #include "vm/deopt_instructions.h" |
| 26 #include "vm/disassembler.h" | 26 #include "vm/disassembler.h" |
| 27 #include "vm/double_conversion.h" | 27 #include "vm/double_conversion.h" |
| 28 #include "vm/exceptions.h" | 28 #include "vm/exceptions.h" |
| 29 #include "vm/flow_graph_builder.h" | 29 #include "vm/flow_graph_builder.h" |
| 30 #include "vm/flow_graph_compiler.h" | 30 #include "vm/flow_graph_compiler.h" |
| 31 #include "vm/growable_array.h" | 31 #include "vm/growable_array.h" |
| 32 #include "vm/heap.h" | 32 #include "vm/heap.h" |
| 33 #include "vm/intermediate_language.h" | 33 #include "vm/intermediate_language.h" |
| 34 #include "vm/intrinsifier.h" | 34 #include "vm/intrinsifier.h" |
| 35 #include "vm/longjump.h" | |
| 36 #include "vm/object_id_ring.h" | 35 #include "vm/object_id_ring.h" |
| 37 #include "vm/object_store.h" | 36 #include "vm/object_store.h" |
| 38 #include "vm/parser.h" | 37 #include "vm/parser.h" |
| 38 #include "vm/report.h" |
| 39 #include "vm/reusable_handles.h" | 39 #include "vm/reusable_handles.h" |
| 40 #include "vm/runtime_entry.h" | 40 #include "vm/runtime_entry.h" |
| 41 #include "vm/scopes.h" | 41 #include "vm/scopes.h" |
| 42 #include "vm/stack_frame.h" | 42 #include "vm/stack_frame.h" |
| 43 #include "vm/symbols.h" | 43 #include "vm/symbols.h" |
| 44 #include "vm/tags.h" | 44 #include "vm/tags.h" |
| 45 #include "vm/timer.h" | 45 #include "vm/timer.h" |
| 46 #include "vm/unicode.h" | 46 #include "vm/unicode.h" |
| 47 | 47 |
| 48 namespace dart { | 48 namespace dart { |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 cls = Class::New<Bool>(); | 699 cls = Class::New<Bool>(); |
| 700 isolate->object_store()->set_bool_class(cls); | 700 isolate->object_store()->set_bool_class(cls); |
| 701 *bool_true_ = Bool::New(true); | 701 *bool_true_ = Bool::New(true); |
| 702 *bool_false_ = Bool::New(false); | 702 *bool_false_ = Bool::New(false); |
| 703 | 703 |
| 704 *smi_illegal_cid_ = Smi::New(kIllegalCid); | 704 *smi_illegal_cid_ = Smi::New(kIllegalCid); |
| 705 | 705 |
| 706 String& error_str = String::Handle(); | 706 String& error_str = String::Handle(); |
| 707 error_str = String::New("SnapshotWriter Error", Heap::kOld); | 707 error_str = String::New("SnapshotWriter Error", Heap::kOld); |
| 708 *snapshot_writer_error_ = LanguageError::New(error_str, | 708 *snapshot_writer_error_ = LanguageError::New(error_str, |
| 709 LanguageError::kError, | 709 Report::kError, |
| 710 Heap::kOld); | 710 Heap::kOld); |
| 711 error_str = String::New("Branch offset overflow", Heap::kOld); | 711 error_str = String::New("Branch offset overflow", Heap::kOld); |
| 712 *branch_offset_error_ = LanguageError::New(error_str, | 712 *branch_offset_error_ = LanguageError::New(error_str, |
| 713 LanguageError::kBailout, | 713 Report::kBailout, |
| 714 Heap::kOld); | 714 Heap::kOld); |
| 715 | 715 |
| 716 ASSERT(!null_object_->IsSmi()); | 716 ASSERT(!null_object_->IsSmi()); |
| 717 ASSERT(!null_array_->IsSmi()); | 717 ASSERT(!null_array_->IsSmi()); |
| 718 ASSERT(null_array_->IsArray()); | 718 ASSERT(null_array_->IsArray()); |
| 719 ASSERT(!null_string_->IsSmi()); | 719 ASSERT(!null_string_->IsSmi()); |
| 720 ASSERT(null_string_->IsString()); | 720 ASSERT(null_string_->IsString()); |
| 721 ASSERT(!null_instance_->IsSmi()); | 721 ASSERT(!null_instance_->IsSmi()); |
| 722 ASSERT(null_instance_->IsInstance()); | 722 ASSERT(null_instance_->IsInstance()); |
| 723 ASSERT(!null_type_arguments_->IsSmi()); | 723 ASSERT(!null_type_arguments_->IsSmi()); |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 result.set_num_native_fields(0); | 1760 result.set_num_native_fields(0); |
| 1761 result.set_token_pos(Scanner::kNoSourcePos); | 1761 result.set_token_pos(Scanner::kNoSourcePos); |
| 1762 result.InitEmptyFields(); | 1762 result.InitEmptyFields(); |
| 1763 Isolate::Current()->RegisterClass(result); | 1763 Isolate::Current()->RegisterClass(result); |
| 1764 return result.raw(); | 1764 return result.raw(); |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 | 1767 |
| 1768 | 1768 |
| 1769 static void ReportTooManyTypeArguments(const Class& cls) { | 1769 static void ReportTooManyTypeArguments(const Class& cls) { |
| 1770 const Error& error = Error::Handle( | 1770 Report::MessageF(Report::kError, |
| 1771 LanguageError::NewFormatted( | 1771 Script::Handle(cls.script()), |
| 1772 Error::Handle(), // No previous error. | 1772 cls.token_pos(), |
| 1773 Script::Handle(cls.script()), | 1773 "too many type parameters declared in class '%s' or in its " |
| 1774 cls.token_pos(), | 1774 "super classes", |
| 1775 LanguageError::kError, | 1775 String::Handle(cls.Name()).ToCString()); |
| 1776 Heap::kNew, | |
| 1777 "too many type parameters declared in class '%s' or in its " | |
| 1778 "super classes", | |
| 1779 String::Handle(cls.Name()).ToCString())); | |
| 1780 Isolate::Current()->long_jump_base()->Jump(1, error); | |
| 1781 UNREACHABLE(); | 1776 UNREACHABLE(); |
| 1782 } | 1777 } |
| 1783 | 1778 |
| 1784 | 1779 |
| 1785 void Class::set_num_type_arguments(intptr_t value) const { | 1780 void Class::set_num_type_arguments(intptr_t value) const { |
| 1786 if (!Utils::IsInt(16, value)) { | 1781 if (!Utils::IsInt(16, value)) { |
| 1787 ReportTooManyTypeArguments(*this); | 1782 ReportTooManyTypeArguments(*this); |
| 1788 } | 1783 } |
| 1789 raw_ptr()->num_type_arguments_ = value; | 1784 raw_ptr()->num_type_arguments_ = value; |
| 1790 } | 1785 } |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2646 new_functions.Add(orig_func); | 2641 new_functions.Add(orig_func); |
| 2647 } | 2642 } |
| 2648 } else if (func.UserVisibleSignature() != | 2643 } else if (func.UserVisibleSignature() != |
| 2649 orig_func.UserVisibleSignature()) { | 2644 orig_func.UserVisibleSignature()) { |
| 2650 // Compare user visible signatures to ignore different implicit parameters | 2645 // Compare user visible signatures to ignore different implicit parameters |
| 2651 // when patching a constructor with a factory. | 2646 // when patching a constructor with a factory. |
| 2652 *error = LanguageError::NewFormatted( | 2647 *error = LanguageError::NewFormatted( |
| 2653 *error, // No previous error. | 2648 *error, // No previous error. |
| 2654 Script::Handle(patch.script()), | 2649 Script::Handle(patch.script()), |
| 2655 func.token_pos(), | 2650 func.token_pos(), |
| 2656 LanguageError::kError, | 2651 Report::kError, |
| 2657 Heap::kNew, | 2652 Heap::kNew, |
| 2658 "signature mismatch: '%s'", member_name.ToCString()); | 2653 "signature mismatch: '%s'", member_name.ToCString()); |
| 2659 return false; | 2654 return false; |
| 2660 } | 2655 } |
| 2661 } | 2656 } |
| 2662 for (intptr_t i = 0; i < patch_len; i++) { | 2657 for (intptr_t i = 0; i < patch_len; i++) { |
| 2663 func ^= patch_list.At(i); | 2658 func ^= patch_list.At(i); |
| 2664 if (func.IsConstructor() || func.IsFactory()) { | 2659 if (func.IsConstructor() || func.IsFactory()) { |
| 2665 // Do not preserve the original implicit constructor, if any. | 2660 // Do not preserve the original implicit constructor, if any. |
| 2666 orig_implicit_ctor = Function::null(); | 2661 orig_implicit_ctor = Function::null(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2691 member_name = field.name(); | 2686 member_name = field.name(); |
| 2692 // TODO(iposva): Verify non-public fields only. | 2687 // TODO(iposva): Verify non-public fields only. |
| 2693 | 2688 |
| 2694 // Verify no duplicate additions. | 2689 // Verify no duplicate additions. |
| 2695 orig_field ^= LookupField(member_name); | 2690 orig_field ^= LookupField(member_name); |
| 2696 if (!orig_field.IsNull()) { | 2691 if (!orig_field.IsNull()) { |
| 2697 *error = LanguageError::NewFormatted( | 2692 *error = LanguageError::NewFormatted( |
| 2698 *error, // No previous error. | 2693 *error, // No previous error. |
| 2699 Script::Handle(patch.script()), | 2694 Script::Handle(patch.script()), |
| 2700 field.token_pos(), | 2695 field.token_pos(), |
| 2701 LanguageError::kError, | 2696 Report::kError, |
| 2702 Heap::kNew, | 2697 Heap::kNew, |
| 2703 "duplicate field: %s", member_name.ToCString()); | 2698 "duplicate field: %s", member_name.ToCString()); |
| 2704 return false; | 2699 return false; |
| 2705 } | 2700 } |
| 2706 new_list.SetAt(i, field); | 2701 new_list.SetAt(i, field); |
| 2707 } | 2702 } |
| 2708 for (intptr_t i = 0; i < orig_len; i++) { | 2703 for (intptr_t i = 0; i < orig_len; i++) { |
| 2709 field ^= orig_list.At(i); | 2704 field ^= orig_list.At(i); |
| 2710 new_list.SetAt(patch_len + i, field); | 2705 new_list.SetAt(patch_len + i, field); |
| 2711 } | 2706 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2793 | 2788 |
| 2794 // Ensure that top level parsing of the class has been done. | 2789 // Ensure that top level parsing of the class has been done. |
| 2795 RawError* Class::EnsureIsFinalized(Isolate* isolate) const { | 2790 RawError* Class::EnsureIsFinalized(Isolate* isolate) const { |
| 2796 // Finalized classes have already been parsed. | 2791 // Finalized classes have already been parsed. |
| 2797 if (is_finalized()) { | 2792 if (is_finalized()) { |
| 2798 return Error::null(); | 2793 return Error::null(); |
| 2799 } | 2794 } |
| 2800 ASSERT(isolate != NULL); | 2795 ASSERT(isolate != NULL); |
| 2801 const Error& error = Error::Handle(isolate, Compiler::CompileClass(*this)); | 2796 const Error& error = Error::Handle(isolate, Compiler::CompileClass(*this)); |
| 2802 if (!error.IsNull() && (isolate->long_jump_base() != NULL)) { | 2797 if (!error.IsNull() && (isolate->long_jump_base() != NULL)) { |
| 2803 isolate->long_jump_base()->Jump(1, error); | 2798 Report::LongJump(error); |
| 2804 UNREACHABLE(); | 2799 UNREACHABLE(); |
| 2805 } | 2800 } |
| 2806 return error.raw(); | 2801 return error.raw(); |
| 2807 } | 2802 } |
| 2808 | 2803 |
| 2809 | 2804 |
| 2810 void Class::SetFields(const Array& value) const { | 2805 void Class::SetFields(const Array& value) const { |
| 2811 ASSERT(!value.IsNull()); | 2806 ASSERT(!value.IsNull()); |
| 2812 #if defined(DEBUG) | 2807 #if defined(DEBUG) |
| 2813 // Verify that all the fields in the array have this class as owner. | 2808 // Verify that all the fields in the array have this class as owner. |
| (...skipping 2935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5749 // Check that this function's signature type is a subtype of the other | 5744 // Check that this function's signature type is a subtype of the other |
| 5750 // function's signature type. | 5745 // function's signature type. |
| 5751 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(), | 5746 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(), |
| 5752 other, Object::null_type_arguments(), bound_error)) { | 5747 other, Object::null_type_arguments(), bound_error)) { |
| 5753 // For more informative error reporting, use the location of the other | 5748 // For more informative error reporting, use the location of the other |
| 5754 // function here, since the caller will use the location of this function. | 5749 // function here, since the caller will use the location of this function. |
| 5755 *bound_error = LanguageError::NewFormatted( | 5750 *bound_error = LanguageError::NewFormatted( |
| 5756 *bound_error, // A bound error if non null. | 5751 *bound_error, // A bound error if non null. |
| 5757 Script::Handle(other.script()), | 5752 Script::Handle(other.script()), |
| 5758 other.token_pos(), | 5753 other.token_pos(), |
| 5759 LanguageError::kError, | 5754 Report::kError, |
| 5760 Heap::kNew, | 5755 Heap::kNew, |
| 5761 "signature type '%s' of function '%s' is not a subtype of signature " | 5756 "signature type '%s' of function '%s' is not a subtype of signature " |
| 5762 "type '%s' of function '%s'", | 5757 "type '%s' of function '%s'", |
| 5763 String::Handle(UserVisibleSignature()).ToCString(), | 5758 String::Handle(UserVisibleSignature()).ToCString(), |
| 5764 String::Handle(UserVisibleName()).ToCString(), | 5759 String::Handle(UserVisibleName()).ToCString(), |
| 5765 String::Handle(other.UserVisibleSignature()).ToCString(), | 5760 String::Handle(other.UserVisibleSignature()).ToCString(), |
| 5766 String::Handle(other.UserVisibleName()).ToCString()); | 5761 String::Handle(other.UserVisibleName()).ToCString()); |
| 5767 return false; | 5762 return false; |
| 5768 } | 5763 } |
| 5769 // We should also check that if the other function explicitly specifies a | 5764 // We should also check that if the other function explicitly specifies a |
| (...skipping 6770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12540 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 12535 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
| 12541 LanguageError::InstanceSize(), | 12536 LanguageError::InstanceSize(), |
| 12542 Heap::kOld); | 12537 Heap::kOld); |
| 12543 return reinterpret_cast<RawLanguageError*>(raw); | 12538 return reinterpret_cast<RawLanguageError*>(raw); |
| 12544 } | 12539 } |
| 12545 | 12540 |
| 12546 | 12541 |
| 12547 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, | 12542 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, |
| 12548 const Script& script, | 12543 const Script& script, |
| 12549 intptr_t token_pos, | 12544 intptr_t token_pos, |
| 12550 Kind kind, | 12545 Report::Kind kind, |
| 12551 Heap::Space space, | 12546 Heap::Space space, |
| 12552 const char* format, | 12547 const char* format, |
| 12553 va_list args) { | 12548 va_list args) { |
| 12554 ASSERT(Object::language_error_class() != Class::null()); | 12549 ASSERT(Object::language_error_class() != Class::null()); |
| 12555 LanguageError& result = LanguageError::Handle(); | 12550 LanguageError& result = LanguageError::Handle(); |
| 12556 { | 12551 { |
| 12557 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 12552 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
| 12558 LanguageError::InstanceSize(), | 12553 LanguageError::InstanceSize(), |
| 12559 space); | 12554 space); |
| 12560 NoGCScope no_gc; | 12555 NoGCScope no_gc; |
| 12561 result ^= raw; | 12556 result ^= raw; |
| 12562 } | 12557 } |
| 12563 result.set_previous_error(prev_error); | 12558 result.set_previous_error(prev_error); |
| 12564 result.set_script(script); | 12559 result.set_script(script); |
| 12565 result.set_token_pos(token_pos); | 12560 result.set_token_pos(token_pos); |
| 12566 result.set_kind(kind); | 12561 result.set_kind(kind); |
| 12567 result.set_message(String::Handle(String::NewFormattedV(format, args))); | 12562 result.set_message(String::Handle(String::NewFormattedV(format, args))); |
| 12568 return result.raw(); | 12563 return result.raw(); |
| 12569 } | 12564 } |
| 12570 | 12565 |
| 12571 | 12566 |
| 12572 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, | 12567 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, |
| 12573 const Script& script, | 12568 const Script& script, |
| 12574 intptr_t token_pos, | 12569 intptr_t token_pos, |
| 12575 Kind kind, | 12570 Report::Kind kind, |
| 12576 Heap::Space space, | 12571 Heap::Space space, |
| 12577 const char* format, ...) { | 12572 const char* format, ...) { |
| 12578 va_list args; | 12573 va_list args; |
| 12579 va_start(args, format); | 12574 va_start(args, format); |
| 12580 RawLanguageError* result = LanguageError::NewFormattedV( | 12575 RawLanguageError* result = LanguageError::NewFormattedV( |
| 12581 prev_error, script, token_pos, kind, space, format, args); | 12576 prev_error, script, token_pos, kind, space, format, args); |
| 12582 NoGCScope no_gc; | 12577 NoGCScope no_gc; |
| 12583 va_end(args); | 12578 va_end(args); |
| 12584 return result; | 12579 return result; |
| 12585 } | 12580 } |
| 12586 | 12581 |
| 12587 | 12582 |
| 12588 RawLanguageError* LanguageError::New(const String& formatted_message, | 12583 RawLanguageError* LanguageError::New(const String& formatted_message, |
| 12589 Kind kind, | 12584 Report::Kind kind, |
| 12590 Heap::Space space) { | 12585 Heap::Space space) { |
| 12591 ASSERT(Object::language_error_class() != Class::null()); | 12586 ASSERT(Object::language_error_class() != Class::null()); |
| 12592 LanguageError& result = LanguageError::Handle(); | 12587 LanguageError& result = LanguageError::Handle(); |
| 12593 { | 12588 { |
| 12594 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 12589 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
| 12595 LanguageError::InstanceSize(), | 12590 LanguageError::InstanceSize(), |
| 12596 space); | 12591 space); |
| 12597 NoGCScope no_gc; | 12592 NoGCScope no_gc; |
| 12598 result ^= raw; | 12593 result ^= raw; |
| 12599 } | 12594 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12631 | 12626 |
| 12632 void LanguageError::set_formatted_message(const String& value) const { | 12627 void LanguageError::set_formatted_message(const String& value) const { |
| 12633 StorePointer(&raw_ptr()->formatted_message_, value.raw()); | 12628 StorePointer(&raw_ptr()->formatted_message_, value.raw()); |
| 12634 } | 12629 } |
| 12635 | 12630 |
| 12636 | 12631 |
| 12637 RawString* LanguageError::FormatMessage() const { | 12632 RawString* LanguageError::FormatMessage() const { |
| 12638 if (formatted_message() != String::null()) { | 12633 if (formatted_message() != String::null()) { |
| 12639 return formatted_message(); | 12634 return formatted_message(); |
| 12640 } | 12635 } |
| 12641 const char* message_header; | 12636 String& result = String::Handle( |
| 12642 switch (kind()) { | 12637 Report::PrependSnippet(kind(), |
| 12643 case kWarning: message_header = "warning"; break; | 12638 Script::Handle(script()), |
| 12644 case kError: message_header = "error"; break; | 12639 token_pos(), |
| 12645 case kMalformedType: message_header = "malformed type"; break; | 12640 String::Handle(message()))); |
| 12646 case kMalboundedType: message_header = "malbounded type"; break; | |
| 12647 case kBailout: message_header = "bailout"; break; | |
| 12648 default: message_header = ""; UNREACHABLE(); | |
| 12649 } | |
| 12650 String& result = String::Handle(); | |
| 12651 String& msg = String::Handle(message()); | |
| 12652 const Script& scr = Script::Handle(script()); | |
| 12653 if (!scr.IsNull()) { | |
| 12654 const String& script_url = String::Handle(scr.url()); | |
| 12655 if (token_pos() >= 0) { | |
| 12656 intptr_t line, column; | |
| 12657 scr.GetTokenLocation(token_pos(), &line, &column); | |
| 12658 // Only report the line position if we have the original source. We still | |
| 12659 // need to get a valid column so that we can report the ^ mark below the | |
| 12660 // snippet. | |
| 12661 if (scr.HasSource()) { | |
| 12662 result = String::NewFormatted("'%s': %s: line %" Pd " pos %" Pd ": ", | |
| 12663 script_url.ToCString(), | |
| 12664 message_header, | |
| 12665 line, | |
| 12666 column); | |
| 12667 } else { | |
| 12668 result = String::NewFormatted("'%s': %s: line %" Pd ": ", | |
| 12669 script_url.ToCString(), | |
| 12670 message_header, | |
| 12671 line); | |
| 12672 } | |
| 12673 // Append the formatted error or warning message. | |
| 12674 result = String::Concat(result, msg); | |
| 12675 // Append the source line. | |
| 12676 const String& script_line = String::Handle(scr.GetLine(line)); | |
| 12677 ASSERT(!script_line.IsNull()); | |
| 12678 result = String::Concat(result, Symbols::NewLine()); | |
| 12679 result = String::Concat(result, script_line); | |
| 12680 result = String::Concat(result, Symbols::NewLine()); | |
| 12681 // Append the column marker. | |
| 12682 const String& column_line = String::Handle( | |
| 12683 String::NewFormatted("%*s\n", static_cast<int>(column), "^")); | |
| 12684 result = String::Concat(result, column_line); | |
| 12685 } else { | |
| 12686 // Token position is unknown. | |
| 12687 result = String::NewFormatted("'%s': %s: ", | |
| 12688 script_url.ToCString(), | |
| 12689 message_header); | |
| 12690 result = String::Concat(result, msg); | |
| 12691 } | |
| 12692 } else { | |
| 12693 // Script is unknown. | |
| 12694 // Append the formatted error or warning message. | |
| 12695 result = String::NewFormatted("%s: ", message_header); | |
| 12696 result = String::Concat(result, msg); | |
| 12697 } | |
| 12698 // Prepend previous error message. | 12641 // Prepend previous error message. |
| 12699 const Error& prev_error = Error::Handle(previous_error()); | 12642 const Error& prev_error = Error::Handle(previous_error()); |
| 12700 if (!prev_error.IsNull()) { | 12643 if (!prev_error.IsNull()) { |
| 12701 msg = String::New(prev_error.ToErrorCString()); | 12644 result = String::Concat( |
| 12702 result = String::Concat(msg, result); | 12645 String::Handle(String::New(prev_error.ToErrorCString())), result); |
| 12703 } | 12646 } |
| 12704 set_formatted_message(result); | 12647 set_formatted_message(result); |
| 12705 return result.raw(); | 12648 return result.raw(); |
| 12706 } | 12649 } |
| 12707 | 12650 |
| 12708 | 12651 |
| 12709 const char* LanguageError::ToErrorCString() const { | 12652 const char* LanguageError::ToErrorCString() const { |
| 12710 const String& msg_str = String::Handle(FormatMessage()); | 12653 const String& msg_str = String::Handle(FormatMessage()); |
| 12711 return msg_str.ToCString(); | 12654 return msg_str.ToCString(); |
| 12712 } | 12655 } |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13947 ASSERT(IsResolved() && !IsFinalized() && !IsBeingFinalized()); | 13890 ASSERT(IsResolved() && !IsFinalized() && !IsBeingFinalized()); |
| 13948 set_type_state(RawType::kBeingFinalized); | 13891 set_type_state(RawType::kBeingFinalized); |
| 13949 } | 13892 } |
| 13950 | 13893 |
| 13951 | 13894 |
| 13952 bool Type::IsMalformed() const { | 13895 bool Type::IsMalformed() const { |
| 13953 if (raw_ptr()->error_ == LanguageError::null()) { | 13896 if (raw_ptr()->error_ == LanguageError::null()) { |
| 13954 return false; | 13897 return false; |
| 13955 } | 13898 } |
| 13956 const LanguageError& type_error = LanguageError::Handle(error()); | 13899 const LanguageError& type_error = LanguageError::Handle(error()); |
| 13957 return type_error.kind() == LanguageError::kMalformedType; | 13900 return type_error.kind() == Report::kMalformedType; |
| 13958 } | 13901 } |
| 13959 | 13902 |
| 13960 | 13903 |
| 13961 bool Type::IsMalbounded() const { | 13904 bool Type::IsMalbounded() const { |
| 13962 if (!FLAG_enable_type_checks) { | 13905 if (!FLAG_enable_type_checks) { |
| 13963 return false; | 13906 return false; |
| 13964 } | 13907 } |
| 13965 if (raw_ptr()->error_ == LanguageError::null()) { | 13908 if (raw_ptr()->error_ == LanguageError::null()) { |
| 13966 return false; | 13909 return false; |
| 13967 } | 13910 } |
| 13968 const LanguageError& type_error = LanguageError::Handle(error()); | 13911 const LanguageError& type_error = LanguageError::Handle(error()); |
| 13969 return type_error.kind() == LanguageError::kMalboundedType; | 13912 return type_error.kind() == Report::kMalboundedType; |
| 13970 } | 13913 } |
| 13971 | 13914 |
| 13972 | 13915 |
| 13973 bool Type::IsMalformedOrMalbounded() const { | 13916 bool Type::IsMalformedOrMalbounded() const { |
| 13974 if (raw_ptr()->error_ == LanguageError::null()) { | 13917 if (raw_ptr()->error_ == LanguageError::null()) { |
| 13975 return false; | 13918 return false; |
| 13976 } | 13919 } |
| 13977 const LanguageError& type_error = LanguageError::Handle(error()); | 13920 const LanguageError& type_error = LanguageError::Handle(error()); |
| 13978 if (type_error.kind() == LanguageError::kMalformedType) { | 13921 if (type_error.kind() == Report::kMalformedType) { |
| 13979 return true; | 13922 return true; |
| 13980 } | 13923 } |
| 13981 ASSERT(type_error.kind() == LanguageError::kMalboundedType); | 13924 ASSERT(type_error.kind() == Report::kMalboundedType); |
| 13982 return FLAG_enable_type_checks; | 13925 return FLAG_enable_type_checks; |
| 13983 } | 13926 } |
| 13984 | 13927 |
| 13985 | 13928 |
| 13986 void Type::set_error(const LanguageError& value) const { | 13929 void Type::set_error(const LanguageError& value) const { |
| 13987 StorePointer(&raw_ptr()->error_, value.raw()); | 13930 StorePointer(&raw_ptr()->error_, value.raw()); |
| 13988 } | 13931 } |
| 13989 | 13932 |
| 13990 | 13933 |
| 13991 void Type::set_is_resolved() const { | 13934 void Type::set_is_resolved() const { |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14710 const String& type_param_name = String::Handle(UserVisibleName()); | 14653 const String& type_param_name = String::Handle(UserVisibleName()); |
| 14711 const Class& cls = Class::Handle(parameterized_class()); | 14654 const Class& cls = Class::Handle(parameterized_class()); |
| 14712 const String& class_name = String::Handle(cls.Name()); | 14655 const String& class_name = String::Handle(cls.Name()); |
| 14713 const Script& script = Script::Handle(cls.script()); | 14656 const Script& script = Script::Handle(cls.script()); |
| 14714 // Since the bound may have been canonicalized, its token index is | 14657 // Since the bound may have been canonicalized, its token index is |
| 14715 // meaningless, therefore use the token index of this type parameter. | 14658 // meaningless, therefore use the token index of this type parameter. |
| 14716 *bound_error = LanguageError::NewFormatted( | 14659 *bound_error = LanguageError::NewFormatted( |
| 14717 *bound_error, | 14660 *bound_error, |
| 14718 script, | 14661 script, |
| 14719 token_pos(), | 14662 token_pos(), |
| 14720 LanguageError::kMalboundedType, | 14663 Report::kMalboundedType, |
| 14721 Heap::kNew, | 14664 Heap::kNew, |
| 14722 "type parameter '%s' of class '%s' must extend bound '%s', " | 14665 "type parameter '%s' of class '%s' must extend bound '%s', " |
| 14723 "but type argument '%s' is not a subtype of '%s'\n", | 14666 "but type argument '%s' is not a subtype of '%s'\n", |
| 14724 type_param_name.ToCString(), | 14667 type_param_name.ToCString(), |
| 14725 class_name.ToCString(), | 14668 class_name.ToCString(), |
| 14726 declared_bound_name.ToCString(), | 14669 declared_bound_name.ToCString(), |
| 14727 bounded_type_name.ToCString(), | 14670 bounded_type_name.ToCString(), |
| 14728 upper_bound_name.ToCString()); | 14671 upper_bound_name.ToCString()); |
| 14729 } | 14672 } |
| 14730 } | 14673 } |
| (...skipping 4357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19088 return tag_label.ToCString(); | 19031 return tag_label.ToCString(); |
| 19089 } | 19032 } |
| 19090 | 19033 |
| 19091 | 19034 |
| 19092 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19035 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19093 Instance::PrintJSONImpl(stream, ref); | 19036 Instance::PrintJSONImpl(stream, ref); |
| 19094 } | 19037 } |
| 19095 | 19038 |
| 19096 | 19039 |
| 19097 } // namespace dart | 19040 } // namespace dart |
| OLD | NEW |