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

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

Issue 22425006: Fix equality of implicit closures in the Dart VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: new simpler approach Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 // Check for illegal self references. 1521 // Check for illegal self references.
1522 GrowableArray<intptr_t> visited_aliases; 1522 GrowableArray<intptr_t> visited_aliases;
1523 if (!IsAliasCycleFree(cls, &visited_aliases)) { 1523 if (!IsAliasCycleFree(cls, &visited_aliases)) {
1524 const String& name = String::Handle(cls.Name()); 1524 const String& name = String::Handle(cls.Name());
1525 const Script& script = Script::Handle(cls.script()); 1525 const Script& script = Script::Handle(cls.script());
1526 ReportError(script, cls.token_pos(), 1526 ReportError(script, cls.token_pos(),
1527 "typedef '%s' illegally refers to itself", 1527 "typedef '%s' illegally refers to itself",
1528 name.ToCString()); 1528 name.ToCString());
1529 } 1529 }
1530 cls.set_is_type_finalized(); 1530 cls.set_is_type_finalized();
1531 // Signature classes extend Object. No need to add this class to the direct
1532 // subclasses of Object.
1533 ASSERT(super_type.IsNull() || super_type.IsObjectType());
Florian Schneider 2013/08/12 18:03:06 Do we rely on this assertion somewhere else?
1534 1531
1535 // The type parameters of signature classes may have bounds. 1532 // The type parameters of signature classes may have bounds.
1536 FinalizeUpperBounds(cls); 1533 FinalizeUpperBounds(cls);
1537 1534
1538 // Resolve and finalize the result and parameter types of the signature 1535 // Resolve and finalize the result and parameter types of the signature
1539 // function of this signature class. 1536 // function of this signature class.
1540 const Function& sig_function = Function::Handle(cls.signature_function()); 1537 const Function& sig_function = Function::Handle(cls.signature_function());
1541 ResolveAndFinalizeSignature(cls, sig_function); 1538 ResolveAndFinalizeSignature(cls, sig_function);
1542 1539
1543 // Resolve and finalize the signature type of this signature class. 1540 // Resolve and finalize the signature type of this signature class.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 case kArrayCid: 1870 case kArrayCid:
1874 case kImmutableArrayCid: 1871 case kImmutableArrayCid:
1875 case kGrowableObjectArrayCid: 1872 case kGrowableObjectArrayCid:
1876 #define DO_NOT_EXTEND_TYPED_DATA_CLASSES(clazz) \ 1873 #define DO_NOT_EXTEND_TYPED_DATA_CLASSES(clazz) \
1877 case kTypedData##clazz##Cid: \ 1874 case kTypedData##clazz##Cid: \
1878 case kTypedData##clazz##ViewCid: \ 1875 case kTypedData##clazz##ViewCid: \
1879 case kExternalTypedData##clazz##Cid: 1876 case kExternalTypedData##clazz##Cid:
1880 CLASS_LIST_TYPED_DATA(DO_NOT_EXTEND_TYPED_DATA_CLASSES) 1877 CLASS_LIST_TYPED_DATA(DO_NOT_EXTEND_TYPED_DATA_CLASSES)
1881 #undef DO_NOT_EXTEND_TYPED_DATA_CLASSES 1878 #undef DO_NOT_EXTEND_TYPED_DATA_CLASSES
1882 case kByteDataViewCid: 1879 case kByteDataViewCid:
1883 case kDartFunctionCid:
1884 case kWeakPropertyCid: 1880 case kWeakPropertyCid:
1885 is_error = true; 1881 is_error = true;
1886 break; 1882 break;
1883 case kDartFunctionCid:
1884 // Signature classes, which are compiler generated and represent a
Ivan Posva 2013/08/13 07:35:09 I don't think this is a valid restriction.
Florian Schneider 2013/08/13 14:52:20 Done.
1885 // function type, are allowed to extend the Function class.
1886 if (!cls.IsSignatureClass()) is_error = true;
1887 break;
1887 default: { 1888 default: {
1888 // Special case: classes for which we don't have a known class id. 1889 // Special case: classes for which we don't have a known class id.
1889 if (super_type.IsDoubleType() || 1890 if (super_type.IsDoubleType() ||
1890 super_type.IsIntType() || 1891 super_type.IsIntType() ||
1891 super_type.IsStringType()) { 1892 super_type.IsStringType()) {
1892 is_error = true; 1893 is_error = true;
1893 } 1894 }
1894 break; 1895 break;
1895 } 1896 }
1896 } 1897 }
(...skipping 22 matching lines...) Expand all
1919 "'dynamic' may not be used as interface"); 1920 "'dynamic' may not be used as interface");
1920 } 1921 }
1921 interface_class = interface.type_class(); 1922 interface_class = interface.type_class();
1922 if (interface_class.IsSignatureClass()) { 1923 if (interface_class.IsSignatureClass()) {
1923 const Script& script = Script::Handle(cls.script()); 1924 const Script& script = Script::Handle(cls.script());
1924 ReportError(script, cls.token_pos(), 1925 ReportError(script, cls.token_pos(),
1925 "'%s' is used where an interface or class name is expected", 1926 "'%s' is used where an interface or class name is expected",
1926 String::Handle(interface_class.Name()).ToCString()); 1927 String::Handle(interface_class.Name()).ToCString());
1927 } 1928 }
1928 // Verify that unless cls belongs to core lib, it cannot extend or implement 1929 // Verify that unless cls belongs to core lib, it cannot extend or implement
1929 // any of bool, num, int, double, String, Function, dynamic. 1930 // any of bool, num, int, double, String, Function, dynamic.
Ivan Posva 2013/08/13 07:35:09 ditto for Function
Florian Schneider 2013/08/13 14:52:20 Done.
1930 // The exception is signature classes, which are compiler generated and 1931 // The exception is signature classes, which are compiler generated and
1931 // represent a function type, therefore implementing the Function interface. 1932 // represent a function type, therefore implementing the Function interface.
1932 if (!cls_belongs_to_core_lib) { 1933 if (!cls_belongs_to_core_lib) {
1933 if (interface.IsBoolType() || 1934 if (interface.IsBoolType() ||
1934 interface.IsNumberType() || 1935 interface.IsNumberType() ||
1935 interface.IsIntType() || 1936 interface.IsIntType() ||
1936 interface.IsDoubleType() || 1937 interface.IsDoubleType() ||
1937 interface.IsStringType() || 1938 interface.IsStringType() ||
1938 (interface.IsFunctionType() && !cls.IsSignatureClass()) || 1939 interface.IsFunctionType() ||
1939 interface.IsDynamicType()) { 1940 interface.IsDynamicType()) {
1940 const Script& script = Script::Handle(cls.script()); 1941 const Script& script = Script::Handle(cls.script());
1941 ReportError(script, cls.token_pos(), 1942 ReportError(script, cls.token_pos(),
1942 "'%s' is not allowed to extend or implement '%s'", 1943 "'%s' is not allowed to extend or implement '%s'",
1943 String::Handle(cls.Name()).ToCString(), 1944 String::Handle(cls.Name()).ToCString(),
1944 String::Handle(interface_class.Name()).ToCString()); 1945 String::Handle(interface_class.Name()).ToCString());
1945 } 1946 }
1946 } 1947 }
1947 interface_class.set_is_implemented(); 1948 interface_class.set_is_implemented();
1948 // Now resolve the super interfaces. 1949 // Now resolve the super interfaces.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 expected_name ^= String::New("_offset"); 2167 expected_name ^= String::New("_offset");
2167 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 2168 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2168 field ^= fields_array.At(2); 2169 field ^= fields_array.At(2);
2169 ASSERT(field.Offset() == TypedDataView::length_offset()); 2170 ASSERT(field.Offset() == TypedDataView::length_offset());
2170 name ^= field.name(); 2171 name ^= field.name();
2171 ASSERT(name.Equals("length")); 2172 ASSERT(name.Equals("length"));
2172 #endif 2173 #endif
2173 } 2174 }
2174 2175
2175 } // namespace dart 2176 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698