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

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

Issue 11411271: Remove support for interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | Annotate | Revision Log
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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 sentinel_ = sentinel.raw(); 295 sentinel_ = sentinel.raw();
296 296
297 Instance& transition_sentinel = Instance::Handle(); 297 Instance& transition_sentinel = Instance::Handle();
298 transition_sentinel ^= 298 transition_sentinel ^=
299 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); 299 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
300 transition_sentinel_ = transition_sentinel.raw(); 300 transition_sentinel_ = transition_sentinel.raw();
301 } 301 }
302 302
303 cls = Class::New<Instance>(kDynamicCid); 303 cls = Class::New<Instance>(kDynamicCid);
304 cls.set_is_finalized(); 304 cls.set_is_finalized();
305 cls.set_is_interface(); 305 cls.set_is_abstract();
306 dynamic_class_ = cls.raw(); 306 dynamic_class_ = cls.raw();
307 307
308 // Allocate the remaining VM internal classes. 308 // Allocate the remaining VM internal classes.
309 cls = Class::New<UnresolvedClass>(); 309 cls = Class::New<UnresolvedClass>();
310 unresolved_class_class_ = cls.raw(); 310 unresolved_class_class_ = cls.raw();
311 311
312 cls = Class::New<Instance>(kVoidCid); 312 cls = Class::New<Instance>(kVoidCid);
313 cls.set_is_finalized(); 313 cls.set_is_finalized();
314 void_class_ = cls.raw(); 314 void_class_ = cls.raw();
315 315
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1777
1778 1778
1779 RawClass* Class::New(const String& name, 1779 RawClass* Class::New(const String& name,
1780 const Script& script, 1780 const Script& script,
1781 intptr_t token_pos) { 1781 intptr_t token_pos) {
1782 Class& result = Class::Handle(New<Instance>(name, script, token_pos)); 1782 Class& result = Class::Handle(New<Instance>(name, script, token_pos));
1783 return result.raw(); 1783 return result.raw();
1784 } 1784 }
1785 1785
1786 1786
1787 RawClass* Class::NewInterface(const String& name,
1788 const Script& script,
1789 intptr_t token_pos) {
1790 Class& result = Class::Handle(New<Instance>(name, script, token_pos));
1791 result.set_is_interface();
1792 return result.raw();
1793 }
1794
1795
1796 RawClass* Class::NewSignatureClass(const String& name, 1787 RawClass* Class::NewSignatureClass(const String& name,
1797 const Function& signature_function, 1788 const Function& signature_function,
1798 const Script& script) { 1789 const Script& script) {
1799 ASSERT(!signature_function.IsNull()); 1790 ASSERT(!signature_function.IsNull());
1800 const Class& owner_class = Class::Handle(signature_function.Owner()); 1791 const Class& owner_class = Class::Handle(signature_function.Owner());
1801 ASSERT(!owner_class.IsNull()); 1792 ASSERT(!owner_class.IsNull());
1802 TypeArguments& type_parameters = TypeArguments::Handle(); 1793 TypeArguments& type_parameters = TypeArguments::Handle();
1803 // A signature class extends class Instance and is parameterized in the same 1794 // A signature class extends class Instance and is parameterized in the same
1804 // way as the owner class of its non-static signature function. 1795 // way as the owner class of its non-static signature function.
1805 // It is not type parameterized if its signature function is static. 1796 // It is not type parameterized if its signature function is static.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 StorePointer(&raw_ptr()->script_, value.raw()); 1899 StorePointer(&raw_ptr()->script_, value.raw());
1909 } 1900 }
1910 1901
1911 1902
1912 void Class::set_token_pos(intptr_t token_pos) const { 1903 void Class::set_token_pos(intptr_t token_pos) const {
1913 ASSERT(token_pos >= 0); 1904 ASSERT(token_pos >= 0);
1914 raw_ptr()->token_pos_ = token_pos; 1905 raw_ptr()->token_pos_ = token_pos;
1915 } 1906 }
1916 1907
1917 1908
1918 void Class::set_is_interface() const {
1919 set_state_bits(InterfaceBit::update(true, raw_ptr()->state_bits_));
1920 }
1921
1922
1923 void Class::set_is_implemented() const { 1909 void Class::set_is_implemented() const {
1924 set_state_bits(ImplementedBit::update(true, raw_ptr()->state_bits_)); 1910 set_state_bits(ImplementedBit::update(true, raw_ptr()->state_bits_));
srdjan 2012/11/29 23:52:12 Weird diff. Is set_is_implemented really twice in
regis 2012/11/30 00:24:30 I do not see this duplication in the source.
1925 } 1911 }
1926 1912
1927 1913
1928 void Class::set_is_abstract() const { 1914 void Class::set_is_abstract() const {
1929 set_state_bits(AbstractBit::update(true, raw_ptr()->state_bits_)); 1915 set_state_bits(AbstractBit::update(true, raw_ptr()->state_bits_));
1930 } 1916 }
1931 1917
1932 1918
1933 void Class::set_is_const() const { 1919 void Class::set_is_const() const {
1934 set_state_bits(ConstBit::update(true, raw_ptr()->state_bits_)); 1920 set_state_bits(ConstBit::update(true, raw_ptr()->state_bits_));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 // Check for NullType, which is not a subtype of any type, but is more 2029 // Check for NullType, which is not a subtype of any type, but is more
2044 // specific than any type. 2030 // specific than any type.
2045 if (IsNullClass()) { 2031 if (IsNullClass()) {
2046 // User code cannot refer to class Null, therefore, we can only encounter 2032 // User code cannot refer to class Null, therefore, we can only encounter
2047 // NullType here as the type of the null constant, which must be treated 2033 // NullType here as the type of the null constant, which must be treated
2048 // separately in 'instance of' checks. Therefore, the NullType can only 2034 // separately in 'instance of' checks. Therefore, the NullType can only
2049 // be encountered here during optimizations in 'more specific than' tests. 2035 // be encountered here during optimizations in 'more specific than' tests.
2050 ASSERT(test_kind == kIsMoreSpecificThan); 2036 ASSERT(test_kind == kIsMoreSpecificThan);
2051 return true; 2037 return true;
2052 } 2038 }
2039 // Check for ObjectType. Any type that is not NullType or DynamicType (already
2040 // checked above), is more specific than ObjectType.
2041 if (other.IsObjectClass()) {
2042 return true;
2043 }
2053 // Check for reflexivity. 2044 // Check for reflexivity.
2054 if (raw() == other.raw()) { 2045 if (raw() == other.raw()) {
2055 const intptr_t len = NumTypeArguments(); 2046 const intptr_t len = NumTypeArguments();
2056 if (len == 0) { 2047 if (len == 0) {
2057 return true; 2048 return true;
2058 } 2049 }
2059 // Since we do not truncate the type argument vector of a subclass (see 2050 // Since we do not truncate the type argument vector of a subclass (see
2060 // below), we only check a prefix of the proper length. 2051 // below), we only check a prefix of the proper length.
2061 // Check for covariance. 2052 // Check for covariance.
2062 if (other_type_arguments.IsNull() || 2053 if (other_type_arguments.IsNull() ||
2063 other_type_arguments.IsRawInstantiatedRaw(len)) { 2054 other_type_arguments.IsRawInstantiatedRaw(len)) {
2064 return true; 2055 return true;
2065 } 2056 }
2066 if (type_arguments.IsNull() || 2057 if (type_arguments.IsNull() ||
2067 type_arguments.IsRawInstantiatedRaw(len)) { 2058 type_arguments.IsRawInstantiatedRaw(len)) {
2068 return test_kind == kIsSubtypeOf; 2059 return test_kind == kIsSubtypeOf;
2069 } 2060 }
2070 return type_arguments.TypeTest(test_kind, 2061 return type_arguments.TypeTest(test_kind,
2071 other_type_arguments, 2062 other_type_arguments,
2072 len, 2063 len,
2073 malformed_error); 2064 malformed_error);
2074 } 2065 }
2075 // TODO(regis): Check for interface type S implementing method call() of 2066 // TODO(regis): Check if type S has a call() method of function type T.
2076 // function type T.
2077 // Check for two function types. 2067 // Check for two function types.
2078 if (IsSignatureClass() && other.IsSignatureClass()) { 2068 if (IsSignatureClass() && other.IsSignatureClass()) {
2079 const Function& fun = Function::Handle(signature_function()); 2069 const Function& fun = Function::Handle(signature_function());
2080 const Function& other_fun = Function::Handle(other.signature_function()); 2070 const Function& other_fun = Function::Handle(other.signature_function());
2081 return fun.TypeTest(test_kind, 2071 return fun.TypeTest(test_kind,
2082 type_arguments, 2072 type_arguments,
2083 other_fun, 2073 other_fun,
2084 other_type_arguments, 2074 other_type_arguments,
2085 malformed_error); 2075 malformed_error);
2086 } 2076 }
2087 // Check for 'direct super type' in the case of an interface 2077 // Check for 'direct super type' specified in the implements clause
2088 // (i.e. other.is_interface()) or implicit interface (i.e. 2078 // and check for transitivity at the same time.
2089 // !other.is_interface()) and check for transitivity at the same time.
2090 Array& interfaces = Array::Handle(this->interfaces()); 2079 Array& interfaces = Array::Handle(this->interfaces());
2091 AbstractType& interface = AbstractType::Handle(); 2080 AbstractType& interface = AbstractType::Handle();
2092 Class& interface_class = Class::Handle(); 2081 Class& interface_class = Class::Handle();
2093 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); 2082 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle();
2094 for (intptr_t i = 0; i < interfaces.Length(); i++) { 2083 for (intptr_t i = 0; i < interfaces.Length(); i++) {
2095 interface ^= interfaces.At(i); 2084 interface ^= interfaces.At(i);
2096 interface_class = interface.type_class(); 2085 interface_class = interface.type_class();
2097 interface_args = interface.arguments(); 2086 interface_args = interface.arguments();
2098 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) { 2087 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) {
2099 // This type class implements an interface that is parameterized with 2088 // This type class implements an interface that is parameterized with
(...skipping 21 matching lines...) Expand all
2121 } 2110 }
2122 } 2111 }
2123 if (interface_class.TypeTest(test_kind, 2112 if (interface_class.TypeTest(test_kind,
2124 interface_args, 2113 interface_args,
2125 other, 2114 other,
2126 other_type_arguments, 2115 other_type_arguments,
2127 malformed_error)) { 2116 malformed_error)) {
2128 return true; 2117 return true;
2129 } 2118 }
2130 } 2119 }
2131 // Check the interface case.
2132 if (is_interface()) {
2133 // We already checked the case where 'other' is an interface. Now, 'this',
2134 // an interface, cannot be more specific than a class, except class Object,
2135 // because although Object is not considered an interface by the vm, it is
2136 // one. In other words, all classes implementing this interface also extend
2137 // class Object. An interface is also more specific than the DynamicType.
2138 return (other.IsDynamicClass() || other.IsObjectClass());
2139 }
2140 const Class& super_class = Class::Handle(SuperClass()); 2120 const Class& super_class = Class::Handle(SuperClass());
2141 if (super_class.IsNull()) { 2121 if (super_class.IsNull()) {
2142 return false; 2122 return false;
2143 } 2123 }
2144 // Instead of truncating the type argument vector to the length of the super 2124 // Instead of truncating the type argument vector to the length of the super
2145 // type argument vector, we make sure that the code works with a vector that 2125 // type argument vector, we make sure that the code works with a vector that
2146 // is longer than necessary. 2126 // is longer than necessary.
2147 return super_class.TypeTest(test_kind, 2127 return super_class.TypeTest(test_kind,
2148 type_arguments, 2128 type_arguments,
2149 other, 2129 other,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 const Object& obj = Object::Handle(isolate, lib.LookupLocalObject(name)); 2331 const Object& obj = Object::Handle(isolate, lib.LookupLocalObject(name));
2352 if (!obj.IsNull() && obj.IsLibraryPrefix()) { 2332 if (!obj.IsNull() && obj.IsLibraryPrefix()) {
2353 const LibraryPrefix& lib_prefix = LibraryPrefix::Cast(obj); 2333 const LibraryPrefix& lib_prefix = LibraryPrefix::Cast(obj);
2354 return lib_prefix.raw(); 2334 return lib_prefix.raw();
2355 } 2335 }
2356 return LibraryPrefix::null(); 2336 return LibraryPrefix::null();
2357 } 2337 }
2358 2338
2359 2339
2360 const char* Class::ToCString() const { 2340 const char* Class::ToCString() const {
2361 const char* format = is_interface() 2341 const char* format = "%s Class: %s";
2362 ? "%s Interface: %s" : "%s Class: %s";
2363 const Library& lib = Library::Handle(library()); 2342 const Library& lib = Library::Handle(library());
2364 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); 2343 const char* library_name = lib.IsNull() ? "" : lib.ToCString();
2365 const char* class_name = String::Handle(Name()).ToCString(); 2344 const char* class_name = String::Handle(Name()).ToCString();
2366 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; 2345 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1;
2367 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 2346 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2368 OS::SNPrint(chars, len, format, library_name, class_name); 2347 OS::SNPrint(chars, len, format, library_name, class_name);
2369 return chars; 2348 return chars;
2370 } 2349 }
2371 2350
2372 2351
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2554 if (arguments.IsNull()) { 2533 if (arguments.IsNull()) {
2555 return other_arguments.IsDynamicTypes(false, other_arguments.Length()); 2534 return other_arguments.IsDynamicTypes(false, other_arguments.Length());
2556 } 2535 }
2557 if (other_arguments.IsNull()) { 2536 if (other_arguments.IsNull()) {
2558 return arguments.IsDynamicTypes(false, arguments.Length()); 2537 return arguments.IsDynamicTypes(false, arguments.Length());
2559 } 2538 }
2560 return arguments.Equals(other_arguments); 2539 return arguments.Equals(other_arguments);
2561 } 2540 }
2562 2541
2563 2542
2564 bool AbstractTypeArguments::AreIdentical(
2565 const AbstractTypeArguments& arguments,
2566 const AbstractTypeArguments& other_arguments,
2567 bool check_type_parameter_bounds) {
2568 if (arguments.raw() == other_arguments.raw()) {
2569 return true;
2570 }
2571 if (arguments.IsNull() || other_arguments.IsNull()) {
2572 return false;
2573 }
2574 intptr_t num_types = arguments.Length();
2575 if (num_types != other_arguments.Length()) {
2576 return false;
2577 }
2578 AbstractType& type = AbstractType::Handle();
2579 AbstractType& other_type = AbstractType::Handle();
2580 for (intptr_t i = 0; i < num_types; i++) {
2581 type = arguments.TypeAt(i);
2582 ASSERT(!type.IsNull());
2583 other_type = other_arguments.TypeAt(i);
2584 if (!type.IsIdentical(other_type, check_type_parameter_bounds)) {
2585 return false;
2586 }
2587 }
2588 return true;
2589 }
2590
2591
2592 RawAbstractTypeArguments* AbstractTypeArguments::InstantiateFrom( 2543 RawAbstractTypeArguments* AbstractTypeArguments::InstantiateFrom(
2593 const AbstractTypeArguments& instantiator_type_arguments) const { 2544 const AbstractTypeArguments& instantiator_type_arguments) const {
2594 // AbstractTypeArguments is an abstract class. 2545 // AbstractTypeArguments is an abstract class.
2595 UNREACHABLE(); 2546 UNREACHABLE();
2596 return NULL; 2547 return NULL;
2597 } 2548 }
2598 2549
2599 2550
2600 bool AbstractTypeArguments::IsDynamicTypes(bool raw_instantiated, 2551 bool AbstractTypeArguments::IsDynamicTypes(bool raw_instantiated,
2601 intptr_t len) const { 2552 intptr_t len) const {
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
4172 tokens_iterator.Advance(); 4123 tokens_iterator.Advance();
4173 } 4124 }
4174 result = result & ((static_cast<uint32_t>(1) << 31) - 1); 4125 result = result & ((static_cast<uint32_t>(1) << 31) - 1);
4175 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); 4126 ASSERT(result <= static_cast<uint32_t>(kMaxInt32));
4176 return result; 4127 return result;
4177 } 4128 }
4178 4129
4179 4130
4180 bool Function::CheckSourceFingerprint(intptr_t fp) const { 4131 bool Function::CheckSourceFingerprint(intptr_t fp) const {
4181 if (SourceFingerprint() != fp) { 4132 if (SourceFingerprint() != fp) {
4182 OS::Print("FP mismatch while recogbnizing method %s:" 4133 OS::Print("FP mismatch while recognizing method %s:"
4183 " expecting %"Pd" found %d\n", 4134 " expecting %"Pd" found %d\n",
4184 ToFullyQualifiedCString(), 4135 ToFullyQualifiedCString(),
4185 fp, 4136 fp,
4186 SourceFingerprint()); 4137 SourceFingerprint());
4187 return false; 4138 return false;
4188 } 4139 }
4189 return true; 4140 return true;
4190 } 4141 }
4191 4142
4192 4143
(...skipping 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after
6350 Error& error = Error::Handle(); 6301 Error& error = Error::Handle();
6351 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 6302 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
6352 Isolate::Current()->object_store()->libraries()); 6303 Isolate::Current()->object_store()->libraries());
6353 Library& lib = Library::Handle(); 6304 Library& lib = Library::Handle();
6354 Class& cls = Class::Handle(); 6305 Class& cls = Class::Handle();
6355 for (int i = 0; i < libs.Length(); i++) { 6306 for (int i = 0; i < libs.Length(); i++) {
6356 lib ^= libs.At(i); 6307 lib ^= libs.At(i);
6357 ClassDictionaryIterator it(lib); 6308 ClassDictionaryIterator it(lib);
6358 while (it.HasNext()) { 6309 while (it.HasNext()) {
6359 cls ^= it.GetNextClass(); 6310 cls ^= it.GetNextClass();
6360 if (!cls.is_interface()) { 6311 error = Compiler::CompileAllFunctions(cls);
6361 error = Compiler::CompileAllFunctions(cls); 6312 if (!error.IsNull()) {
6362 if (!error.IsNull()) { 6313 return error.raw();
6363 return error.raw();
6364 }
6365 } 6314 }
6366 } 6315 }
6367 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); 6316 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_);
6368 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { 6317 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) {
6369 cls ^= anon_classes.At(i); 6318 cls ^= anon_classes.At(i);
6370 ASSERT(!cls.is_interface());
6371 error = Compiler::CompileAllFunctions(cls); 6319 error = Compiler::CompileAllFunctions(cls);
6372 if (!error.IsNull()) { 6320 if (!error.IsNull()) {
6373 return error.raw(); 6321 return error.raw();
6374 } 6322 }
6375 } 6323 }
6376 } 6324 }
6377 return error.raw(); 6325 return error.raw();
6378 } 6326 }
6379 6327
6380 6328
(...skipping 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after
8417 } 8365 }
8418 8366
8419 8367
8420 bool AbstractType::Equals(const Instance& other) const { 8368 bool AbstractType::Equals(const Instance& other) const {
8421 // AbstractType is an abstract class. 8369 // AbstractType is an abstract class.
8422 UNREACHABLE(); 8370 UNREACHABLE();
8423 return false; 8371 return false;
8424 } 8372 }
8425 8373
8426 8374
8427 bool AbstractType::IsIdentical(const AbstractType& other,
8428 bool check_type_parameter_bound) const {
8429 // AbstractType is an abstract class.
8430 UNREACHABLE();
8431 return false;
8432 }
8433
8434
8435 RawAbstractType* AbstractType::InstantiateFrom( 8375 RawAbstractType* AbstractType::InstantiateFrom(
8436 const AbstractTypeArguments& instantiator_type_arguments) const { 8376 const AbstractTypeArguments& instantiator_type_arguments) const {
8437 // AbstractType is an abstract class. 8377 // AbstractType is an abstract class.
8438 UNREACHABLE(); 8378 UNREACHABLE();
8439 return NULL; 8379 return NULL;
8440 } 8380 }
8441 8381
8442 8382
8443 RawAbstractType* AbstractType::Canonicalize() const { 8383 RawAbstractType* AbstractType::Canonicalize() const {
8444 // AbstractType is an abstract class. 8384 // AbstractType is an abstract class.
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
8848 } 8788 }
8849 if (type_class() != other_type.type_class()) { 8789 if (type_class() != other_type.type_class()) {
8850 return false; 8790 return false;
8851 } 8791 }
8852 return AbstractTypeArguments::AreEqual( 8792 return AbstractTypeArguments::AreEqual(
8853 AbstractTypeArguments::Handle(arguments()), 8793 AbstractTypeArguments::Handle(arguments()),
8854 AbstractTypeArguments::Handle(other_type.arguments())); 8794 AbstractTypeArguments::Handle(other_type.arguments()));
8855 } 8795 }
8856 8796
8857 8797
8858 bool Type::IsIdentical(const AbstractType& other,
8859 bool check_type_parameter_bounds) const {
8860 if (raw() == other.raw()) {
8861 return true;
8862 }
8863 if (!other.IsType()) {
8864 return false;
8865 }
8866 // Both type classes may not be resolved yet.
8867 String& name = String::Handle(TypeClassName());
8868 String& other_name = String::Handle(Type::Cast(other).TypeClassName());
8869 if (!name.Equals(other_name)) {
8870 return false;
8871 }
8872 return AbstractTypeArguments::AreIdentical(
8873 AbstractTypeArguments::Handle(arguments()),
8874 AbstractTypeArguments::Handle(other.arguments()),
8875 false); // Bounds are only checked at the top level.
8876 }
8877
8878
8879 RawAbstractType* Type::Canonicalize() const { 8798 RawAbstractType* Type::Canonicalize() const {
8880 ASSERT(IsFinalized()); 8799 ASSERT(IsFinalized());
8881 if (IsCanonical() || IsMalformed()) { 8800 if (IsCanonical() || IsMalformed()) {
8882 ASSERT(IsMalformed() || AbstractTypeArguments::Handle(arguments()).IsOld()); 8801 ASSERT(IsMalformed() || AbstractTypeArguments::Handle(arguments()).IsOld());
8883 return this->raw(); 8802 return this->raw();
8884 } 8803 }
8885 const Class& cls = Class::Handle(type_class()); 8804 const Class& cls = Class::Handle(type_class());
8886 Array& canonical_types = Array::Handle(cls.canonical_types()); 8805 Array& canonical_types = Array::Handle(cls.canonical_types());
8887 if (canonical_types.IsNull()) { 8806 if (canonical_types.IsNull()) {
8888 // Types defined in the VM isolate are canonicalized via the object store. 8807 // Types defined in the VM isolate are canonicalized via the object store.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
9033 } 8952 }
9034 if (index() != other_type_param.index()) { 8953 if (index() != other_type_param.index()) {
9035 return false; 8954 return false;
9036 } 8955 }
9037 const String& type_param_name = String::Handle(name()); 8956 const String& type_param_name = String::Handle(name());
9038 const String& other_type_param_name = String::Handle(other_type_param.name()); 8957 const String& other_type_param_name = String::Handle(other_type_param.name());
9039 return type_param_name.Equals(other_type_param_name); 8958 return type_param_name.Equals(other_type_param_name);
9040 } 8959 }
9041 8960
9042 8961
9043 bool TypeParameter::IsIdentical(const AbstractType& other,
9044 bool check_type_parameter_bound) const {
9045 if (raw() == other.raw()) {
9046 return true;
9047 }
9048 if (!other.IsTypeParameter()) {
9049 return false;
9050 }
9051 const TypeParameter& other_type_param = TypeParameter::Cast(other);
9052 // IsIdentical may be called on type parameters belonging to different
9053 // classes, e.g. to an interface and to its default factory class.
9054 // Therefore, both type parameters may have different parameterized classes
9055 // and different indices. Compare the type parameter names only, and their
9056 // bounds if requested.
9057 String& type_param_name = String::Handle(name());
9058 String& other_type_param_name = String::Handle(other_type_param.name());
9059 if (!type_param_name.Equals(other_type_param_name)) {
9060 return false;
9061 }
9062 if (check_type_parameter_bound) {
9063 AbstractType& this_bound = AbstractType::Handle(bound());
9064 AbstractType& other_bound = AbstractType::Handle(other_type_param.bound());
9065 // Bounds are only checked at the top level.
9066 const bool check_type_parameter_bounds = false;
9067 if (!this_bound.IsIdentical(other_bound, check_type_parameter_bounds)) {
9068 return false;
9069 }
9070 }
9071 return true;
9072 }
9073
9074
9075 void TypeParameter::set_parameterized_class(const Class& value) const { 8962 void TypeParameter::set_parameterized_class(const Class& value) const {
9076 // Set value may be null. 8963 // Set value may be null.
9077 StorePointer(&raw_ptr()->parameterized_class_, value.raw()); 8964 StorePointer(&raw_ptr()->parameterized_class_, value.raw());
9078 } 8965 }
9079 8966
9080 8967
9081 void TypeParameter::set_index(intptr_t value) const { 8968 void TypeParameter::set_index(intptr_t value) const {
9082 ASSERT(value >= 0); 8969 ASSERT(value >= 0);
9083 raw_ptr()->index_ = value; 8970 raw_ptr()->index_ = value;
9084 } 8971 }
(...skipping 3104 matching lines...) Expand 10 before | Expand all | Expand 10 after
12189 } 12076 }
12190 return result.raw(); 12077 return result.raw();
12191 } 12078 }
12192 12079
12193 12080
12194 const char* WeakProperty::ToCString() const { 12081 const char* WeakProperty::ToCString() const {
12195 return "_WeakProperty"; 12082 return "_WeakProperty";
12196 } 12083 }
12197 12084
12198 } // namespace dart 12085 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698