Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: runtime/vm/object.cc

Issue 2865603003: Revert "Void is not required to be `null` anymore." (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/become.h" 10 #include "vm/become.h"
(...skipping 3802 matching lines...) Expand 10 before | Expand all | Expand 10 after
3813 const Class& other, 3813 const Class& other,
3814 const TypeArguments& other_type_arguments, 3814 const TypeArguments& other_type_arguments,
3815 Error* bound_error, 3815 Error* bound_error,
3816 TrailPtr bound_trail, 3816 TrailPtr bound_trail,
3817 Heap::Space space) { 3817 Heap::Space space) {
3818 // Use the thsi object as if it was the receiver of this method, but instead 3818 // Use the thsi object as if it was the receiver of this method, but instead
3819 // of recursing reset it to the super class and loop. 3819 // of recursing reset it to the super class and loop.
3820 Zone* zone = Thread::Current()->zone(); 3820 Zone* zone = Thread::Current()->zone();
3821 Class& thsi = Class::Handle(zone, cls.raw()); 3821 Class& thsi = Class::Handle(zone, cls.raw());
3822 while (true) { 3822 while (true) {
3823 ASSERT(!thsi.IsVoidClass());
3823 // Check for DynamicType. 3824 // Check for DynamicType.
3824 // Each occurrence of DynamicType in type T is interpreted as the dynamic 3825 // Each occurrence of DynamicType in type T is interpreted as the dynamic
3825 // type, a supertype of all types. 3826 // type, a supertype of all types.
3826 if (other.IsDynamicClass()) { 3827 if (other.IsDynamicClass()) {
3827 return true; 3828 return true;
3828 } 3829 }
3829 // Check for NullType, which, as of Dart 1.5, is a subtype of (and is more 3830 // Check for NullType, which, as of Dart 1.5, is a subtype of (and is more
3830 // specific than) any type. Note that the null instance is not handled here. 3831 // specific than) any type. Note that the null instance is not handled here.
3831 if (thsi.IsNullClass()) { 3832 if (thsi.IsNullClass()) {
3832 return true; 3833 return true;
3833 } 3834 }
3834 // In the case of a subtype test, each occurrence of DynamicType in type S 3835 // In the case of a subtype test, each occurrence of DynamicType in type S
3835 // is interpreted as the bottom type, a subtype of all types. 3836 // is interpreted as the bottom type, a subtype of all types.
3836 // However, DynamicType is not more specific than any type. 3837 // However, DynamicType is not more specific than any type.
3837 if (thsi.IsDynamicClass()) { 3838 if (thsi.IsDynamicClass()) {
3838 return test_kind == Class::kIsSubtypeOf; 3839 return test_kind == Class::kIsSubtypeOf;
3839 } 3840 }
3840 // Check for ObjectType. Any type that is not NullType or DynamicType 3841 // Check for ObjectType. Any type that is not NullType or DynamicType
3841 // (already checked above), is more specific than ObjectType/VoidType. 3842 // (already checked above), is more specific than ObjectType.
3842 if (other.IsObjectClass() || other.IsVoidClass()) { 3843 if (other.IsObjectClass()) {
3843 return true; 3844 return true;
3844 } 3845 }
3845 // If other is neither Object, dynamic or void, then ObjectType/VoidType
3846 // can't be a subtype of other.
3847 if (thsi.IsObjectClass() || thsi.IsVoidClass()) {
3848 return false;
3849 }
3850 // Check for reflexivity. 3846 // Check for reflexivity.
3851 if (thsi.raw() == other.raw()) { 3847 if (thsi.raw() == other.raw()) {
3852 const intptr_t num_type_params = thsi.NumTypeParameters(); 3848 const intptr_t num_type_params = thsi.NumTypeParameters();
3853 if (num_type_params == 0) { 3849 if (num_type_params == 0) {
3854 return true; 3850 return true;
3855 } 3851 }
3856 const intptr_t num_type_args = thsi.NumTypeArguments(); 3852 const intptr_t num_type_args = thsi.NumTypeArguments();
3857 const intptr_t from_index = num_type_args - num_type_params; 3853 const intptr_t from_index = num_type_args - num_type_params;
3858 // Since we do not truncate the type argument vector of a subclass (see 3854 // Since we do not truncate the type argument vector of a subclass (see
3859 // below), we only check a subvector of the proper length. 3855 // below), we only check a subvector of the proper length.
(...skipping 11967 matching lines...) Expand 10 before | Expand all | Expand 10 after
15827 const AbstractType& other, 15823 const AbstractType& other,
15828 const TypeArguments& other_instantiator_type_arguments, 15824 const TypeArguments& other_instantiator_type_arguments,
15829 const TypeArguments& other_function_type_arguments, 15825 const TypeArguments& other_function_type_arguments,
15830 Error* bound_error) const { 15826 Error* bound_error) const {
15831 ASSERT(other.IsFinalized()); 15827 ASSERT(other.IsFinalized());
15832 ASSERT(!other.IsDynamicType()); 15828 ASSERT(!other.IsDynamicType());
15833 ASSERT(!other.IsTypeRef()); // Must be dereferenced at compile time. 15829 ASSERT(!other.IsTypeRef()); // Must be dereferenced at compile time.
15834 ASSERT(!other.IsMalformed()); 15830 ASSERT(!other.IsMalformed());
15835 ASSERT(!other.IsMalbounded()); 15831 ASSERT(!other.IsMalbounded());
15836 if (other.IsVoidType()) { 15832 if (other.IsVoidType()) {
15837 return true; 15833 return false;
15838 } 15834 }
15839 Zone* zone = Thread::Current()->zone(); 15835 Zone* zone = Thread::Current()->zone();
15840 const Class& cls = Class::Handle(zone, clazz()); 15836 const Class& cls = Class::Handle(zone, clazz());
15841 if (cls.IsClosureClass()) { 15837 if (cls.IsClosureClass()) {
15842 if (other.IsObjectType() || other.IsDartFunctionType() || 15838 if (other.IsObjectType() || other.IsDartFunctionType() ||
15843 other.IsDartClosureType()) { 15839 other.IsDartClosureType()) {
15844 return true; 15840 return true;
15845 } 15841 }
15846 AbstractType& instantiated_other = AbstractType::Handle(zone, other.raw()); 15842 AbstractType& instantiated_other = AbstractType::Handle(zone, other.raw());
15847 // Note that we may encounter a bound error in checked mode. 15843 // Note that we may encounter a bound error in checked mode.
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
16645 return false; 16641 return false;
16646 } 16642 }
16647 if (other.IsMalbounded()) { 16643 if (other.IsMalbounded()) {
16648 ASSERT(Isolate::Current()->type_checks()); 16644 ASSERT(Isolate::Current()->type_checks());
16649 if ((bound_error != NULL) && bound_error->IsNull()) { 16645 if ((bound_error != NULL) && bound_error->IsNull()) {
16650 *bound_error = other.error(); 16646 *bound_error = other.error();
16651 } 16647 }
16652 return false; 16648 return false;
16653 } 16649 }
16654 // Any type is a subtype of (and is more specific than) Object and dynamic. 16650 // Any type is a subtype of (and is more specific than) Object and dynamic.
16655 // As of Dart 1.24, void is dynamically treated like Object (except when
16656 // comparing function-types).
16657 // As of Dart 1.5, the Null type is a subtype of (and is more specific than) 16651 // As of Dart 1.5, the Null type is a subtype of (and is more specific than)
16658 // any type. 16652 // any type.
16659 if (other.IsObjectType() || other.IsDynamicType() || other.IsVoidType() || 16653 if (other.IsObjectType() || other.IsDynamicType() || IsNullType()) {
16660 IsNullType()) {
16661 return true; 16654 return true;
16662 } 16655 }
16663 Zone* zone = Thread::Current()->zone(); 16656 Zone* zone = Thread::Current()->zone();
16664 if (IsBoundedType() || other.IsBoundedType()) { 16657 if (IsBoundedType() || other.IsBoundedType()) {
16665 if (Equals(other)) { 16658 if (Equals(other)) {
16666 return true; 16659 return true;
16667 } 16660 }
16668 // Redundant check if other type is equal to the upper bound of this type. 16661 // Redundant check if other type is equal to the upper bound of this type.
16669 if (IsBoundedType() && 16662 if (IsBoundedType() &&
16670 AbstractType::Handle(BoundedType::Cast(*this).bound()).Equals(other)) { 16663 AbstractType::Handle(BoundedType::Cast(*this).bound()).Equals(other)) {
(...skipping 6661 matching lines...) Expand 10 before | Expand all | Expand 10 after
23332 return UserTag::null(); 23325 return UserTag::null();
23333 } 23326 }
23334 23327
23335 23328
23336 const char* UserTag::ToCString() const { 23329 const char* UserTag::ToCString() const {
23337 const String& tag_label = String::Handle(label()); 23330 const String& tag_label = String::Handle(label());
23338 return tag_label.ToCString(); 23331 return tag_label.ToCString();
23339 } 23332 }
23340 23333
23341 } // namespace dart 23334 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.cc ('k') | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698