| 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 3672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3683 return type_arguments.TypeTest(test_kind, | 3683 return type_arguments.TypeTest(test_kind, |
| 3684 other_type_arguments, | 3684 other_type_arguments, |
| 3685 from_index, | 3685 from_index, |
| 3686 num_type_params, | 3686 num_type_params, |
| 3687 bound_error, | 3687 bound_error, |
| 3688 bound_trail, | 3688 bound_trail, |
| 3689 space); | 3689 space); |
| 3690 } | 3690 } |
| 3691 if (other.IsFunctionClass()) { | 3691 if (other.IsFunctionClass()) { |
| 3692 // Check if type S has a call() method. | 3692 // Check if type S has a call() method. |
| 3693 Function& function = | 3693 Function& function = Function::Handle(zone, |
| 3694 Function::Handle(zone, thsi.LookupDynamicFunction(Symbols::Call())); | 3694 thsi.LookupDynamicFunctionAllowAbstract(Symbols::Call())); |
| 3695 if (function.IsNull()) { | 3695 if (function.IsNull()) { |
| 3696 // Walk up the super_class chain. | 3696 // Walk up the super_class chain. |
| 3697 Class& cls = Class::Handle(zone, thsi.SuperClass()); | 3697 Class& cls = Class::Handle(zone, thsi.SuperClass()); |
| 3698 while (!cls.IsNull() && function.IsNull()) { | 3698 while (!cls.IsNull() && function.IsNull()) { |
| 3699 function = cls.LookupDynamicFunction(Symbols::Call()); | 3699 function = cls.LookupDynamicFunctionAllowAbstract(Symbols::Call()); |
| 3700 cls = cls.SuperClass(); | 3700 cls = cls.SuperClass(); |
| 3701 } | 3701 } |
| 3702 } | 3702 } |
| 3703 if (!function.IsNull()) { | 3703 if (!function.IsNull()) { |
| 3704 return true; | 3704 return true; |
| 3705 } | 3705 } |
| 3706 } | 3706 } |
| 3707 // Check for 'direct super type' specified in the implements clause | 3707 // Check for 'direct super type' specified in the implements clause |
| 3708 // and check for transitivity at the same time. | 3708 // and check for transitivity at the same time. |
| 3709 Array& interfaces = Array::Handle(zone, thsi.interfaces()); | 3709 Array& interfaces = Array::Handle(zone, thsi.interfaces()); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3812 bool Class::IsPrivate() const { | 3812 bool Class::IsPrivate() const { |
| 3813 return Library::IsPrivate(String::Handle(Name())); | 3813 return Library::IsPrivate(String::Handle(Name())); |
| 3814 } | 3814 } |
| 3815 | 3815 |
| 3816 | 3816 |
| 3817 RawFunction* Class::LookupDynamicFunction(const String& name) const { | 3817 RawFunction* Class::LookupDynamicFunction(const String& name) const { |
| 3818 return LookupFunction(name, kInstance); | 3818 return LookupFunction(name, kInstance); |
| 3819 } | 3819 } |
| 3820 | 3820 |
| 3821 | 3821 |
| 3822 RawFunction* Class::LookupDynamicFunctionAllowAbstract( |
| 3823 const String& name) const { |
| 3824 return LookupFunction(name, kInstanceAllowAbstract); |
| 3825 } |
| 3826 |
| 3827 |
| 3822 RawFunction* Class::LookupDynamicFunctionAllowPrivate( | 3828 RawFunction* Class::LookupDynamicFunctionAllowPrivate( |
| 3823 const String& name) const { | 3829 const String& name) const { |
| 3824 return LookupFunctionAllowPrivate(name, kInstance); | 3830 return LookupFunctionAllowPrivate(name, kInstance); |
| 3825 } | 3831 } |
| 3826 | 3832 |
| 3827 | 3833 |
| 3828 RawFunction* Class::LookupStaticFunction(const String& name) const { | 3834 RawFunction* Class::LookupStaticFunction(const String& name) const { |
| 3829 return LookupFunction(name, kStatic); | 3835 return LookupFunction(name, kStatic); |
| 3830 } | 3836 } |
| 3831 | 3837 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3884 for (intptr_t i = 0, j = prefix_length; i < accessor_name_len; i++, j++) { | 3890 for (intptr_t i = 0, j = prefix_length; i < accessor_name_len; i++, j++) { |
| 3885 if (name.CharAt(j) != accessor_name.CharAt(i)) { | 3891 if (name.CharAt(j) != accessor_name.CharAt(i)) { |
| 3886 return false; | 3892 return false; |
| 3887 } | 3893 } |
| 3888 } | 3894 } |
| 3889 return true; | 3895 return true; |
| 3890 } | 3896 } |
| 3891 | 3897 |
| 3892 | 3898 |
| 3893 RawFunction* Class::CheckFunctionType(const Function& func, MemberKind kind) { | 3899 RawFunction* Class::CheckFunctionType(const Function& func, MemberKind kind) { |
| 3894 if (kind == kInstance) { | 3900 if ((kind == kInstance) || (kind == kInstanceAllowAbstract)) { |
| 3895 if (func.IsDynamicFunction()) { | 3901 if (func.IsDynamicFunction(kind == kInstanceAllowAbstract)) { |
| 3896 return func.raw(); | 3902 return func.raw(); |
| 3897 } | 3903 } |
| 3898 } else if (kind == kStatic) { | 3904 } else if (kind == kStatic) { |
| 3899 if (func.IsStaticFunction()) { | 3905 if (func.IsStaticFunction()) { |
| 3900 return func.raw(); | 3906 return func.raw(); |
| 3901 } | 3907 } |
| 3902 } else if (kind == kConstructor) { | 3908 } else if (kind == kConstructor) { |
| 3903 if (func.IsGenerativeConstructor()) { | 3909 if (func.IsGenerativeConstructor()) { |
| 3904 ASSERT(!func.is_static()); | 3910 ASSERT(!func.is_static()); |
| 3905 return func.raw(); | 3911 return func.raw(); |
| (...skipping 10376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14282 instantiated_other = TypeRef::Cast(instantiated_other).type(); | 14288 instantiated_other = TypeRef::Cast(instantiated_other).type(); |
| 14283 } | 14289 } |
| 14284 if (instantiated_other.IsDynamicType()) { | 14290 if (instantiated_other.IsDynamicType()) { |
| 14285 return true; | 14291 return true; |
| 14286 } | 14292 } |
| 14287 } | 14293 } |
| 14288 other_type_arguments = instantiated_other.arguments(); | 14294 other_type_arguments = instantiated_other.arguments(); |
| 14289 const bool other_is_dart_function = instantiated_other.IsDartFunctionType(); | 14295 const bool other_is_dart_function = instantiated_other.IsDartFunctionType(); |
| 14290 if (other_is_dart_function || instantiated_other.IsFunctionType()) { | 14296 if (other_is_dart_function || instantiated_other.IsFunctionType()) { |
| 14291 // Check if this instance understands a call() method of a compatible type. | 14297 // Check if this instance understands a call() method of a compatible type. |
| 14292 Function& call = | 14298 Function& call = Function::Handle(zone, |
| 14293 Function::Handle(zone, cls.LookupDynamicFunction(Symbols::Call())); | 14299 cls.LookupDynamicFunctionAllowAbstract(Symbols::Call())); |
| 14294 if (call.IsNull()) { | 14300 if (call.IsNull()) { |
| 14295 // Walk up the super_class chain. | 14301 // Walk up the super_class chain. |
| 14296 Class& super_cls = Class::Handle(zone, cls.SuperClass()); | 14302 Class& super_cls = Class::Handle(zone, cls.SuperClass()); |
| 14297 while (!super_cls.IsNull() && call.IsNull()) { | 14303 while (!super_cls.IsNull() && call.IsNull()) { |
| 14298 call = super_cls.LookupDynamicFunction(Symbols::Call()); | 14304 call = super_cls.LookupDynamicFunctionAllowAbstract(Symbols::Call()); |
| 14299 super_cls = super_cls.SuperClass(); | 14305 super_cls = super_cls.SuperClass(); |
| 14300 } | 14306 } |
| 14301 } | 14307 } |
| 14302 if (!call.IsNull()) { | 14308 if (!call.IsNull()) { |
| 14303 if (other_is_dart_function) { | 14309 if (other_is_dart_function) { |
| 14304 return true; | 14310 return true; |
| 14305 } | 14311 } |
| 14306 const Function& other_signature = Function::Handle( | 14312 const Function& other_signature = Function::Handle( |
| 14307 zone, FunctionType::Cast(instantiated_other).signature()); | 14313 zone, FunctionType::Cast(instantiated_other).signature()); |
| 14308 if (call.IsSubtypeOf(type_arguments, | 14314 if (call.IsSubtypeOf(type_arguments, |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15049 const Function& fun = | 15055 const Function& fun = |
| 15050 Function::Handle(zone, FunctionType::Cast(*this).signature()); | 15056 Function::Handle(zone, FunctionType::Cast(*this).signature()); |
| 15051 return fun.TypeTest(test_kind, | 15057 return fun.TypeTest(test_kind, |
| 15052 TypeArguments::Handle(zone, arguments()), | 15058 TypeArguments::Handle(zone, arguments()), |
| 15053 other_fun, | 15059 other_fun, |
| 15054 TypeArguments::Handle(zone, other.arguments()), | 15060 TypeArguments::Handle(zone, other.arguments()), |
| 15055 bound_error, | 15061 bound_error, |
| 15056 space); | 15062 space); |
| 15057 } | 15063 } |
| 15058 // Check if type S has a call() method of function type T. | 15064 // Check if type S has a call() method of function type T. |
| 15059 Function& function = | 15065 Function& function = Function::Handle(zone, |
| 15060 Function::Handle(zone, type_cls.LookupDynamicFunction(Symbols::Call())); | 15066 type_cls.LookupDynamicFunctionAllowAbstract(Symbols::Call())); |
| 15061 if (function.IsNull()) { | 15067 if (function.IsNull()) { |
| 15062 // Walk up the super_class chain. | 15068 // Walk up the super_class chain. |
| 15063 Class& cls = Class::Handle(zone, type_cls.SuperClass()); | 15069 Class& cls = Class::Handle(zone, type_cls.SuperClass()); |
| 15064 while (!cls.IsNull() && function.IsNull()) { | 15070 while (!cls.IsNull() && function.IsNull()) { |
| 15065 function = cls.LookupDynamicFunction(Symbols::Call()); | 15071 function = cls.LookupDynamicFunctionAllowAbstract(Symbols::Call()); |
| 15066 cls = cls.SuperClass(); | 15072 cls = cls.SuperClass(); |
| 15067 } | 15073 } |
| 15068 } | 15074 } |
| 15069 if (!function.IsNull()) { | 15075 if (!function.IsNull()) { |
| 15070 if (other_is_dart_function_type || | 15076 if (other_is_dart_function_type || |
| 15071 function.TypeTest(test_kind, | 15077 function.TypeTest(test_kind, |
| 15072 TypeArguments::Handle(zone, arguments()), | 15078 TypeArguments::Handle(zone, arguments()), |
| 15073 Function::Handle( | 15079 Function::Handle( |
| 15074 zone, FunctionType::Cast(other).signature()), | 15080 zone, FunctionType::Cast(other).signature()), |
| 15075 TypeArguments::Handle(zone, other.arguments()), | 15081 TypeArguments::Handle(zone, other.arguments()), |
| (...skipping 6410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21486 return UserTag::null(); | 21492 return UserTag::null(); |
| 21487 } | 21493 } |
| 21488 | 21494 |
| 21489 | 21495 |
| 21490 const char* UserTag::ToCString() const { | 21496 const char* UserTag::ToCString() const { |
| 21491 const String& tag_label = String::Handle(label()); | 21497 const String& tag_label = String::Handle(label()); |
| 21492 return tag_label.ToCString(); | 21498 return tag_label.ToCString(); |
| 21493 } | 21499 } |
| 21494 | 21500 |
| 21495 } // namespace dart | 21501 } // namespace dart |
| OLD | NEW |