| 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 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 } | 1802 } |
| 1803 interface_class.set_is_implemented(); | 1803 interface_class.set_is_implemented(); |
| 1804 // Now resolve the super interfaces. | 1804 // Now resolve the super interfaces. |
| 1805 ResolveSuperTypeAndInterfaces(interface_class, visited); | 1805 ResolveSuperTypeAndInterfaces(interface_class, visited); |
| 1806 } | 1806 } |
| 1807 visited->RemoveLast(); | 1807 visited->RemoveLast(); |
| 1808 } | 1808 } |
| 1809 | 1809 |
| 1810 | 1810 |
| 1811 // A class is marked as constant if it has one constant constructor. | 1811 // A class is marked as constant if it has one constant constructor. |
| 1812 // A constant class: | 1812 // A constant class can only have final instance fields. |
| 1813 // - may extend only const classes. | |
| 1814 // - has only const instance fields. | |
| 1815 // Note: we must check for cycles before checking for const properties. | 1813 // Note: we must check for cycles before checking for const properties. |
| 1816 void ClassFinalizer::CheckForLegalConstClass(const Class& cls) { | 1814 void ClassFinalizer::CheckForLegalConstClass(const Class& cls) { |
| 1817 ASSERT(cls.is_const()); | 1815 ASSERT(cls.is_const()); |
| 1818 const Class& super = Class::Handle(cls.SuperClass()); | |
| 1819 if (!super.IsNull() && !super.is_const()) { | |
| 1820 String& name = String::Handle(super.Name()); | |
| 1821 const Script& script = Script::Handle(cls.script()); | |
| 1822 ReportError(script, cls.token_pos(), | |
| 1823 "superclass '%s' must be const", name.ToCString()); | |
| 1824 } | |
| 1825 const Array& fields_array = Array::Handle(cls.fields()); | 1816 const Array& fields_array = Array::Handle(cls.fields()); |
| 1826 intptr_t len = fields_array.Length(); | 1817 intptr_t len = fields_array.Length(); |
| 1827 Field& field = Field::Handle(); | 1818 Field& field = Field::Handle(); |
| 1828 for (intptr_t i = 0; i < len; i++) { | 1819 for (intptr_t i = 0; i < len; i++) { |
| 1829 field ^= fields_array.At(i); | 1820 field ^= fields_array.At(i); |
| 1830 if (!field.is_static() && !field.is_final()) { | 1821 if (!field.is_static() && !field.is_final()) { |
| 1831 const String& class_name = String::Handle(cls.Name()); | 1822 const String& class_name = String::Handle(cls.Name()); |
| 1832 const String& field_name = String::Handle(field.name()); | 1823 const String& field_name = String::Handle(field.name()); |
| 1833 const Script& script = Script::Handle(cls.script()); | 1824 const Script& script = Script::Handle(cls.script()); |
| 1834 ReportError(script, field.token_pos(), | 1825 ReportError(script, field.token_pos(), |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2045 expected_name ^= String::New("_offset"); | 2036 expected_name ^= String::New("_offset"); |
| 2046 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 2037 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 2047 field ^= fields_array.At(2); | 2038 field ^= fields_array.At(2); |
| 2048 ASSERT(field.Offset() == TypedDataView::length_offset()); | 2039 ASSERT(field.Offset() == TypedDataView::length_offset()); |
| 2049 name ^= field.name(); | 2040 name ^= field.name(); |
| 2050 ASSERT(name.Equals("length")); | 2041 ASSERT(name.Equals("length")); |
| 2051 #endif | 2042 #endif |
| 2052 } | 2043 } |
| 2053 | 2044 |
| 2054 } // namespace dart | 2045 } // namespace dart |
| OLD | NEW |