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

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

Issue 10399080: Revert r7729 until Dartium fixes its method override errors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ReportError("Duplicate definition : %s\n", str.ToCString()); 90 ReportError("Duplicate definition : %s\n", str.ToCString());
91 } 91 }
92 } else { 92 } else {
93 retval = false; 93 retval = false;
94 } 94 }
95 isolate->set_long_jump_base(base); 95 isolate->set_long_jump_base(base);
96 return retval; 96 return retval;
97 } 97 }
98 98
99 99
100 #if defined (DEBUG)
100 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur. 101 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur.
101 // No cycles are allowed. 102 // No cycles are allowed.
102 void ClassFinalizer::CollectInterfaces(const Class& cls, 103 void ClassFinalizer::CollectInterfaces(const Class& cls,
103 const GrowableObjectArray& collected) { 104 const GrowableObjectArray& collected) {
104 const Array& interface_array = Array::ZoneHandle(cls.interfaces()); 105 const Array& interface_array = Array::ZoneHandle(cls.interfaces());
105 AbstractType& interface = AbstractType::Handle(); 106 AbstractType& interface = AbstractType::Handle();
106 Class& interface_class = Class::Handle(); 107 Class& interface_class = Class::Handle();
107 for (intptr_t i = 0; i < interface_array.Length(); i++) { 108 for (intptr_t i = 0; i < interface_array.Length(); i++) {
108 interface ^= interface_array.At(i); 109 interface ^= interface_array.At(i);
109 interface_class = interface.type_class(); 110 interface_class = interface.type_class();
110 collected.Add(interface_class); 111 collected.Add(interface_class);
111 CollectInterfaces(interface_class, collected); 112 CollectInterfaces(interface_class, collected);
112 } 113 }
113 } 114 }
114 115
115 116
116 #if defined (DEBUG)
117 // Collect all interfaces of the class 'cls' and check that every function 117 // Collect all interfaces of the class 'cls' and check that every function
118 // defined in each interface can be found in the class. 118 // defined in each interface can be found in the class.
119 // No need to check instance fields since they have been turned into 119 // No need to check instance fields since they have been turned into
120 // getters/setters. 120 // getters/setters.
121 void ClassFinalizer::VerifyClassImplements(const Class& cls) { 121 void ClassFinalizer::VerifyClassImplements(const Class& cls) {
122 ASSERT(!cls.is_interface()); 122 ASSERT(!cls.is_interface());
123 const GrowableObjectArray& interfaces = 123 const GrowableObjectArray& interfaces =
124 GrowableObjectArray::Handle(GrowableObjectArray::New()); 124 GrowableObjectArray::Handle(GrowableObjectArray::New());
125 CollectInterfaces(cls, interfaces); 125 CollectInterfaces(cls, interfaces);
126 const String& class_name = String::Handle(cls.Name()); 126 const String& class_name = String::Handle(cls.Name());
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 const Script& script = Script::Handle(cls.script()); 944 const Script& script = Script::Handle(cls.script());
945 ReportError(script, field.token_index(), 945 ReportError(script, field.token_index(),
946 "field '%s' of class '%s' conflicts with instance " 946 "field '%s' of class '%s' conflicts with instance "
947 "member '%s' of super class '%s'", 947 "member '%s' of super class '%s'",
948 name.ToCString(), 948 name.ToCString(),
949 class_name.ToCString(), 949 class_name.ToCString(),
950 name.ToCString(), 950 name.ToCString(),
951 super_class_name.ToCString()); 951 super_class_name.ToCString());
952 } 952 }
953 } 953 }
954 // Collect interfaces, super interfaces, and super classes of this class. 954 // Resolve function signatures and check for conflicts in super classes.
955 const GrowableObjectArray& interfaces =
956 GrowableObjectArray::Handle(GrowableObjectArray::New());
957 CollectInterfaces(cls, interfaces);
958 // Include superclasses in list of interfaces and super interfaces.
959 super_class = cls.SuperClass();
960 while (!super_class.IsNull()) {
961 interfaces.Add(super_class);
962 super_class = super_class.SuperClass();
963 }
964 // Resolve function signatures and check for conflicts in super classes and
965 // interfaces.
966 array = cls.functions(); 955 array = cls.functions();
967 Function& function = Function::Handle(); 956 Function& function = Function::Handle();
968 Function& overridden_function = Function::Handle(); 957 Function& overridden_function = Function::Handle();
969 intptr_t num_functions = array.Length(); 958 intptr_t num_functions = array.Length();
970 String& function_name = String::Handle(); 959 String& function_name = String::Handle();
971 for (intptr_t i = 0; i < num_functions; i++) { 960 for (intptr_t i = 0; i < num_functions; i++) {
972 function ^= array.At(i); 961 function ^= array.At(i);
973 ResolveAndFinalizeSignature(cls, function); 962 ResolveAndFinalizeSignature(cls, function);
974 function_name = function.name(); 963 function_name = function.name();
975 if (function.is_static()) { 964 if (function.is_static()) {
976 super_class = FindSuperOwnerOfInstanceMember(cls, function_name); 965 super_class = FindSuperOwnerOfInstanceMember(cls, function_name);
977 if (!super_class.IsNull()) { 966 if (!super_class.IsNull()) {
978 const String& class_name = String::Handle(cls.Name()); 967 const String& class_name = String::Handle(cls.Name());
979 const String& super_class_name = String::Handle(super_class.Name()); 968 const String& super_class_name = String::Handle(super_class.Name());
980 const Script& script = Script::Handle(cls.script()); 969 const Script& script = Script::Handle(cls.script());
981 ReportError(script, function.token_index(), 970 ReportError(script, function.token_index(),
982 "static function '%s' of class '%s' conflicts with " 971 "static function '%s' of class '%s' conflicts with "
983 "instance member '%s' of super class '%s'", 972 "instance member '%s' of super class '%s'",
984 function_name.ToCString(), 973 function_name.ToCString(),
985 class_name.ToCString(), 974 class_name.ToCString(),
986 function_name.ToCString(), 975 function_name.ToCString(),
987 super_class_name.ToCString()); 976 super_class_name.ToCString());
988 } 977 }
989 } else { 978 } else {
990 for (int i = 0; i < interfaces.Length(); i++) { 979 // TODO(regis): This arity check is still being debated. Revisit.
991 super_class ^= interfaces.At(i); 980 super_class = cls.SuperClass();
981 while (!super_class.IsNull()) {
992 overridden_function = super_class.LookupDynamicFunction(function_name); 982 overridden_function = super_class.LookupDynamicFunction(function_name);
993 if (!overridden_function.IsNull() && 983 if (!overridden_function.IsNull() &&
994 !function.HasCompatibleParametersWith(overridden_function)) { 984 !function.HasCompatibleParametersWith(overridden_function)) {
995 // Function types are purposely not checked for subtyping. 985 // Function types are purposely not checked for subtyping.
996 const String& class_name = String::Handle(cls.Name()); 986 const String& class_name = String::Handle(cls.Name());
997 const String& super_class_name = String::Handle(super_class.Name()); 987 const String& super_class_name = String::Handle(super_class.Name());
998 const Script& script = Script::Handle(cls.script()); 988 const Script& script = Script::Handle(cls.script());
999 ReportError(script, function.token_index(), 989 ReportError(script, function.token_index(),
1000 "class '%s' overrides function '%s' of %s '%s' " 990 "class '%s' overrides function '%s' of super class '%s' "
1001 "with incompatible parameters", 991 "with incompatible parameters",
1002 class_name.ToCString(), 992 class_name.ToCString(),
1003 function_name.ToCString(), 993 function_name.ToCString(),
1004 super_class.is_interface() ? "interface" : "super class",
1005 super_class_name.ToCString()); 994 super_class_name.ToCString());
1006 } 995 }
996 super_class = super_class.SuperClass();
1007 } 997 }
1008 } 998 }
1009 if (function.kind() == RawFunction::kGetterFunction) { 999 if (function.kind() == RawFunction::kGetterFunction) {
1010 name = Field::NameFromGetter(function_name); 1000 name = Field::NameFromGetter(function_name);
1011 super_class = FindSuperOwnerOfFunction(cls, name); 1001 super_class = FindSuperOwnerOfFunction(cls, name);
1012 if (!super_class.IsNull()) { 1002 if (!super_class.IsNull()) {
1013 const String& class_name = String::Handle(cls.Name()); 1003 const String& class_name = String::Handle(cls.Name());
1014 const String& super_class_name = String::Handle(super_class.Name()); 1004 const String& super_class_name = String::Handle(super_class.Name());
1015 const Script& script = Script::Handle(cls.script()); 1005 const Script& script = Script::Handle(cls.script());
1016 ReportError(script, function.token_index(), 1006 ReportError(script, function.token_index(),
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 void ClassFinalizer::ReportError(const char* format, ...) { 1483 void ClassFinalizer::ReportError(const char* format, ...) {
1494 va_list args; 1484 va_list args;
1495 va_start(args, format); 1485 va_start(args, format);
1496 const Error& error = Error::Handle( 1486 const Error& error = Error::Handle(
1497 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1487 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1498 va_end(args); 1488 va_end(args);
1499 ReportError(error); 1489 ReportError(error);
1500 } 1490 }
1501 1491
1502 } // namespace dart 1492 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698