| 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 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2549 return (test_kind == kIsMoreSpecificThan) || | 2549 return (test_kind == kIsMoreSpecificThan) || |
| 2550 other.IsObjectClass() || other.IsNullClass(); | 2550 other.IsObjectClass() || other.IsNullClass(); |
| 2551 } | 2551 } |
| 2552 // Check for ObjectType. Any type that is not NullType or DynamicType (already | 2552 // Check for ObjectType. Any type that is not NullType or DynamicType (already |
| 2553 // checked above), is more specific than ObjectType. | 2553 // checked above), is more specific than ObjectType. |
| 2554 if (other.IsObjectClass()) { | 2554 if (other.IsObjectClass()) { |
| 2555 return true; | 2555 return true; |
| 2556 } | 2556 } |
| 2557 // Check for reflexivity. | 2557 // Check for reflexivity. |
| 2558 if (raw() == other.raw()) { | 2558 if (raw() == other.raw()) { |
| 2559 const intptr_t len = NumTypeArguments(); | 2559 if (!HasTypeArguments()) { |
| 2560 if (len == 0) { | |
| 2561 return true; | 2560 return true; |
| 2562 } | 2561 } |
| 2562 const intptr_t len = NumTypeArguments(); |
| 2563 // Since we do not truncate the type argument vector of a subclass (see | 2563 // Since we do not truncate the type argument vector of a subclass (see |
| 2564 // below), we only check a prefix of the proper length. | 2564 // below), we only check a prefix of the proper length. |
| 2565 // Check for covariance. | 2565 // Check for covariance. |
| 2566 if (other_type_arguments.IsNull() || other_type_arguments.IsRaw(len)) { | 2566 if (other_type_arguments.IsNull() || other_type_arguments.IsRaw(len)) { |
| 2567 return true; | 2567 return true; |
| 2568 } | 2568 } |
| 2569 if (type_arguments.IsNull() || type_arguments.IsRaw(len)) { | 2569 if (type_arguments.IsNull() || type_arguments.IsRaw(len)) { |
| 2570 // Other type can't be more specific than this one because for that | 2570 // Other type can't be more specific than this one because for that |
| 2571 // it would have to have all dynamic type arguments which is checked | 2571 // it would have to have all dynamic type arguments which is checked |
| 2572 // above. | 2572 // above. |
| (...skipping 8030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10603 bool Instance::IsInstanceOf(const AbstractType& other, | 10603 bool Instance::IsInstanceOf(const AbstractType& other, |
| 10604 const AbstractTypeArguments& other_instantiator, | 10604 const AbstractTypeArguments& other_instantiator, |
| 10605 Error* bound_error) const { | 10605 Error* bound_error) const { |
| 10606 ASSERT(other.IsFinalized()); | 10606 ASSERT(other.IsFinalized()); |
| 10607 ASSERT(!other.IsDynamicType()); | 10607 ASSERT(!other.IsDynamicType()); |
| 10608 ASSERT(!other.IsMalformed()); | 10608 ASSERT(!other.IsMalformed()); |
| 10609 ASSERT(!other.IsMalbounded()); | 10609 ASSERT(!other.IsMalbounded()); |
| 10610 if (other.IsVoidType()) { | 10610 if (other.IsVoidType()) { |
| 10611 return false; | 10611 return false; |
| 10612 } | 10612 } |
| 10613 const Class& cls = Class::Handle(clazz()); | 10613 Isolate* isolate = Isolate::Current(); |
| 10614 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 10614 const Class& cls = Class::Handle(isolate, clazz()); |
| 10615 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 10615 AbstractTypeArguments& type_arguments = |
| 10616 if (num_type_arguments > 0) { | 10616 AbstractTypeArguments::Handle(isolate); |
| 10617 if (cls.HasTypeArguments()) { |
| 10617 type_arguments = GetTypeArguments(); | 10618 type_arguments = GetTypeArguments(); |
| 10618 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { | 10619 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { |
| 10619 type_arguments = type_arguments.Canonicalize(); | 10620 type_arguments = type_arguments.Canonicalize(); |
| 10620 SetTypeArguments(type_arguments); | 10621 SetTypeArguments(type_arguments); |
| 10621 } | 10622 } |
| 10622 // The number of type arguments in the instance must be greater or equal to | 10623 // The number of type arguments in the instance must be greater or equal to |
| 10623 // the number of type arguments expected by the instance class. | 10624 // the number of type arguments expected by the instance class. |
| 10624 // A discrepancy is allowed for closures, which borrow the type argument | 10625 // A discrepancy is allowed for closures, which borrow the type argument |
| 10625 // vector of their instantiator, which may be of a subclass of the class | 10626 // vector of their instantiator, which may be of a subclass of the class |
| 10626 // defining the closure. Truncating the vector to the correct length on | 10627 // defining the closure. Truncating the vector to the correct length on |
| 10627 // instantiation is unnecessary. The vector may therefore be longer. | 10628 // instantiation is unnecessary. The vector may therefore be longer. |
| 10628 // Also, an optimization reuses the type argument vector of the instantiator | 10629 // Also, an optimization reuses the type argument vector of the instantiator |
| 10629 // of generic instances when its layout is compatible. | 10630 // of generic instances when its layout is compatible. |
| 10630 ASSERT(type_arguments.IsNull() || | 10631 ASSERT(type_arguments.IsNull() || |
| 10631 (type_arguments.Length() >= num_type_arguments)); | 10632 (type_arguments.Length() >= cls.NumTypeArguments())); |
| 10632 } | 10633 } |
| 10633 Class& other_class = Class::Handle(); | 10634 Class& other_class = Class::Handle(isolate); |
| 10634 AbstractTypeArguments& other_type_arguments = AbstractTypeArguments::Handle(); | 10635 AbstractTypeArguments& other_type_arguments = |
| 10636 AbstractTypeArguments::Handle(isolate); |
| 10635 // Note that we may encounter a bound error in checked mode. | 10637 // Note that we may encounter a bound error in checked mode. |
| 10636 if (!other.IsInstantiated()) { | 10638 if (!other.IsInstantiated()) { |
| 10637 const AbstractType& instantiated_other = AbstractType::Handle( | 10639 const AbstractType& instantiated_other = AbstractType::Handle( |
| 10638 other.InstantiateFrom(other_instantiator, bound_error)); | 10640 isolate, other.InstantiateFrom(other_instantiator, bound_error)); |
| 10639 if ((bound_error != NULL) && !bound_error->IsNull()) { | 10641 if ((bound_error != NULL) && !bound_error->IsNull()) { |
| 10640 ASSERT(FLAG_enable_type_checks); | 10642 ASSERT(FLAG_enable_type_checks); |
| 10641 return false; | 10643 return false; |
| 10642 } | 10644 } |
| 10643 other_class = instantiated_other.type_class(); | 10645 other_class = instantiated_other.type_class(); |
| 10644 other_type_arguments = instantiated_other.arguments(); | 10646 other_type_arguments = instantiated_other.arguments(); |
| 10645 } else { | 10647 } else { |
| 10646 other_class = other.type_class(); | 10648 other_class = other.type_class(); |
| 10647 other_type_arguments = other.arguments(); | 10649 other_type_arguments = other.arguments(); |
| 10648 } | 10650 } |
| (...skipping 4691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15340 return "_MirrorReference"; | 15342 return "_MirrorReference"; |
| 15341 } | 15343 } |
| 15342 | 15344 |
| 15343 | 15345 |
| 15344 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15346 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 15345 JSONObject jsobj(stream); | 15347 JSONObject jsobj(stream); |
| 15346 } | 15348 } |
| 15347 | 15349 |
| 15348 | 15350 |
| 15349 } // namespace dart | 15351 } // namespace dart |
| OLD | NEW |