| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 } | 2018 } |
| 2019 | 2019 |
| 2020 | 2020 |
| 2021 void Class::set_allocation_stub(const Code& value) const { | 2021 void Class::set_allocation_stub(const Code& value) const { |
| 2022 ASSERT(!value.IsNull()); | 2022 ASSERT(!value.IsNull()); |
| 2023 ASSERT(raw_ptr()->allocation_stub_ == Code::null()); | 2023 ASSERT(raw_ptr()->allocation_stub_ == Code::null()); |
| 2024 StorePointer(&raw_ptr()->allocation_stub_, value.raw()); | 2024 StorePointer(&raw_ptr()->allocation_stub_, value.raw()); |
| 2025 } | 2025 } |
| 2026 | 2026 |
| 2027 | 2027 |
| 2028 bool Class::IsFunctionClass() const { |
| 2029 return raw() == Type::Handle(Type::Function()).type_class(); |
| 2030 } |
| 2031 |
| 2032 |
| 2028 bool Class::IsListClass() const { | 2033 bool Class::IsListClass() const { |
| 2029 return raw() == Isolate::Current()->object_store()->list_class(); | 2034 return raw() == Isolate::Current()->object_store()->list_class(); |
| 2030 } | 2035 } |
| 2031 | 2036 |
| 2032 | 2037 |
| 2033 bool Class::IsCanonicalSignatureClass() const { | 2038 bool Class::IsCanonicalSignatureClass() const { |
| 2034 const Function& function = Function::Handle(signature_function()); | 2039 const Function& function = Function::Handle(signature_function()); |
| 2035 return (!function.IsNull() && (function.signature_class() == raw())); | 2040 return (!function.IsNull() && (function.signature_class() == raw())); |
| 2036 } | 2041 } |
| 2037 | 2042 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2091 } | 2096 } |
| 2092 if (type_arguments.IsNull() || | 2097 if (type_arguments.IsNull() || |
| 2093 type_arguments.IsRawInstantiatedRaw(len)) { | 2098 type_arguments.IsRawInstantiatedRaw(len)) { |
| 2094 return test_kind == kIsSubtypeOf; | 2099 return test_kind == kIsSubtypeOf; |
| 2095 } | 2100 } |
| 2096 return type_arguments.TypeTest(test_kind, | 2101 return type_arguments.TypeTest(test_kind, |
| 2097 other_type_arguments, | 2102 other_type_arguments, |
| 2098 len, | 2103 len, |
| 2099 malformed_error); | 2104 malformed_error); |
| 2100 } | 2105 } |
| 2101 // TODO(regis): Check if type S has a call() method of function type T. | 2106 const bool other_is_function_class = other.IsFunctionClass(); |
| 2102 // Check for two function types. | 2107 if (other.IsSignatureClass() || other_is_function_class) { |
| 2103 if (IsSignatureClass() && other.IsSignatureClass()) { | |
| 2104 const Function& fun = Function::Handle(signature_function()); | |
| 2105 const Function& other_fun = Function::Handle(other.signature_function()); | 2108 const Function& other_fun = Function::Handle(other.signature_function()); |
| 2106 return fun.TypeTest(test_kind, | 2109 if (IsSignatureClass()) { |
| 2107 type_arguments, | 2110 if (other_is_function_class) { |
| 2108 other_fun, | 2111 return true; |
| 2109 other_type_arguments, | 2112 } |
| 2110 malformed_error); | 2113 // Check for two function types. |
| 2114 const Function& fun = Function::Handle(signature_function()); |
| 2115 return fun.TypeTest(test_kind, |
| 2116 type_arguments, |
| 2117 other_fun, |
| 2118 other_type_arguments, |
| 2119 malformed_error); |
| 2120 } |
| 2121 // Check if type S has a call() method of function type T. |
| 2122 const String& function_name = String::Handle(Symbols::Call()); |
| 2123 Function& function = Function::Handle(LookupDynamicFunction(function_name)); |
| 2124 if (function.IsNull()) { |
| 2125 // Walk up the super_class chain. |
| 2126 Class& cls = Class::Handle(SuperClass()); |
| 2127 while (!cls.IsNull() && function.IsNull()) { |
| 2128 function = cls.LookupDynamicFunction(function_name); |
| 2129 cls = cls.SuperClass(); |
| 2130 } |
| 2131 } |
| 2132 if (!function.IsNull()) { |
| 2133 if (other_is_function_class || |
| 2134 function.TypeTest(test_kind, |
| 2135 type_arguments, |
| 2136 other_fun, |
| 2137 other_type_arguments, |
| 2138 malformed_error)) { |
| 2139 return true; |
| 2140 } |
| 2141 } |
| 2111 } | 2142 } |
| 2112 // Check for 'direct super type' specified in the implements clause | 2143 // Check for 'direct super type' specified in the implements clause |
| 2113 // and check for transitivity at the same time. | 2144 // and check for transitivity at the same time. |
| 2114 Array& interfaces = Array::Handle(this->interfaces()); | 2145 Array& interfaces = Array::Handle(this->interfaces()); |
| 2115 AbstractType& interface = AbstractType::Handle(); | 2146 AbstractType& interface = AbstractType::Handle(); |
| 2116 Class& interface_class = Class::Handle(); | 2147 Class& interface_class = Class::Handle(); |
| 2117 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); | 2148 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); |
| 2118 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 2149 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
| 2119 interface ^= interfaces.At(i); | 2150 interface ^= interfaces.At(i); |
| 2120 interface_class = interface.type_class(); | 2151 interface_class = interface.type_class(); |
| (...skipping 10176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12297 } | 12328 } |
| 12298 return result.raw(); | 12329 return result.raw(); |
| 12299 } | 12330 } |
| 12300 | 12331 |
| 12301 | 12332 |
| 12302 const char* WeakProperty::ToCString() const { | 12333 const char* WeakProperty::ToCString() const { |
| 12303 return "_WeakProperty"; | 12334 return "_WeakProperty"; |
| 12304 } | 12335 } |
| 12305 | 12336 |
| 12306 } // namespace dart | 12337 } // namespace dart |
| OLD | NEW |