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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 return HasResolvedTypeClass() && | 1763 return HasResolvedTypeClass() && |
1764 (type_class() == Type::Handle(Type::FunctionInterface()).type_class()); | 1764 (type_class() == Type::Handle(Type::FunctionInterface()).type_class()); |
1765 } | 1765 } |
1766 | 1766 |
1767 | 1767 |
1768 bool Type::IsMoreSpecificThan(const Type& other) const { | 1768 bool Type::IsMoreSpecificThan(const Type& other) const { |
1769 ASSERT(IsFinalized()); | 1769 ASSERT(IsFinalized()); |
1770 ASSERT(other.IsFinalized()); | 1770 ASSERT(other.IsFinalized()); |
1771 // Type parameters cannot be handled by Class::IsMoreSpecificThan(). | 1771 // Type parameters cannot be handled by Class::IsMoreSpecificThan(). |
1772 if (IsTypeParameter() || other.IsTypeParameter()) { | 1772 if (IsTypeParameter() || other.IsTypeParameter()) { |
1773 return IsTypeParameter() && other.IsTypeParameter() && | 1773 // TODO(regis): Revisit this temporary workaround. See issue 5474672. |
1774 (Index() == other.Index()); | 1774 return |
| 1775 (!IsTypeParameter() && other.IsTypeParameter()) || |
| 1776 (IsTypeParameter() && other.IsTypeParameter() && |
| 1777 (Index() == other.Index())); |
1775 } | 1778 } |
1776 const Class& cls = Class::Handle(type_class()); | 1779 const Class& cls = Class::Handle(type_class()); |
1777 return cls.IsMoreSpecificThan(TypeArguments::Handle(arguments()), | 1780 return cls.IsMoreSpecificThan(TypeArguments::Handle(arguments()), |
1778 Class::Handle(other.type_class()), | 1781 Class::Handle(other.type_class()), |
1779 TypeArguments::Handle(other.arguments())); | 1782 TypeArguments::Handle(other.arguments())); |
1780 } | 1783 } |
1781 | 1784 |
1782 | 1785 |
1783 bool Type::Test(TypeTestKind test, const Type& other) const { | 1786 bool Type::Test(TypeTestKind test, const Type& other) const { |
1784 ASSERT(IsFinalized()); | 1787 ASSERT(IsFinalized()); |
1785 ASSERT(other.IsFinalized()); | 1788 ASSERT(other.IsFinalized()); |
1786 // Type parameters cannot be handled by Class::TestType(). | 1789 // Type parameters cannot be handled by Class::TestType(). |
1787 if (IsTypeParameter() || other.IsTypeParameter()) { | 1790 if (IsTypeParameter() || other.IsTypeParameter()) { |
1788 return IsTypeParameter() && other.IsTypeParameter() && | 1791 // TODO(regis): Revisit this temporary workaround. See issue 5474672. |
1789 (Index() == other.Index()); | 1792 return |
| 1793 (!IsTypeParameter() && other.IsTypeParameter()) || |
| 1794 (IsTypeParameter() && other.IsTypeParameter() && |
| 1795 (Index() == other.Index())); |
1790 } | 1796 } |
1791 const Class& cls = Class::Handle(type_class()); | 1797 const Class& cls = Class::Handle(type_class()); |
1792 if (test == kIsSubtypeOf) { | 1798 if (test == kIsSubtypeOf) { |
1793 return cls.IsSubtypeOf(TypeArguments::Handle(arguments()), | 1799 return cls.IsSubtypeOf(TypeArguments::Handle(arguments()), |
1794 Class::Handle(other.type_class()), | 1800 Class::Handle(other.type_class()), |
1795 TypeArguments::Handle(other.arguments())); | 1801 TypeArguments::Handle(other.arguments())); |
1796 } else { | 1802 } else { |
1797 ASSERT(test == kIsAssignableTo); | 1803 ASSERT(test == kIsAssignableTo); |
1798 return cls.IsAssignableTo(TypeArguments::Handle(arguments()), | 1804 return cls.IsAssignableTo(TypeArguments::Handle(arguments()), |
1799 Class::Handle(other.type_class()), | 1805 Class::Handle(other.type_class()), |
(...skipping 4658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6458 const String& str = String::Handle(pattern()); | 6464 const String& str = String::Handle(pattern()); |
6459 const char* format = "JSRegExp: pattern=%s flags=%s"; | 6465 const char* format = "JSRegExp: pattern=%s flags=%s"; |
6460 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 6466 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
6461 char* chars = reinterpret_cast<char*>( | 6467 char* chars = reinterpret_cast<char*>( |
6462 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6468 Isolate::Current()->current_zone()->Allocate(len + 1)); |
6463 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 6469 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
6464 return chars; | 6470 return chars; |
6465 } | 6471 } |
6466 | 6472 |
6467 } // namespace dart | 6473 } // namespace dart |
OLD | NEW |