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

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

Issue 10832401: Gentle start with removing explicit interfaces (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 "typedef '%s' illegally refers to itself", 1121 "typedef '%s' illegally refers to itself",
1122 name.ToCString()); 1122 name.ToCString());
1123 } 1123 }
1124 cls.Finalize(); 1124 cls.Finalize();
1125 // Signature classes extend Object. No need to add this class to the direct 1125 // Signature classes extend Object. No need to add this class to the direct
1126 // subclasses of Object. 1126 // subclasses of Object.
1127 ASSERT(super_type.IsNull() || super_type.IsObjectType()); 1127 ASSERT(super_type.IsNull() || super_type.IsObjectType());
1128 return; 1128 return;
1129 } 1129 }
1130 // Finalize factory class, if any. 1130 // Finalize factory class, if any.
1131 if (cls.is_interface()) { 1131 if (cls.is_interface()) {
siva 2012/08/21 21:22:06 Are we going to remove the notion of interface fro
hausner 2012/08/23 00:25:06 Yes, this will go away, I would expect.
1132 if (cls.HasFactoryClass()) { 1132 if (cls.HasFactoryClass()) {
1133 const Class& factory_class = Class::Handle(cls.FactoryClass()); 1133 const Class& factory_class = Class::Handle(cls.FactoryClass());
1134 if (!factory_class.is_finalized()) { 1134 if (!factory_class.is_finalized()) {
1135 FinalizeClass(factory_class, generating_snapshot); 1135 FinalizeClass(factory_class, generating_snapshot);
1136 // Finalizing the factory class may indirectly finalize this interface. 1136 // Finalizing the factory class may indirectly finalize this interface.
1137 if (cls.is_finalized()) { 1137 if (cls.is_finalized()) {
1138 return; 1138 return;
1139 } 1139 }
1140 } 1140 }
1141 } 1141 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 ReportError(script, cls.token_pos(), 1337 ReportError(script, cls.token_pos(),
1338 "'%s' is used where an interface or class name is expected", 1338 "'%s' is used where an interface or class name is expected",
1339 String::Handle(interface_class.Name()).ToCString()); 1339 String::Handle(interface_class.Name()).ToCString());
1340 } 1340 }
1341 // Verify that unless cls belongs to core lib, it cannot extend or implement 1341 // Verify that unless cls belongs to core lib, it cannot extend or implement
1342 // any of bool, num, int, double, String, Function, Dynamic. 1342 // any of bool, num, int, double, String, Function, Dynamic.
1343 // The exception is signature classes, which are compiler generated and 1343 // The exception is signature classes, which are compiler generated and
1344 // represent a function type, therefore implementing the Function interface. 1344 // represent a function type, therefore implementing the Function interface.
1345 if (!cls_belongs_to_core_lib) { 1345 if (!cls_belongs_to_core_lib) {
1346 if (interface.IsBoolInterface() || 1346 if (interface.IsBoolInterface() ||
1347 interface.IsNumberInterface() || 1347 interface.IsNumber() ||
regis 2012/08/21 19:13:22 Besides type testers, we also have class testers a
hausner 2012/08/23 00:25:06 Agree. Changing to IsFunctionType() and IsNumberTy
1348 interface.IsIntInterface() || 1348 interface.IsIntInterface() ||
1349 interface.IsDoubleInterface() || 1349 interface.IsDoubleInterface() ||
1350 interface.IsStringInterface() || 1350 interface.IsStringInterface() ||
1351 (interface.IsFunctionInterface() && !cls.IsSignatureClass()) || 1351 (interface.IsFunction() && !cls.IsSignatureClass()) ||
1352 interface.IsDynamicType()) { 1352 interface.IsDynamicType()) {
1353 const Script& script = Script::Handle(cls.script()); 1353 const Script& script = Script::Handle(cls.script());
1354 ReportError(script, cls.token_pos(), 1354 ReportError(script, cls.token_pos(),
1355 "'%s' is not allowed to extend or implement '%s'", 1355 "'%s' is not allowed to extend or implement '%s'",
1356 String::Handle(cls.Name()).ToCString(), 1356 String::Handle(cls.Name()).ToCString(),
1357 String::Handle(interface_class.Name()).ToCString()); 1357 String::Handle(interface_class.Name()).ToCString());
1358 } 1358 }
1359 } 1359 }
1360 // Now resolve the super interfaces. 1360 // Now resolve the super interfaces.
1361 ResolveInterfaces(interface_class, visited); 1361 ResolveInterfaces(interface_class, visited);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 void ClassFinalizer::ReportError(const char* format, ...) { 1509 void ClassFinalizer::ReportError(const char* format, ...) {
1510 va_list args; 1510 va_list args;
1511 va_start(args, format); 1511 va_start(args, format);
1512 const Error& error = Error::Handle( 1512 const Error& error = Error::Handle(
1513 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1513 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1514 va_end(args); 1514 va_end(args);
1515 ReportError(error); 1515 ReportError(error);
1516 } 1516 }
1517 1517
1518 } // namespace dart 1518 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698