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/become.h" | 10 #include "vm/become.h" |
(...skipping 15860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15871 bound_error, NULL, NULL, Heap::kOld); | 15871 bound_error, NULL, NULL, Heap::kOld); |
15872 if ((bound_error != NULL) && !bound_error->IsNull()) { | 15872 if ((bound_error != NULL) && !bound_error->IsNull()) { |
15873 ASSERT(Isolate::Current()->type_checks()); | 15873 ASSERT(Isolate::Current()->type_checks()); |
15874 return false; | 15874 return false; |
15875 } | 15875 } |
15876 if (instantiated_other.IsTypeRef()) { | 15876 if (instantiated_other.IsTypeRef()) { |
15877 instantiated_other = TypeRef::Cast(instantiated_other).type(); | 15877 instantiated_other = TypeRef::Cast(instantiated_other).type(); |
15878 } | 15878 } |
15879 if (instantiated_other.IsDynamicType() || | 15879 if (instantiated_other.IsDynamicType() || |
15880 instantiated_other.IsObjectType() || | 15880 instantiated_other.IsObjectType() || |
| 15881 instantiated_other.IsVoidType() || |
15881 instantiated_other.IsDartFunctionType()) { | 15882 instantiated_other.IsDartFunctionType()) { |
15882 return true; | 15883 return true; |
15883 } | 15884 } |
15884 } | 15885 } |
15885 if (!instantiated_other.IsFunctionType()) { | 15886 if (!instantiated_other.IsFunctionType()) { |
15886 return false; | 15887 return false; |
15887 } | 15888 } |
15888 Function& other_signature = | 15889 Function& other_signature = |
15889 Function::Handle(zone, Type::Cast(instantiated_other).signature()); | 15890 Function::Handle(zone, Type::Cast(instantiated_other).signature()); |
15890 Function& sig_fun = Function::Handle(zone, Closure::Cast(*this).function()); | 15891 Function& sig_fun = Function::Handle(zone, Closure::Cast(*this).function()); |
(...skipping 30 matching lines...) Expand all Loading... |
15921 instantiated_other = other.InstantiateFrom( | 15922 instantiated_other = other.InstantiateFrom( |
15922 other_instantiator_type_arguments, other_function_type_arguments, | 15923 other_instantiator_type_arguments, other_function_type_arguments, |
15923 bound_error, NULL, NULL, Heap::kOld); | 15924 bound_error, NULL, NULL, Heap::kOld); |
15924 if ((bound_error != NULL) && !bound_error->IsNull()) { | 15925 if ((bound_error != NULL) && !bound_error->IsNull()) { |
15925 ASSERT(Isolate::Current()->type_checks()); | 15926 ASSERT(Isolate::Current()->type_checks()); |
15926 return false; | 15927 return false; |
15927 } | 15928 } |
15928 if (instantiated_other.IsTypeRef()) { | 15929 if (instantiated_other.IsTypeRef()) { |
15929 instantiated_other = TypeRef::Cast(instantiated_other).type(); | 15930 instantiated_other = TypeRef::Cast(instantiated_other).type(); |
15930 } | 15931 } |
15931 if (instantiated_other.IsDynamicType()) { | 15932 if (instantiated_other.IsDynamicType() || |
| 15933 instantiated_other.IsObjectType() || instantiated_other.IsVoidType()) { |
15932 return true; | 15934 return true; |
15933 } | 15935 } |
15934 } | 15936 } |
15935 other_type_arguments = instantiated_other.arguments(); | 15937 other_type_arguments = instantiated_other.arguments(); |
15936 const bool other_is_dart_function = instantiated_other.IsDartFunctionType(); | 15938 const bool other_is_dart_function = instantiated_other.IsDartFunctionType(); |
15937 if (other_is_dart_function || instantiated_other.IsFunctionType()) { | 15939 if (other_is_dart_function || instantiated_other.IsFunctionType()) { |
15938 // Check if this instance understands a call() method of a compatible type. | 15940 // Check if this instance understands a call() method of a compatible type. |
15939 Function& sig_fun = | 15941 Function& sig_fun = |
15940 Function::Handle(zone, cls.LookupCallFunctionForTypeTest()); | 15942 Function::Handle(zone, cls.LookupCallFunctionForTypeTest()); |
15941 if (!sig_fun.IsNull()) { | 15943 if (!sig_fun.IsNull()) { |
(...skipping 14 matching lines...) Expand all Loading... |
15956 } | 15958 } |
15957 } | 15959 } |
15958 } | 15960 } |
15959 if (!instantiated_other.IsType()) { | 15961 if (!instantiated_other.IsType()) { |
15960 return false; | 15962 return false; |
15961 } | 15963 } |
15962 other_class = instantiated_other.type_class(); | 15964 other_class = instantiated_other.type_class(); |
15963 if (IsNull()) { | 15965 if (IsNull()) { |
15964 ASSERT(cls.IsNullClass()); | 15966 ASSERT(cls.IsNullClass()); |
15965 // As of Dart 1.5, the null instance and Null type are handled differently. | 15967 // As of Dart 1.5, the null instance and Null type are handled differently. |
15966 // We already checked for other.IsDynamicType(). | 15968 // We already checked other for dynamic and void. |
15967 return other_class.IsNullClass() || other_class.IsObjectClass(); | 15969 return other_class.IsNullClass() || other_class.IsObjectClass(); |
15968 } | 15970 } |
15969 return cls.IsSubtypeOf(type_arguments, other_class, other_type_arguments, | 15971 return cls.IsSubtypeOf(type_arguments, other_class, other_type_arguments, |
15970 bound_error, NULL, Heap::kOld); | 15972 bound_error, NULL, Heap::kOld); |
15971 } | 15973 } |
15972 | 15974 |
15973 | 15975 |
15974 bool Instance::OperatorEquals(const Instance& other) const { | 15976 bool Instance::OperatorEquals(const Instance& other) const { |
15975 // TODO(koda): Optimize for all builtin classes and all classes | 15977 // TODO(koda): Optimize for all builtin classes and all classes |
15976 // that do not override operator==. | 15978 // that do not override operator==. |
(...skipping 7377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23354 return UserTag::null(); | 23356 return UserTag::null(); |
23355 } | 23357 } |
23356 | 23358 |
23357 | 23359 |
23358 const char* UserTag::ToCString() const { | 23360 const char* UserTag::ToCString() const { |
23359 const String& tag_label = String::Handle(label()); | 23361 const String& tag_label = String::Handle(label()); |
23360 return tag_label.ToCString(); | 23362 return tag_label.ToCString(); |
23361 } | 23363 } |
23362 | 23364 |
23363 } // namespace dart | 23365 } // namespace dart |
OLD | NEW |