| OLD | NEW |
| 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 Loading... |
| 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: |
| 1930 case kNumberCid: | 1931 case kNumberCid: |
| 1931 case kIntegerCid: // Class Integer, not int. | 1932 case kIntegerCid: // Class Integer, not int. |
| 1932 case kSmiCid: | 1933 case kSmiCid: |
| 1933 case kMintCid: | 1934 case kMintCid: |
| 1934 case kBigintCid: | 1935 case kBigintCid: |
| 1935 case kDoubleCid: // Class Double, not double. | 1936 case kDoubleCid: // Class Double, not double. |
| 1936 case kOneByteStringCid: | 1937 case kOneByteStringCid: |
| 1937 case kTwoByteStringCid: | 1938 case kTwoByteStringCid: |
| 1938 case kExternalOneByteStringCid: | 1939 case kExternalOneByteStringCid: |
| 1939 case kExternalTwoByteStringCid: | 1940 case kExternalTwoByteStringCid: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 } | 1990 } |
| 1990 interface_class = interface.type_class(); | 1991 interface_class = interface.type_class(); |
| 1991 if (interface_class.IsSignatureClass()) { | 1992 if (interface_class.IsSignatureClass()) { |
| 1992 const Script& script = Script::Handle(cls.script()); | 1993 const Script& script = Script::Handle(cls.script()); |
| 1993 ReportError(Error::Handle(), // No previous error. | 1994 ReportError(Error::Handle(), // No previous error. |
| 1994 script, cls.token_pos(), | 1995 script, cls.token_pos(), |
| 1995 "function type alias '%s' may not be used as interface", | 1996 "function type alias '%s' may not be used as interface", |
| 1996 String::Handle(interface_class.Name()).ToCString()); | 1997 String::Handle(interface_class.Name()).ToCString()); |
| 1997 } | 1998 } |
| 1998 // 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 |
| 1999 // any of bool, num, int, double, String, Function, dynamic. | 2000 // any of Null, bool, num, int, double, String, Function, dynamic. |
| 2000 // The exception is signature classes, which are compiler generated and | 2001 // The exception is signature classes, which are compiler generated and |
| 2001 // represent a function type, therefore implementing the Function interface. | 2002 // represent a function type, therefore implementing the Function interface. |
| 2002 if (!cls_belongs_to_core_lib) { | 2003 if (!cls_belongs_to_core_lib) { |
| 2003 if (interface.IsBoolType() || | 2004 if (interface.IsNullType() || |
| 2005 interface.IsBoolType() || |
| 2004 interface.IsNumberType() || | 2006 interface.IsNumberType() || |
| 2005 interface.IsIntType() || | 2007 interface.IsIntType() || |
| 2006 interface.IsDoubleType() || | 2008 interface.IsDoubleType() || |
| 2007 interface.IsStringType() || | 2009 interface.IsStringType() || |
| 2008 interface.IsDynamicType()) { | 2010 interface.IsDynamicType()) { |
| 2009 const Script& script = Script::Handle(cls.script()); | 2011 const Script& script = Script::Handle(cls.script()); |
| 2010 ReportError(Error::Handle(), // No previous error. | 2012 ReportError(Error::Handle(), // No previous error. |
| 2011 script, cls.token_pos(), | 2013 script, cls.token_pos(), |
| 2012 "'%s' is not allowed to extend or implement '%s'", | 2014 "'%s' is not allowed to extend or implement '%s'", |
| 2013 String::Handle(cls.Name()).ToCString(), | 2015 String::Handle(cls.Name()).ToCString(), |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2243 expected_name ^= String::New("_offset"); | 2245 expected_name ^= String::New("_offset"); |
| 2244 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 2246 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 2245 field ^= fields_array.At(2); | 2247 field ^= fields_array.At(2); |
| 2246 ASSERT(field.Offset() == TypedDataView::length_offset()); | 2248 ASSERT(field.Offset() == TypedDataView::length_offset()); |
| 2247 name ^= field.name(); | 2249 name ^= field.name(); |
| 2248 ASSERT(name.Equals("length")); | 2250 ASSERT(name.Equals("length")); |
| 2249 #endif | 2251 #endif |
| 2250 } | 2252 } |
| 2251 | 2253 |
| 2252 } // namespace dart | 2254 } // namespace dart |
| OLD | NEW |