| 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 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 String::Handle(cls.Name()).ToCString(), | 1896 String::Handle(cls.Name()).ToCString(), |
| 1897 String::Handle(super_type.UserVisibleName()).ToCString()); | 1897 String::Handle(super_type.UserVisibleName()).ToCString()); |
| 1898 } | 1898 } |
| 1899 | 1899 |
| 1900 // If cls belongs to core lib or to core lib's implementation, restrictions | 1900 // If cls belongs to core lib or to core lib's implementation, restrictions |
| 1901 // about allowed interfaces are lifted. | 1901 // about allowed interfaces are lifted. |
| 1902 if (!cls_belongs_to_core_lib) { | 1902 if (!cls_belongs_to_core_lib) { |
| 1903 // Prevent extending core implementation classes. | 1903 // Prevent extending core implementation classes. |
| 1904 bool is_error = false; | 1904 bool is_error = false; |
| 1905 switch (interface_class.id()) { | 1905 switch (interface_class.id()) { |
| 1906 case kNullCid: |
| 1906 case kNumberCid: | 1907 case kNumberCid: |
| 1907 case kIntegerCid: // Class Integer, not int. | 1908 case kIntegerCid: // Class Integer, not int. |
| 1908 case kSmiCid: | 1909 case kSmiCid: |
| 1909 case kMintCid: | 1910 case kMintCid: |
| 1910 case kBigintCid: | 1911 case kBigintCid: |
| 1911 case kDoubleCid: // Class Double, not double. | 1912 case kDoubleCid: // Class Double, not double. |
| 1912 case kOneByteStringCid: | 1913 case kOneByteStringCid: |
| 1913 case kTwoByteStringCid: | 1914 case kTwoByteStringCid: |
| 1914 case kExternalOneByteStringCid: | 1915 case kExternalOneByteStringCid: |
| 1915 case kExternalTwoByteStringCid: | 1916 case kExternalTwoByteStringCid: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 } | 1966 } |
| 1966 interface_class = interface.type_class(); | 1967 interface_class = interface.type_class(); |
| 1967 if (interface_class.IsSignatureClass()) { | 1968 if (interface_class.IsSignatureClass()) { |
| 1968 const Script& script = Script::Handle(cls.script()); | 1969 const Script& script = Script::Handle(cls.script()); |
| 1969 ReportError(Error::Handle(), // No previous error. | 1970 ReportError(Error::Handle(), // No previous error. |
| 1970 script, cls.token_pos(), | 1971 script, cls.token_pos(), |
| 1971 "function type alias '%s' may not be used as interface", | 1972 "function type alias '%s' may not be used as interface", |
| 1972 String::Handle(interface_class.Name()).ToCString()); | 1973 String::Handle(interface_class.Name()).ToCString()); |
| 1973 } | 1974 } |
| 1974 // Verify that unless cls belongs to core lib, it cannot extend or implement | 1975 // Verify that unless cls belongs to core lib, it cannot extend or implement |
| 1975 // any of bool, num, int, double, String, Function, dynamic. | 1976 // any of Null, bool, num, int, double, String, Function, dynamic. |
| 1976 // The exception is signature classes, which are compiler generated and | 1977 // The exception is signature classes, which are compiler generated and |
| 1977 // represent a function type, therefore implementing the Function interface. | 1978 // represent a function type, therefore implementing the Function interface. |
| 1978 if (!cls_belongs_to_core_lib) { | 1979 if (!cls_belongs_to_core_lib) { |
| 1979 if (interface.IsBoolType() || | 1980 if (interface.IsNullType() || |
| 1981 interface.IsBoolType() || |
| 1980 interface.IsNumberType() || | 1982 interface.IsNumberType() || |
| 1981 interface.IsIntType() || | 1983 interface.IsIntType() || |
| 1982 interface.IsDoubleType() || | 1984 interface.IsDoubleType() || |
| 1983 interface.IsStringType() || | 1985 interface.IsStringType() || |
| 1984 interface.IsDynamicType()) { | 1986 interface.IsDynamicType()) { |
| 1985 const Script& script = Script::Handle(cls.script()); | 1987 const Script& script = Script::Handle(cls.script()); |
| 1986 ReportError(Error::Handle(), // No previous error. | 1988 ReportError(Error::Handle(), // No previous error. |
| 1987 script, cls.token_pos(), | 1989 script, cls.token_pos(), |
| 1988 "'%s' is not allowed to extend or implement '%s'", | 1990 "'%s' is not allowed to extend or implement '%s'", |
| 1989 String::Handle(cls.Name()).ToCString(), | 1991 String::Handle(cls.Name()).ToCString(), |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 expected_name ^= String::New("_offset"); | 2221 expected_name ^= String::New("_offset"); |
| 2220 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 2222 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 2221 field ^= fields_array.At(2); | 2223 field ^= fields_array.At(2); |
| 2222 ASSERT(field.Offset() == TypedDataView::length_offset()); | 2224 ASSERT(field.Offset() == TypedDataView::length_offset()); |
| 2223 name ^= field.name(); | 2225 name ^= field.name(); |
| 2224 ASSERT(name.Equals("length")); | 2226 ASSERT(name.Equals("length")); |
| 2225 #endif | 2227 #endif |
| 2226 } | 2228 } |
| 2227 | 2229 |
| 2228 } // namespace dart | 2230 } // namespace dart |
| OLD | NEW |