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

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

Issue 22819005: Make Null a public class of dart:core. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase on dart2js's putback 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 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 String::Handle(cls.Name()).ToCString(), 1920 String::Handle(cls.Name()).ToCString(),
1921 String::Handle(super_type.UserVisibleName()).ToCString()); 1921 String::Handle(super_type.UserVisibleName()).ToCString());
1922 } 1922 }
1923 1923
1924 // If cls belongs to core lib or to core lib's implementation, restrictions 1924 // If cls belongs to core lib or to core lib's implementation, restrictions
1925 // about allowed interfaces are lifted. 1925 // about allowed interfaces are lifted.
1926 if (!cls_belongs_to_core_lib) { 1926 if (!cls_belongs_to_core_lib) {
1927 // Prevent extending core implementation classes. 1927 // Prevent extending core implementation classes.
1928 bool is_error = false; 1928 bool is_error = false;
1929 switch (interface_class.id()) { 1929 switch (interface_class.id()) {
1930 case kNullCid:
1931 case kNumberCid: 1930 case kNumberCid:
1932 case kIntegerCid: // Class Integer, not int. 1931 case kIntegerCid: // Class Integer, not int.
1933 case kSmiCid: 1932 case kSmiCid:
1934 case kMintCid: 1933 case kMintCid:
1935 case kBigintCid: 1934 case kBigintCid:
1936 case kDoubleCid: // Class Double, not double. 1935 case kDoubleCid: // Class Double, not double.
1937 case kOneByteStringCid: 1936 case kOneByteStringCid:
1938 case kTwoByteStringCid: 1937 case kTwoByteStringCid:
1939 case kExternalOneByteStringCid: 1938 case kExternalOneByteStringCid:
1940 case kExternalTwoByteStringCid: 1939 case kExternalTwoByteStringCid:
1941 case kBoolCid: 1940 case kBoolCid:
1941 case kNullCid:
1942 case kArrayCid: 1942 case kArrayCid:
1943 case kImmutableArrayCid: 1943 case kImmutableArrayCid:
1944 case kGrowableObjectArrayCid: 1944 case kGrowableObjectArrayCid:
1945 #define DO_NOT_EXTEND_TYPED_DATA_CLASSES(clazz) \ 1945 #define DO_NOT_EXTEND_TYPED_DATA_CLASSES(clazz) \
1946 case kTypedData##clazz##Cid: \ 1946 case kTypedData##clazz##Cid: \
1947 case kTypedData##clazz##ViewCid: \ 1947 case kTypedData##clazz##ViewCid: \
1948 case kExternalTypedData##clazz##Cid: 1948 case kExternalTypedData##clazz##Cid:
1949 CLASS_LIST_TYPED_DATA(DO_NOT_EXTEND_TYPED_DATA_CLASSES) 1949 CLASS_LIST_TYPED_DATA(DO_NOT_EXTEND_TYPED_DATA_CLASSES)
1950 #undef DO_NOT_EXTEND_TYPED_DATA_CLASSES 1950 #undef DO_NOT_EXTEND_TYPED_DATA_CLASSES
1951 case kByteDataViewCid: 1951 case kByteDataViewCid:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 ReportError(Error::Handle(), // No previous error. 1994 ReportError(Error::Handle(), // No previous error.
1995 script, cls.token_pos(), 1995 script, cls.token_pos(),
1996 "function type alias '%s' may not be used as interface", 1996 "function type alias '%s' may not be used as interface",
1997 String::Handle(interface_class.Name()).ToCString()); 1997 String::Handle(interface_class.Name()).ToCString());
1998 } 1998 }
1999 // Verify that unless cls belongs to core lib, it cannot extend or implement 1999 // Verify that unless cls belongs to core lib, it cannot extend or implement
2000 // any of Null, bool, num, int, double, String, Function, dynamic. 2000 // any of Null, bool, num, int, double, String, Function, dynamic.
2001 // The exception is signature classes, which are compiler generated and 2001 // The exception is signature classes, which are compiler generated and
2002 // represent a function type, therefore implementing the Function interface. 2002 // represent a function type, therefore implementing the Function interface.
2003 if (!cls_belongs_to_core_lib) { 2003 if (!cls_belongs_to_core_lib) {
2004 if (interface.IsNullType() || 2004 if (interface.IsBoolType() ||
2005 interface.IsBoolType() || 2005 interface.IsNullType() ||
2006 interface.IsNumberType() || 2006 interface.IsNumberType() ||
2007 interface.IsIntType() || 2007 interface.IsIntType() ||
2008 interface.IsDoubleType() || 2008 interface.IsDoubleType() ||
2009 interface.IsStringType() || 2009 interface.IsStringType() ||
2010 interface.IsDynamicType()) { 2010 interface.IsDynamicType()) {
2011 const Script& script = Script::Handle(cls.script()); 2011 const Script& script = Script::Handle(cls.script());
2012 ReportError(Error::Handle(), // No previous error. 2012 ReportError(Error::Handle(), // No previous error.
2013 script, cls.token_pos(), 2013 script, cls.token_pos(),
2014 "'%s' is not allowed to extend or implement '%s'", 2014 "'%s' is not allowed to extend or implement '%s'",
2015 String::Handle(cls.Name()).ToCString(), 2015 String::Handle(cls.Name()).ToCString(),
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 expected_name ^= String::New("_offset"); 2245 expected_name ^= String::New("_offset");
2246 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 2246 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2247 field ^= fields_array.At(2); 2247 field ^= fields_array.At(2);
2248 ASSERT(field.Offset() == TypedDataView::length_offset()); 2248 ASSERT(field.Offset() == TypedDataView::length_offset());
2249 name ^= field.name(); 2249 name ^= field.name();
2250 ASSERT(name.Equals("length")); 2250 ASSERT(name.Equals("length"));
2251 #endif 2251 #endif
2252 } 2252 }
2253 2253
2254 } // namespace dart 2254 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698