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 "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 } | 1528 } |
1529 // Check for two function types. | 1529 // Check for two function types. |
1530 if (IsSignatureClass() && other.IsSignatureClass()) { | 1530 if (IsSignatureClass() && other.IsSignatureClass()) { |
1531 const Function& fun = Function::Handle(signature_function()); | 1531 const Function& fun = Function::Handle(signature_function()); |
1532 const Function& other_fun = Function::Handle(other.signature_function()); | 1532 const Function& other_fun = Function::Handle(other.signature_function()); |
1533 return fun.IsSubtypeOf(type_arguments, | 1533 return fun.IsSubtypeOf(type_arguments, |
1534 other_fun, | 1534 other_fun, |
1535 other_type_arguments, | 1535 other_type_arguments, |
1536 malformed_error); | 1536 malformed_error); |
1537 } | 1537 } |
1538 // Check for 'direct super type' in the case of an interface and check for | 1538 // Check for 'direct super type' in the case of an interface |
1539 // transitivity at the same time. | 1539 // (i.e. other.is_interface()) or implicit interface (i.e. |
1540 if (other.is_interface()) { | 1540 // !other.is_interface()) and check for transitivity at the same time. |
1541 Array& interfaces = Array::Handle(this->interfaces()); | 1541 Array& interfaces = Array::Handle(this->interfaces()); |
1542 AbstractType& interface = AbstractType::Handle(); | 1542 AbstractType& interface = AbstractType::Handle(); |
1543 Class& interface_class = Class::Handle(); | 1543 Class& interface_class = Class::Handle(); |
1544 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); | 1544 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); |
1545 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 1545 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
1546 interface ^= interfaces.At(i); | 1546 interface ^= interfaces.At(i); |
1547 interface_class = interface.type_class(); | 1547 interface_class = interface.type_class(); |
1548 interface_args = interface.arguments(); | 1548 interface_args = interface.arguments(); |
1549 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) { | 1549 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) { |
1550 // This type class implements an interface that is parameterized with | 1550 // This type class implements an interface that is parameterized with |
1551 // generic type(s), e.g. it implements List<T>. | 1551 // generic type(s), e.g. it implements List<T>. |
1552 // The uninstantiated type T must be instantiated using the type | 1552 // The uninstantiated type T must be instantiated using the type |
1553 // parameters of this type before performing the type test. | 1553 // parameters of this type before performing the type test. |
1554 // The type arguments of this type that are referred to by the type | 1554 // The type arguments of this type that are referred to by the type |
1555 // parameters of the interface are at the end of the type vector, | 1555 // parameters of the interface are at the end of the type vector, |
1556 // after the type arguments of the super type of this type. | 1556 // after the type arguments of the super type of this type. |
1557 // The index of the type parameters is adjusted upon finalization. | 1557 // The index of the type parameters is adjusted upon finalization. |
1558 ASSERT(interface.IsFinalized()); | 1558 ASSERT(interface.IsFinalized()); |
1559 interface_args = interface_args.InstantiateFrom(type_arguments); | 1559 interface_args = interface_args.InstantiateFrom(type_arguments); |
1560 // In checked mode, verify that the instantiated interface type | 1560 // In checked mode, verify that the instantiated interface type |
1561 // arguments are within the bounds specified by the interface class. | 1561 // arguments are within the bounds specified by the interface class. |
1562 // Note that the additional bounds check in checked mode may lead to a | 1562 // Note that the additional bounds check in checked mode may lead to a |
1563 // dynamic type error, but it will never change the result of the type | 1563 // dynamic type error, but it will never change the result of the type |
1564 // check from true in production mode to false in checked mode. | 1564 // check from true in production mode to false in checked mode. |
1565 if (FLAG_enable_type_checks && !interface_args.IsNull()) { | 1565 if (FLAG_enable_type_checks && !interface_args.IsNull()) { |
1566 // Pass type_arguments as bounds instantiator. | 1566 // Pass type_arguments as bounds instantiator. |
1567 if (!interface_args.IsWithinBoundsOf(interface_class, | 1567 if (!interface_args.IsWithinBoundsOf(interface_class, |
1568 type_arguments, | 1568 type_arguments, |
1569 malformed_error)) { | 1569 malformed_error)) { |
1570 continue; | 1570 continue; |
1571 } | |
1572 } | 1571 } |
1573 } | 1572 } |
1574 if (interface_class.IsSubtypeOf(interface_args, | 1573 } |
1575 other, | 1574 if (interface_class.IsSubtypeOf(interface_args, |
1576 other_type_arguments, | 1575 other, |
1577 malformed_error)) { | 1576 other_type_arguments, |
1578 return true; | 1577 malformed_error)) { |
1579 } | 1578 return true; |
1580 } | 1579 } |
1581 } | 1580 } |
1582 // Check the interface case. | 1581 // Check the interface case. |
1583 if (is_interface()) { | 1582 if (is_interface()) { |
1584 // We already checked the case where 'other' is an interface. Now, 'this', | 1583 // We already checked the case where 'other' is an interface. Now, 'this', |
1585 // an interface, cannot be more specific than a class, except class Object, | 1584 // an interface, cannot be more specific than a class, except class Object, |
1586 // because although Object is not considered an interface by the vm, it is | 1585 // because although Object is not considered an interface by the vm, it is |
1587 // one. In other words, all classes implementing this interface also extend | 1586 // one. In other words, all classes implementing this interface also extend |
1588 // class Object. An interface is also more specific than the DynamicType. | 1587 // class Object. An interface is also more specific than the DynamicType. |
1589 return (other.IsDynamicClass() || other.IsObjectClass()); | 1588 return (other.IsDynamicClass() || other.IsObjectClass()); |
(...skipping 7540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9130 const String& str = String::Handle(pattern()); | 9129 const String& str = String::Handle(pattern()); |
9131 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9130 const char* format = "JSRegExp: pattern=%s flags=%s"; |
9132 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9131 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
9133 char* chars = reinterpret_cast<char*>( | 9132 char* chars = reinterpret_cast<char*>( |
9134 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9133 Isolate::Current()->current_zone()->Allocate(len + 1)); |
9135 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9134 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
9136 return chars; | 9135 return chars; |
9137 } | 9136 } |
9138 | 9137 |
9139 } // namespace dart | 9138 } // namespace dart |
OLD | NEW |