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

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

Issue 10876100: Convert double interface into abstract class (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « lib/core/double.dart ('k') | runtime/vm/dart_api_message.cc » ('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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 "class '%s' and superclass '%s' are not " 250 "class '%s' and superclass '%s' are not "
251 "both classes or both interfaces", 251 "both classes or both interfaces",
252 class_name.ToCString(), 252 class_name.ToCString(),
253 super_class_name.ToCString()); 253 super_class_name.ToCString());
254 } 254 }
255 // If cls belongs to core lib or to core lib's implementation, restrictions 255 // If cls belongs to core lib or to core lib's implementation, restrictions
256 // about allowed interfaces are lifted. 256 // about allowed interfaces are lifted.
257 if ((cls.library() != Library::CoreLibrary()) && 257 if ((cls.library() != Library::CoreLibrary()) &&
258 (cls.library() != Library::CoreImplLibrary())) { 258 (cls.library() != Library::CoreImplLibrary())) {
259 // Prevent extending core implementation classes. 259 // Prevent extending core implementation classes.
260 bool is_error = false;
260 switch (super_class.id()) { 261 switch (super_class.id()) {
261 case kNumberCid: 262 case kNumberCid:
262 case kIntegerCid: 263 case kIntegerCid:
263 case kSmiCid: 264 case kSmiCid:
264 case kMintCid: 265 case kMintCid:
265 case kBigintCid: 266 case kBigintCid:
266 case kDoubleCid: 267 case kDoubleCid:
267 case kOneByteStringCid: 268 case kOneByteStringCid:
268 case kTwoByteStringCid: 269 case kTwoByteStringCid:
269 case kFourByteStringCid: 270 case kFourByteStringCid:
(...skipping 18 matching lines...) Expand all
288 case kExternalUint32ArrayCid: 289 case kExternalUint32ArrayCid:
289 case kInt64ArrayCid: 290 case kInt64ArrayCid:
290 case kExternalInt64ArrayCid: 291 case kExternalInt64ArrayCid:
291 case kUint64ArrayCid: 292 case kUint64ArrayCid:
292 case kExternalUint64ArrayCid: 293 case kExternalUint64ArrayCid:
293 case kFloat32ArrayCid: 294 case kFloat32ArrayCid:
294 case kExternalFloat32ArrayCid: 295 case kExternalFloat32ArrayCid:
295 case kFloat64ArrayCid: 296 case kFloat64ArrayCid:
296 case kExternalFloat64ArrayCid: 297 case kExternalFloat64ArrayCid:
297 case kDartFunctionCid: 298 case kDartFunctionCid:
298 case kWeakPropertyCid: { 299 case kWeakPropertyCid:
299 const Script& script = Script::Handle(cls.script()); 300 is_error = true;
300 ReportError(script, cls.token_pos(),
301 "'%s' is not allowed to extend '%s'",
302 String::Handle(cls.Name()).ToCString(),
303 String::Handle(super_class.Name()).ToCString());
304 break; 301 break;
305 } 302 default:
306 default: break; 303 // Special case: classes for which we don't have a known class id.
304 if (Type::Handle(Type::Double()).type_class() == super_class.raw()) {
305 is_error = true;
306 }
307 break;
308 }
309 if (is_error) {
310 const Script& script = Script::Handle(cls.script());
311 ReportError(script, cls.token_pos(),
312 "'%s' is not allowed to extend '%s'",
313 String::Handle(cls.Name()).ToCString(),
314 String::Handle(super_class.Name()).ToCString());
307 } 315 }
308 } 316 }
309 return; 317 return;
310 } 318 }
311 319
312 320
313 void ClassFinalizer::ResolveFactoryClass(const Class& interface) { 321 void ClassFinalizer::ResolveFactoryClass(const Class& interface) {
314 ASSERT(interface.is_interface()); 322 ASSERT(interface.is_interface());
315 if (interface.is_finalized() || 323 if (interface.is_finalized() ||
316 !interface.HasFactoryClass() || 324 !interface.HasFactoryClass() ||
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 String::Handle(interface_class.Name()).ToCString()); 1232 String::Handle(interface_class.Name()).ToCString());
1225 } 1233 }
1226 // Verify that unless cls belongs to core lib, it cannot extend or implement 1234 // Verify that unless cls belongs to core lib, it cannot extend or implement
1227 // any of bool, num, int, double, String, Function, Dynamic. 1235 // any of bool, num, int, double, String, Function, Dynamic.
1228 // The exception is signature classes, which are compiler generated and 1236 // The exception is signature classes, which are compiler generated and
1229 // represent a function type, therefore implementing the Function interface. 1237 // represent a function type, therefore implementing the Function interface.
1230 if (!cls_belongs_to_core_lib) { 1238 if (!cls_belongs_to_core_lib) {
1231 if (interface.IsBoolType() || 1239 if (interface.IsBoolType() ||
1232 interface.IsNumberType() || 1240 interface.IsNumberType() ||
1233 interface.IsIntInterface() || 1241 interface.IsIntInterface() ||
1234 interface.IsDoubleInterface() || 1242 interface.IsDoubleType() ||
1235 interface.IsStringInterface() || 1243 interface.IsStringInterface() ||
1236 (interface.IsFunctionType() && !cls.IsSignatureClass()) || 1244 (interface.IsFunctionType() && !cls.IsSignatureClass()) ||
1237 interface.IsDynamicType()) { 1245 interface.IsDynamicType()) {
1238 const Script& script = Script::Handle(cls.script()); 1246 const Script& script = Script::Handle(cls.script());
1239 ReportError(script, cls.token_pos(), 1247 ReportError(script, cls.token_pos(),
1240 "'%s' is not allowed to extend or implement '%s'", 1248 "'%s' is not allowed to extend or implement '%s'",
1241 String::Handle(cls.Name()).ToCString(), 1249 String::Handle(cls.Name()).ToCString(),
1242 String::Handle(interface_class.Name()).ToCString()); 1250 String::Handle(interface_class.Name()).ToCString());
1243 } 1251 }
1244 } 1252 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 void ClassFinalizer::ReportError(const char* format, ...) { 1404 void ClassFinalizer::ReportError(const char* format, ...) {
1397 va_list args; 1405 va_list args;
1398 va_start(args, format); 1406 va_start(args, format);
1399 const Error& error = Error::Handle( 1407 const Error& error = Error::Handle(
1400 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1408 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1401 va_end(args); 1409 va_end(args);
1402 ReportError(error); 1410 ReportError(error);
1403 } 1411 }
1404 1412
1405 } // namespace dart 1413 } // namespace dart
OLDNEW
« no previous file with comments | « lib/core/double.dart ('k') | runtime/vm/dart_api_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698