| 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 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 GrowableArray<intptr_t> visited_aliases; | 1533 GrowableArray<intptr_t> visited_aliases; |
| 1534 if (!IsAliasCycleFree(cls, &visited_aliases)) { | 1534 if (!IsAliasCycleFree(cls, &visited_aliases)) { |
| 1535 const String& name = String::Handle(cls.Name()); | 1535 const String& name = String::Handle(cls.Name()); |
| 1536 const Script& script = Script::Handle(cls.script()); | 1536 const Script& script = Script::Handle(cls.script()); |
| 1537 ReportError(Error::Handle(), // No previous error. | 1537 ReportError(Error::Handle(), // No previous error. |
| 1538 script, cls.token_pos(), | 1538 script, cls.token_pos(), |
| 1539 "typedef '%s' illegally refers to itself", | 1539 "typedef '%s' illegally refers to itself", |
| 1540 name.ToCString()); | 1540 name.ToCString()); |
| 1541 } | 1541 } |
| 1542 cls.set_is_type_finalized(); | 1542 cls.set_is_type_finalized(); |
| 1543 // Signature classes extend Object. No need to add this class to the direct | |
| 1544 // subclasses of Object. | |
| 1545 ASSERT(super_type.IsNull() || super_type.IsObjectType()); | |
| 1546 | 1543 |
| 1547 // The type parameters of signature classes may have bounds. | 1544 // The type parameters of signature classes may have bounds. |
| 1548 FinalizeUpperBounds(cls); | 1545 FinalizeUpperBounds(cls); |
| 1549 | 1546 |
| 1550 // Resolve and finalize the result and parameter types of the signature | 1547 // Resolve and finalize the result and parameter types of the signature |
| 1551 // function of this signature class. | 1548 // function of this signature class. |
| 1552 const Function& sig_function = Function::Handle(cls.signature_function()); | 1549 const Function& sig_function = Function::Handle(cls.signature_function()); |
| 1553 ResolveAndFinalizeSignature(cls, sig_function); | 1550 ResolveAndFinalizeSignature(cls, sig_function); |
| 1554 | 1551 |
| 1555 // Resolve and finalize the signature type of this signature class. | 1552 // Resolve and finalize the signature type of this signature class. |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 CLASS_LIST_TYPED_DATA(DO_NOT_EXTEND_TYPED_DATA_CLASSES) | 1924 CLASS_LIST_TYPED_DATA(DO_NOT_EXTEND_TYPED_DATA_CLASSES) |
| 1928 #undef DO_NOT_EXTEND_TYPED_DATA_CLASSES | 1925 #undef DO_NOT_EXTEND_TYPED_DATA_CLASSES |
| 1929 case kByteDataViewCid: | 1926 case kByteDataViewCid: |
| 1930 case kWeakPropertyCid: | 1927 case kWeakPropertyCid: |
| 1931 is_error = true; | 1928 is_error = true; |
| 1932 break; | 1929 break; |
| 1933 default: { | 1930 default: { |
| 1934 // Special case: classes for which we don't have a known class id. | 1931 // Special case: classes for which we don't have a known class id. |
| 1935 if (super_type.IsDoubleType() || | 1932 if (super_type.IsDoubleType() || |
| 1936 super_type.IsIntType() || | 1933 super_type.IsIntType() || |
| 1937 super_type.IsStringType() || | 1934 super_type.IsStringType()) { |
| 1938 super_type.IsFunctionType()) { | |
| 1939 is_error = true; | 1935 is_error = true; |
| 1940 } | 1936 } |
| 1941 break; | 1937 break; |
| 1942 } | 1938 } |
| 1943 } | 1939 } |
| 1944 if (is_error) { | 1940 if (is_error) { |
| 1945 const Script& script = Script::Handle(cls.script()); | 1941 const Script& script = Script::Handle(cls.script()); |
| 1946 ReportError(Error::Handle(), // No previous error. | 1942 ReportError(Error::Handle(), // No previous error. |
| 1947 script, cls.token_pos(), | 1943 script, cls.token_pos(), |
| 1948 "'%s' is not allowed to extend '%s'", | 1944 "'%s' is not allowed to extend '%s'", |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1978 // Verify that unless cls belongs to core lib, it cannot extend or implement | 1974 // Verify that unless cls belongs to core lib, it cannot extend or implement |
| 1979 // any of bool, num, int, double, String, Function, dynamic. | 1975 // any of bool, num, int, double, String, Function, dynamic. |
| 1980 // The exception is signature classes, which are compiler generated and | 1976 // The exception is signature classes, which are compiler generated and |
| 1981 // represent a function type, therefore implementing the Function interface. | 1977 // represent a function type, therefore implementing the Function interface. |
| 1982 if (!cls_belongs_to_core_lib) { | 1978 if (!cls_belongs_to_core_lib) { |
| 1983 if (interface.IsBoolType() || | 1979 if (interface.IsBoolType() || |
| 1984 interface.IsNumberType() || | 1980 interface.IsNumberType() || |
| 1985 interface.IsIntType() || | 1981 interface.IsIntType() || |
| 1986 interface.IsDoubleType() || | 1982 interface.IsDoubleType() || |
| 1987 interface.IsStringType() || | 1983 interface.IsStringType() || |
| 1988 (interface.IsFunctionType() && !cls.IsSignatureClass()) || | |
| 1989 interface.IsDynamicType()) { | 1984 interface.IsDynamicType()) { |
| 1990 const Script& script = Script::Handle(cls.script()); | 1985 const Script& script = Script::Handle(cls.script()); |
| 1991 ReportError(Error::Handle(), // No previous error. | 1986 ReportError(Error::Handle(), // No previous error. |
| 1992 script, cls.token_pos(), | 1987 script, cls.token_pos(), |
| 1993 "'%s' is not allowed to extend or implement '%s'", | 1988 "'%s' is not allowed to extend or implement '%s'", |
| 1994 String::Handle(cls.Name()).ToCString(), | 1989 String::Handle(cls.Name()).ToCString(), |
| 1995 String::Handle(interface_class.Name()).ToCString()); | 1990 String::Handle(interface_class.Name()).ToCString()); |
| 1996 } | 1991 } |
| 1997 } | 1992 } |
| 1998 interface_class.set_is_implemented(); | 1993 interface_class.set_is_implemented(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 expected_name ^= String::New("_offset"); | 2219 expected_name ^= String::New("_offset"); |
| 2225 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 2220 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 2226 field ^= fields_array.At(2); | 2221 field ^= fields_array.At(2); |
| 2227 ASSERT(field.Offset() == TypedDataView::length_offset()); | 2222 ASSERT(field.Offset() == TypedDataView::length_offset()); |
| 2228 name ^= field.name(); | 2223 name ^= field.name(); |
| 2229 ASSERT(name.Equals("length")); | 2224 ASSERT(name.Equals("length")); |
| 2230 #endif | 2225 #endif |
| 2231 } | 2226 } |
| 2232 | 2227 |
| 2233 } // namespace dart | 2228 } // namespace dart |
| OLD | NEW |