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

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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 "both classes or both interfaces", 328 "both classes or both interfaces",
329 class_name.ToCString(), 329 class_name.ToCString(),
330 super_class_name.ToCString()); 330 super_class_name.ToCString());
331 } 331 }
332 // If cls belongs to core lib or to core lib's implementation, restrictions 332 // If cls belongs to core lib or to core lib's implementation, restrictions
333 // about allowed interfaces are lifted. 333 // about allowed interfaces are lifted.
334 if ((cls.library() != Library::CoreLibrary()) && 334 if ((cls.library() != Library::CoreLibrary()) &&
335 (cls.library() != Library::CoreImplLibrary())) { 335 (cls.library() != Library::CoreImplLibrary())) {
336 // Prevent extending core implementation classes. 336 // Prevent extending core implementation classes.
337 switch (super_class.id()) { 337 switch (super_class.id()) {
338 case kNumberCid:
338 case kIntegerCid: 339 case kIntegerCid:
339 case kSmiCid: 340 case kSmiCid:
340 case kMintCid: 341 case kMintCid:
341 case kBigintCid: 342 case kBigintCid:
342 case kDoubleCid: 343 case kDoubleCid:
343 case kOneByteStringCid: 344 case kOneByteStringCid:
344 case kTwoByteStringCid: 345 case kTwoByteStringCid:
345 case kFourByteStringCid: 346 case kFourByteStringCid:
346 case kExternalOneByteStringCid: 347 case kExternalOneByteStringCid:
347 case kExternalTwoByteStringCid: 348 case kExternalTwoByteStringCid:
(...skipping 15 matching lines...) Expand all
363 case kUint32ArrayCid: 364 case kUint32ArrayCid:
364 case kExternalUint32ArrayCid: 365 case kExternalUint32ArrayCid:
365 case kInt64ArrayCid: 366 case kInt64ArrayCid:
366 case kExternalInt64ArrayCid: 367 case kExternalInt64ArrayCid:
367 case kUint64ArrayCid: 368 case kUint64ArrayCid:
368 case kExternalUint64ArrayCid: 369 case kExternalUint64ArrayCid:
369 case kFloat32ArrayCid: 370 case kFloat32ArrayCid:
370 case kExternalFloat32ArrayCid: 371 case kExternalFloat32ArrayCid:
371 case kFloat64ArrayCid: 372 case kFloat64ArrayCid:
372 case kExternalFloat64ArrayCid: 373 case kExternalFloat64ArrayCid:
374 case kDartFunctionCid:
373 case kWeakPropertyCid: { 375 case kWeakPropertyCid: {
374 const Script& script = Script::Handle(cls.script()); 376 const Script& script = Script::Handle(cls.script());
375 ReportError(script, cls.token_pos(), 377 ReportError(script, cls.token_pos(),
376 "'%s' is not allowed to extend '%s'", 378 "'%s' is not allowed to extend '%s'",
377 String::Handle(cls.Name()).ToCString(), 379 String::Handle(cls.Name()).ToCString(),
378 String::Handle(super_class.Name()).ToCString()); 380 String::Handle(super_class.Name()).ToCString());
379 break; 381 break;
380 } 382 }
381 default: break; 383 default: break;
382 } 384 }
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 ReportError(script, cls.token_pos(), 1339 ReportError(script, cls.token_pos(),
1338 "'%s' is used where an interface or class name is expected", 1340 "'%s' is used where an interface or class name is expected",
1339 String::Handle(interface_class.Name()).ToCString()); 1341 String::Handle(interface_class.Name()).ToCString());
1340 } 1342 }
1341 // Verify that unless cls belongs to core lib, it cannot extend or implement 1343 // Verify that unless cls belongs to core lib, it cannot extend or implement
1342 // any of bool, num, int, double, String, Function, Dynamic. 1344 // any of bool, num, int, double, String, Function, Dynamic.
1343 // The exception is signature classes, which are compiler generated and 1345 // The exception is signature classes, which are compiler generated and
1344 // represent a function type, therefore implementing the Function interface. 1346 // represent a function type, therefore implementing the Function interface.
1345 if (!cls_belongs_to_core_lib) { 1347 if (!cls_belongs_to_core_lib) {
1346 if (interface.IsBoolInterface() || 1348 if (interface.IsBoolInterface() ||
1347 interface.IsNumberInterface() || 1349 interface.IsNumberType() ||
1348 interface.IsIntInterface() || 1350 interface.IsIntInterface() ||
1349 interface.IsDoubleInterface() || 1351 interface.IsDoubleInterface() ||
1350 interface.IsStringInterface() || 1352 interface.IsStringInterface() ||
1351 (interface.IsFunctionInterface() && !cls.IsSignatureClass()) || 1353 (interface.IsFunctionType() && !cls.IsSignatureClass()) ||
1352 interface.IsDynamicType()) { 1354 interface.IsDynamicType()) {
1353 const Script& script = Script::Handle(cls.script()); 1355 const Script& script = Script::Handle(cls.script());
1354 ReportError(script, cls.token_pos(), 1356 ReportError(script, cls.token_pos(),
1355 "'%s' is not allowed to extend or implement '%s'", 1357 "'%s' is not allowed to extend or implement '%s'",
1356 String::Handle(cls.Name()).ToCString(), 1358 String::Handle(cls.Name()).ToCString(),
1357 String::Handle(interface_class.Name()).ToCString()); 1359 String::Handle(interface_class.Name()).ToCString());
1358 } 1360 }
1359 } 1361 }
1360 // Now resolve the super interfaces. 1362 // Now resolve the super interfaces.
1361 ResolveInterfaces(interface_class, visited); 1363 ResolveInterfaces(interface_class, visited);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 void ClassFinalizer::ReportError(const char* format, ...) { 1511 void ClassFinalizer::ReportError(const char* format, ...) {
1510 va_list args; 1512 va_list args;
1511 va_start(args, format); 1513 va_start(args, format);
1512 const Error& error = Error::Handle( 1514 const Error& error = Error::Handle(
1513 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1515 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1514 va_end(args); 1516 va_end(args);
1515 ReportError(error); 1517 ReportError(error);
1516 } 1518 }
1517 1519
1518 } // namespace dart 1520 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698