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 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 result.set_num_type_arguments(0); | 1673 result.set_num_type_arguments(0); |
1674 result.set_num_own_type_arguments(0); | 1674 result.set_num_own_type_arguments(0); |
1675 result.set_num_native_fields(0); | 1675 result.set_num_native_fields(0); |
1676 result.set_token_pos(Scanner::kDummyTokenIndex); | 1676 result.set_token_pos(Scanner::kDummyTokenIndex); |
1677 result.InitEmptyFields(); | 1677 result.InitEmptyFields(); |
1678 Isolate::Current()->RegisterClass(result); | 1678 Isolate::Current()->RegisterClass(result); |
1679 return result.raw(); | 1679 return result.raw(); |
1680 } | 1680 } |
1681 | 1681 |
1682 | 1682 |
1683 static RawError* FormatError(const Error& prev_error, | |
1684 const Script& script, | |
1685 intptr_t token_pos, | |
1686 const char* format, ...) { | |
1687 va_list args; | |
1688 va_start(args, format); | |
1689 if (prev_error.IsNull()) { | |
1690 return Parser::FormatError(script, token_pos, "Error", format, args); | |
1691 } else { | |
1692 return Parser::FormatErrorWithAppend(prev_error, script, token_pos, | |
1693 "Error", format, args); | |
1694 } | |
1695 } | |
1696 | |
1697 | 1683 |
1698 static void ReportTooManyTypeArguments(const Class& cls) { | 1684 static void ReportTooManyTypeArguments(const Class& cls) { |
1699 const Error& error = Error::Handle( | 1685 const Error& error = Error::Handle( |
1700 FormatError(Error::Handle(), // No previous error. | 1686 LanguageError::NewFormatted( |
1701 Script::Handle(cls.script()), cls.token_pos(), | 1687 Error::Handle(), // No previous error. |
1702 "too many type parameters declared in class '%s' or in its " | 1688 Script::Handle(cls.script()), |
1703 "super classes", | 1689 cls.token_pos(), |
1704 String::Handle(cls.Name()).ToCString())); | 1690 LanguageError::kError, |
| 1691 Heap::kNew, |
| 1692 "too many type parameters declared in class '%s' or in its " |
| 1693 "super classes", |
| 1694 String::Handle(cls.Name()).ToCString())); |
1705 Isolate::Current()->long_jump_base()->Jump(1, error); | 1695 Isolate::Current()->long_jump_base()->Jump(1, error); |
1706 UNREACHABLE(); | 1696 UNREACHABLE(); |
1707 } | 1697 } |
1708 | 1698 |
1709 | 1699 |
1710 void Class::set_num_type_arguments(intptr_t value) const { | 1700 void Class::set_num_type_arguments(intptr_t value) const { |
1711 if (!Utils::IsInt(16, value)) { | 1701 if (!Utils::IsInt(16, value)) { |
1712 ReportTooManyTypeArguments(*this); | 1702 ReportTooManyTypeArguments(*this); |
1713 } | 1703 } |
1714 raw_ptr()->num_type_arguments_ = value; | 1704 raw_ptr()->num_type_arguments_ = value; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2231 // the loop below. | 2221 // the loop below. |
2232 // However, an implicitly created constructor should not be preserved if | 2222 // However, an implicitly created constructor should not be preserved if |
2233 // the patch provides a constructor or a factory. Wait for now. | 2223 // the patch provides a constructor or a factory. Wait for now. |
2234 if (orig_func.raw() != orig_implicit_ctor.raw()) { | 2224 if (orig_func.raw() != orig_implicit_ctor.raw()) { |
2235 new_functions.Add(orig_func); | 2225 new_functions.Add(orig_func); |
2236 } | 2226 } |
2237 } else if (func.UserVisibleSignature() != | 2227 } else if (func.UserVisibleSignature() != |
2238 orig_func.UserVisibleSignature()) { | 2228 orig_func.UserVisibleSignature()) { |
2239 // Compare user visible signatures to ignore different implicit parameters | 2229 // Compare user visible signatures to ignore different implicit parameters |
2240 // when patching a constructor with a factory. | 2230 // when patching a constructor with a factory. |
2241 *error = FormatError(*error, // No previous error. | 2231 *error = LanguageError::NewFormatted( |
2242 Script::Handle(patch.script()), func.token_pos(), | 2232 *error, // No previous error. |
2243 "signature mismatch: '%s'", member_name.ToCString()); | 2233 Script::Handle(patch.script()), |
| 2234 func.token_pos(), |
| 2235 LanguageError::kError, |
| 2236 Heap::kNew, |
| 2237 "signature mismatch: '%s'", member_name.ToCString()); |
2244 return false; | 2238 return false; |
2245 } | 2239 } |
2246 } | 2240 } |
2247 for (intptr_t i = 0; i < patch_len; i++) { | 2241 for (intptr_t i = 0; i < patch_len; i++) { |
2248 func ^= patch_list.At(i); | 2242 func ^= patch_list.At(i); |
2249 if (func.IsConstructor() || func.IsFactory()) { | 2243 if (func.IsConstructor() || func.IsFactory()) { |
2250 // Do not preserve the original implicit constructor, if any. | 2244 // Do not preserve the original implicit constructor, if any. |
2251 orig_implicit_ctor = Function::null(); | 2245 orig_implicit_ctor = Function::null(); |
2252 } | 2246 } |
2253 func.set_owner(patch_class); | 2247 func.set_owner(patch_class); |
(...skipping 18 matching lines...) Expand all Loading... |
2272 new_list = Array::New(patch_len + orig_len); | 2266 new_list = Array::New(patch_len + orig_len); |
2273 for (intptr_t i = 0; i < patch_len; i++) { | 2267 for (intptr_t i = 0; i < patch_len; i++) { |
2274 field ^= patch_list.At(i); | 2268 field ^= patch_list.At(i); |
2275 field.set_owner(*this); | 2269 field.set_owner(*this); |
2276 member_name = field.name(); | 2270 member_name = field.name(); |
2277 // TODO(iposva): Verify non-public fields only. | 2271 // TODO(iposva): Verify non-public fields only. |
2278 | 2272 |
2279 // Verify no duplicate additions. | 2273 // Verify no duplicate additions. |
2280 orig_field ^= LookupField(member_name); | 2274 orig_field ^= LookupField(member_name); |
2281 if (!orig_field.IsNull()) { | 2275 if (!orig_field.IsNull()) { |
2282 *error = FormatError(*error, // No previous error. | 2276 *error = LanguageError::NewFormatted( |
2283 Script::Handle(patch.script()), field.token_pos(), | 2277 *error, // No previous error. |
2284 "duplicate field: %s", member_name.ToCString()); | 2278 Script::Handle(patch.script()), |
| 2279 field.token_pos(), |
| 2280 LanguageError::kError, |
| 2281 Heap::kNew, |
| 2282 "duplicate field: %s", member_name.ToCString()); |
2285 return false; | 2283 return false; |
2286 } | 2284 } |
2287 new_list.SetAt(i, field); | 2285 new_list.SetAt(i, field); |
2288 } | 2286 } |
2289 for (intptr_t i = 0; i < orig_len; i++) { | 2287 for (intptr_t i = 0; i < orig_len; i++) { |
2290 field ^= orig_list.At(i); | 2288 field ^= orig_list.At(i); |
2291 new_list.SetAt(patch_len + i, field); | 2289 new_list.SetAt(patch_len + i, field); |
2292 } | 2290 } |
2293 SetFields(new_list); | 2291 SetFields(new_list); |
2294 | 2292 |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2836 // Check for 'direct super type' specified in the implements clause | 2834 // Check for 'direct super type' specified in the implements clause |
2837 // and check for transitivity at the same time. | 2835 // and check for transitivity at the same time. |
2838 Array& interfaces = Array::Handle(thsi.interfaces()); | 2836 Array& interfaces = Array::Handle(thsi.interfaces()); |
2839 AbstractType& interface = AbstractType::Handle(); | 2837 AbstractType& interface = AbstractType::Handle(); |
2840 Class& interface_class = Class::Handle(); | 2838 Class& interface_class = Class::Handle(); |
2841 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); | 2839 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); |
2842 Error& error = Error::Handle(); | 2840 Error& error = Error::Handle(); |
2843 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 2841 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
2844 interface ^= interfaces.At(i); | 2842 interface ^= interfaces.At(i); |
2845 if (!interface.IsFinalized()) { | 2843 if (!interface.IsFinalized()) { |
2846 // We may be checking bounds at finalization time. Skipping this | 2844 // We may be checking bounds at finalization time and can encounter |
2847 // unfinalized interface will postpone bound checking to run time. | 2845 // a still unfinalized interface. |
2848 continue; | 2846 ClassFinalizer::FinalizeType( |
| 2847 thsi, interface, ClassFinalizer::kCanonicalize); |
| 2848 interfaces.SetAt(i, interface); |
2849 } | 2849 } |
2850 error = Error::null(); | 2850 error = Error::null(); |
2851 if (interface.IsMalboundedWithError(&error)) { | 2851 if (interface.IsMalboundedWithError(&error)) { |
2852 // Return the first bound error to the caller if it requests it. | 2852 // Return the first bound error to the caller if it requests it. |
2853 if ((bound_error != NULL) && bound_error->IsNull()) { | 2853 if ((bound_error != NULL) && bound_error->IsNull()) { |
2854 ASSERT(!error.IsNull()); | 2854 ASSERT(!error.IsNull()); |
2855 *bound_error = error.raw(); | 2855 *bound_error = error.raw(); |
2856 } | 2856 } |
2857 continue; // Another interface may work better. | 2857 continue; // Another interface may work better. |
2858 } | 2858 } |
(...skipping 1980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4839 | 4839 |
4840 bool Function::HasCompatibleParametersWith(const Function& other, | 4840 bool Function::HasCompatibleParametersWith(const Function& other, |
4841 Error* bound_error) const { | 4841 Error* bound_error) const { |
4842 ASSERT(FLAG_error_on_bad_override); | 4842 ASSERT(FLAG_error_on_bad_override); |
4843 // Check that this function's signature type is a subtype of the other | 4843 // Check that this function's signature type is a subtype of the other |
4844 // function's signature type. | 4844 // function's signature type. |
4845 if (!TypeTest(kIsSubtypeOf, Object::null_abstract_type_arguments(), | 4845 if (!TypeTest(kIsSubtypeOf, Object::null_abstract_type_arguments(), |
4846 other, Object::null_abstract_type_arguments(), bound_error)) { | 4846 other, Object::null_abstract_type_arguments(), bound_error)) { |
4847 // For more informative error reporting, use the location of the other | 4847 // For more informative error reporting, use the location of the other |
4848 // function here, since the caller will use the location of this function. | 4848 // function here, since the caller will use the location of this function. |
4849 *bound_error = FormatError( | 4849 *bound_error = LanguageError::NewFormatted( |
4850 *bound_error, // A bound error if non null. | 4850 *bound_error, // A bound error if non null. |
4851 Script::Handle(other.script()), | 4851 Script::Handle(other.script()), |
4852 other.token_pos(), | 4852 other.token_pos(), |
| 4853 LanguageError::kError, |
| 4854 Heap::kNew, |
4853 "signature type '%s' of function '%s' is not a subtype of signature " | 4855 "signature type '%s' of function '%s' is not a subtype of signature " |
4854 "type '%s' of function '%s'", | 4856 "type '%s' of function '%s'", |
4855 String::Handle(UserVisibleSignature()).ToCString(), | 4857 String::Handle(UserVisibleSignature()).ToCString(), |
4856 String::Handle(UserVisibleName()).ToCString(), | 4858 String::Handle(UserVisibleName()).ToCString(), |
4857 String::Handle(other.UserVisibleSignature()).ToCString(), | 4859 String::Handle(other.UserVisibleSignature()).ToCString(), |
4858 String::Handle(other.UserVisibleName()).ToCString()); | 4860 String::Handle(other.UserVisibleName()).ToCString()); |
4859 return false; | 4861 return false; |
4860 } | 4862 } |
4861 // We should also check that if the other function explicitly specifies a | 4863 // We should also check that if the other function explicitly specifies a |
4862 // default value for a formal parameter, this function does not specify a | 4864 // default value for a formal parameter, this function does not specify a |
(...skipping 5792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10655 | 10657 |
10656 RawLanguageError* LanguageError::New() { | 10658 RawLanguageError* LanguageError::New() { |
10657 ASSERT(Object::language_error_class() != Class::null()); | 10659 ASSERT(Object::language_error_class() != Class::null()); |
10658 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 10660 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
10659 LanguageError::InstanceSize(), | 10661 LanguageError::InstanceSize(), |
10660 Heap::kOld); | 10662 Heap::kOld); |
10661 return reinterpret_cast<RawLanguageError*>(raw); | 10663 return reinterpret_cast<RawLanguageError*>(raw); |
10662 } | 10664 } |
10663 | 10665 |
10664 | 10666 |
10665 RawLanguageError* LanguageError::New(const String& message, Heap::Space space) { | 10667 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, |
| 10668 const Script& script, |
| 10669 intptr_t token_pos, |
| 10670 Kind kind, |
| 10671 Heap::Space space, |
| 10672 const char* format, |
| 10673 va_list args) { |
10666 ASSERT(Object::language_error_class() != Class::null()); | 10674 ASSERT(Object::language_error_class() != Class::null()); |
10667 LanguageError& result = LanguageError::Handle(); | 10675 LanguageError& result = LanguageError::Handle(); |
10668 { | 10676 { |
10669 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 10677 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
10670 LanguageError::InstanceSize(), | 10678 LanguageError::InstanceSize(), |
10671 space); | 10679 space); |
10672 NoGCScope no_gc; | 10680 NoGCScope no_gc; |
10673 result ^= raw; | 10681 result ^= raw; |
10674 } | 10682 } |
10675 result.set_message(message); | 10683 result.set_previous_error(prev_error); |
| 10684 result.set_script(script); |
| 10685 result.set_token_pos(token_pos); |
| 10686 result.set_kind(kind); |
| 10687 result.set_message(String::Handle(String::NewFormattedV(format, args))); |
10676 return result.raw(); | 10688 return result.raw(); |
10677 } | 10689 } |
10678 | 10690 |
10679 | 10691 |
10680 void LanguageError::set_message(const String& message) const { | 10692 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, |
10681 StorePointer(&raw_ptr()->message_, message.raw()); | 10693 const Script& script, |
| 10694 intptr_t token_pos, |
| 10695 Kind kind, |
| 10696 Heap::Space space, |
| 10697 const char* format, ...) { |
| 10698 va_list args; |
| 10699 va_start(args, format); |
| 10700 RawLanguageError* result = LanguageError::NewFormattedV( |
| 10701 prev_error, script, token_pos, kind, space, format, args); |
| 10702 NoGCScope no_gc; |
| 10703 va_end(args); |
| 10704 return result; |
| 10705 } |
| 10706 |
| 10707 |
| 10708 RawLanguageError* LanguageError::New(const String& formatted_message, |
| 10709 Heap::Space space) { |
| 10710 ASSERT(Object::language_error_class() != Class::null()); |
| 10711 LanguageError& result = LanguageError::Handle(); |
| 10712 { |
| 10713 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
| 10714 LanguageError::InstanceSize(), |
| 10715 space); |
| 10716 NoGCScope no_gc; |
| 10717 result ^= raw; |
| 10718 } |
| 10719 result.set_formatted_message(formatted_message); |
| 10720 return result.raw(); |
| 10721 } |
| 10722 |
| 10723 |
| 10724 void LanguageError::set_previous_error(const Error& value) const { |
| 10725 StorePointer(&raw_ptr()->previous_error_, value.raw()); |
| 10726 } |
| 10727 |
| 10728 |
| 10729 void LanguageError::set_script(const Script& value) const { |
| 10730 StorePointer(&raw_ptr()->script_, value.raw()); |
| 10731 } |
| 10732 |
| 10733 |
| 10734 void LanguageError::set_token_pos(intptr_t value) const { |
| 10735 ASSERT(value >= 0); |
| 10736 raw_ptr()->token_pos_ = value; |
| 10737 } |
| 10738 |
| 10739 |
| 10740 void LanguageError::set_kind(uint8_t value) const { |
| 10741 raw_ptr()->kind_ = value; |
| 10742 } |
| 10743 |
| 10744 |
| 10745 void LanguageError::set_message(const String& value) const { |
| 10746 StorePointer(&raw_ptr()->message_, value.raw()); |
| 10747 } |
| 10748 |
| 10749 |
| 10750 void LanguageError::set_formatted_message(const String& value) const { |
| 10751 StorePointer(&raw_ptr()->formatted_message_, value.raw()); |
| 10752 } |
| 10753 |
| 10754 |
| 10755 RawString* LanguageError::FormatMessage() const { |
| 10756 if (formatted_message() != String::null()) { |
| 10757 return formatted_message(); |
| 10758 } |
| 10759 const char* message_header; |
| 10760 switch (kind()) { |
| 10761 case kWarning: message_header = "warning"; break; |
| 10762 case kError: message_header = "error"; break; |
| 10763 case kMalformedType: message_header = "malformed type"; break; |
| 10764 case kMalboundedType: message_header = "malbounded type"; break; |
| 10765 default: message_header = ""; UNREACHABLE(); |
| 10766 } |
| 10767 String& result = String::Handle(); |
| 10768 String& msg = String::Handle(message()); |
| 10769 const Script& scr = Script::Handle(script()); |
| 10770 if (!scr.IsNull()) { |
| 10771 const String& script_url = String::Handle(scr.url()); |
| 10772 if (token_pos() >= 0) { |
| 10773 intptr_t line, column; |
| 10774 scr.GetTokenLocation(token_pos(), &line, &column); |
| 10775 // Only report the line position if we have the original source. We still |
| 10776 // need to get a valid column so that we can report the ^ mark below the |
| 10777 // snippet. |
| 10778 if (scr.HasSource()) { |
| 10779 result = String::NewFormatted("'%s': %s: line %" Pd " pos %" Pd ": ", |
| 10780 script_url.ToCString(), |
| 10781 message_header, |
| 10782 line, |
| 10783 column); |
| 10784 } else { |
| 10785 result = String::NewFormatted("'%s': %s: line %" Pd ": ", |
| 10786 script_url.ToCString(), |
| 10787 message_header, |
| 10788 line); |
| 10789 } |
| 10790 // Append the formatted error or warning message. |
| 10791 result = String::Concat(result, msg); |
| 10792 // Append the source line. |
| 10793 const String& script_line = String::Handle(scr.GetLine(line)); |
| 10794 ASSERT(!script_line.IsNull()); |
| 10795 result = String::Concat(result, Symbols::NewLine()); |
| 10796 result = String::Concat(result, script_line); |
| 10797 result = String::Concat(result, Symbols::NewLine()); |
| 10798 // Append the column marker. |
| 10799 const String& column_line = String::Handle( |
| 10800 String::NewFormatted("%*s\n", static_cast<int>(column), "^")); |
| 10801 result = String::Concat(result, column_line); |
| 10802 } else { |
| 10803 // Token position is unknown. |
| 10804 result = String::NewFormatted("'%s': %s: ", |
| 10805 script_url.ToCString(), |
| 10806 message_header); |
| 10807 result = String::Concat(result, msg); |
| 10808 } |
| 10809 } else { |
| 10810 // Script is unknown. |
| 10811 // Append the formatted error or warning message. |
| 10812 result = String::NewFormatted("%s: ", message_header); |
| 10813 result = String::Concat(result, msg); |
| 10814 } |
| 10815 // Prepend previous error message. |
| 10816 const Error& prev_error = Error::Handle(previous_error()); |
| 10817 if (!prev_error.IsNull()) { |
| 10818 msg = String::New(prev_error.ToErrorCString()); |
| 10819 result = String::Concat(msg, result); |
| 10820 } |
| 10821 set_formatted_message(result); |
| 10822 return result.raw(); |
10682 } | 10823 } |
10683 | 10824 |
10684 | 10825 |
10685 const char* LanguageError::ToErrorCString() const { | 10826 const char* LanguageError::ToErrorCString() const { |
10686 const String& msg_str = String::Handle(message()); | 10827 const String& msg_str = String::Handle(FormatMessage()); |
10687 return msg_str.ToCString(); | 10828 return msg_str.ToCString(); |
10688 } | 10829 } |
10689 | 10830 |
10690 | 10831 |
10691 const char* LanguageError::ToCString() const { | 10832 const char* LanguageError::ToCString() const { |
10692 return "LanguageError"; | 10833 return "LanguageError"; |
10693 } | 10834 } |
10694 | 10835 |
10695 | 10836 |
10696 void LanguageError::PrintToJSONStream(JSONStream* stream, bool ref) const { | 10837 void LanguageError::PrintToJSONStream(JSONStream* stream, bool ref) const { |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12105 upper_bound.UserVisibleName()); | 12246 upper_bound.UserVisibleName()); |
12106 const AbstractType& declared_bound = AbstractType::Handle(bound()); | 12247 const AbstractType& declared_bound = AbstractType::Handle(bound()); |
12107 const String& declared_bound_name = String::Handle( | 12248 const String& declared_bound_name = String::Handle( |
12108 declared_bound.UserVisibleName()); | 12249 declared_bound.UserVisibleName()); |
12109 const String& type_param_name = String::Handle(UserVisibleName()); | 12250 const String& type_param_name = String::Handle(UserVisibleName()); |
12110 const Class& cls = Class::Handle(parameterized_class()); | 12251 const Class& cls = Class::Handle(parameterized_class()); |
12111 const String& class_name = String::Handle(cls.Name()); | 12252 const String& class_name = String::Handle(cls.Name()); |
12112 const Script& script = Script::Handle(cls.script()); | 12253 const Script& script = Script::Handle(cls.script()); |
12113 // Since the bound may have been canonicalized, its token index is | 12254 // Since the bound may have been canonicalized, its token index is |
12114 // meaningless, therefore use the token index of this type parameter. | 12255 // meaningless, therefore use the token index of this type parameter. |
12115 *bound_error = FormatError( | 12256 *bound_error = LanguageError::NewFormatted( |
12116 *bound_error, | 12257 *bound_error, |
12117 script, | 12258 script, |
12118 token_pos(), | 12259 token_pos(), |
| 12260 LanguageError::kMalboundedType, |
| 12261 Heap::kNew, |
12119 "type parameter '%s' of class '%s' must extend bound '%s', " | 12262 "type parameter '%s' of class '%s' must extend bound '%s', " |
12120 "but type argument '%s' is not a subtype of '%s'\n", | 12263 "but type argument '%s' is not a subtype of '%s'\n", |
12121 type_param_name.ToCString(), | 12264 type_param_name.ToCString(), |
12122 class_name.ToCString(), | 12265 class_name.ToCString(), |
12123 declared_bound_name.ToCString(), | 12266 declared_bound_name.ToCString(), |
12124 bounded_type_name.ToCString(), | 12267 bounded_type_name.ToCString(), |
12125 upper_bound_name.ToCString()); | 12268 upper_bound_name.ToCString()); |
12126 } | 12269 } |
12127 return false; | 12270 return false; |
12128 } | 12271 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12363 const BoundedType& result = BoundedType::Handle(BoundedType::New()); | 12506 const BoundedType& result = BoundedType::Handle(BoundedType::New()); |
12364 result.set_type(type); | 12507 result.set_type(type); |
12365 result.set_bound(bound); | 12508 result.set_bound(bound); |
12366 result.set_type_parameter(type_parameter); | 12509 result.set_type_parameter(type_parameter); |
12367 result.set_is_being_checked(false); | 12510 result.set_is_being_checked(false); |
12368 return result.raw(); | 12511 return result.raw(); |
12369 } | 12512 } |
12370 | 12513 |
12371 | 12514 |
12372 const char* BoundedType::ToCString() const { | 12515 const char* BoundedType::ToCString() const { |
12373 const char* format = "BoundedType: type %s; bound: %s; class: %s"; | 12516 const char* format = "BoundedType: type %s; bound: %s; type param: %s%s%s"; |
12374 const char* type_cstr = String::Handle(AbstractType::Handle( | 12517 const char* type_cstr = String::Handle(AbstractType::Handle( |
12375 type()).Name()).ToCString(); | 12518 type()).Name()).ToCString(); |
12376 const char* bound_cstr = String::Handle(AbstractType::Handle( | 12519 const char* bound_cstr = String::Handle(AbstractType::Handle( |
12377 bound()).Name()).ToCString(); | 12520 bound()).Name()).ToCString(); |
12378 const Class& cls = Class::Handle(TypeParameter::Handle( | 12521 const TypeParameter& type_param = TypeParameter::Handle(type_parameter()); |
12379 type_parameter()).parameterized_class()); | 12522 const char* type_param_cstr = "null"; |
12380 const char* cls_cstr = | 12523 const char* of_cstr = ""; |
12381 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString(); | 12524 const char* cls_cstr = ""; |
12382 intptr_t len = OS::SNPrint( | 12525 if (!type_param.IsNull()) { |
12383 NULL, 0, format, type_cstr, bound_cstr, cls_cstr) + 1; | 12526 type_param_cstr = String::Handle(type_param.name()).ToCString(); |
| 12527 const Class& cls = Class::Handle(type_param.parameterized_class()); |
| 12528 if (!cls.IsNull()) { |
| 12529 of_cstr = " of "; |
| 12530 cls_cstr = String::Handle(cls.Name()).ToCString(); |
| 12531 } |
| 12532 } |
| 12533 intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr, bound_cstr, |
| 12534 type_param_cstr, of_cstr, cls_cstr) + 1; |
12384 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 12535 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
12385 OS::SNPrint(chars, len, format, type_cstr, bound_cstr, cls_cstr); | 12536 OS::SNPrint(chars, len, format, type_cstr, bound_cstr, type_param_cstr, |
| 12537 of_cstr, cls_cstr); |
12386 return chars; | 12538 return chars; |
12387 } | 12539 } |
12388 | 12540 |
12389 | 12541 |
12390 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const { | 12542 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const { |
12391 JSONObject jsobj(stream); | 12543 JSONObject jsobj(stream); |
12392 } | 12544 } |
12393 | 12545 |
12394 | 12546 |
12395 intptr_t MixinAppType::token_pos() const { | 12547 intptr_t MixinAppType::token_pos() const { |
(...skipping 3348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15744 return "_MirrorReference"; | 15896 return "_MirrorReference"; |
15745 } | 15897 } |
15746 | 15898 |
15747 | 15899 |
15748 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15900 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15749 JSONObject jsobj(stream); | 15901 JSONObject jsobj(stream); |
15750 } | 15902 } |
15751 | 15903 |
15752 | 15904 |
15753 } // namespace dart | 15905 } // namespace dart |
OLD | NEW |