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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart

Issue 177963002: Use List instead of Link in the type system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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) 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 class ClassEmitter extends CodeEmitterHelper { 7 class ClassEmitter extends CodeEmitterHelper {
8 /** 8 /**
9 * Documentation wanted -- johnniwinther 9 * Documentation wanted -- johnniwinther
10 * 10 *
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 void emitClassBuilderWithReflectionData(String className, 294 void emitClassBuilderWithReflectionData(String className,
295 ClassElement classElement, 295 ClassElement classElement,
296 ClassBuilder classBuilder, 296 ClassBuilder classBuilder,
297 ClassBuilder enclosingBuilder) { 297 ClassBuilder enclosingBuilder) {
298 var metadata = task.metadataEmitter.buildMetadataFunction(classElement); 298 var metadata = task.metadataEmitter.buildMetadataFunction(classElement);
299 if (metadata != null) { 299 if (metadata != null) {
300 classBuilder.addProperty("@", metadata); 300 classBuilder.addProperty("@", metadata);
301 } 301 }
302 302
303 if (backend.isNeededForReflection(classElement)) { 303 if (backend.isNeededForReflection(classElement)) {
304 Link typeVars = classElement.typeVariables; 304 bool sameList(List a, List b) {
Johnni Winther 2014/02/26 14:01:54 Put this in util.dart and reuse in dart_types.dart
karlklose 2014/02/27 09:31:41 Done.
305 if (a.length != b.length) return false;
306 for (int index = 0; index < a.length; index++) {
307 if (a[index] != b[index]) {
308 return false;
309 }
310 }
311 return true;
312 }
313
314 List<DartType> typeVars = classElement.typeVariables;
305 Iterable typeVariableProperties = task.typeVariableHandler 315 Iterable typeVariableProperties = task.typeVariableHandler
306 .typeVariablesOf(classElement).map(js.toExpression); 316 .typeVariablesOf(classElement).map(js.toExpression);
307 317
308 ClassElement superclass = classElement.superclass; 318 ClassElement superclass = classElement.superclass;
309 bool hasSuper = superclass != null; 319 bool hasSuper = superclass != null;
310 if ((!typeVariableProperties.isEmpty && !hasSuper) || 320 if ((!typeVariableProperties.isEmpty && !hasSuper) ||
311 (hasSuper && superclass.typeVariables != typeVars)) { 321 (hasSuper && !sameList(superclass.typeVariables, typeVars))) {
312 classBuilder.addProperty('<>', 322 classBuilder.addProperty('<>',
313 new jsAst.ArrayInitializer.from(typeVariableProperties)); 323 new jsAst.ArrayInitializer.from(typeVariableProperties));
314 } 324 }
315 } 325 }
316 326
317 List<jsAst.Property> statics = new List<jsAst.Property>(); 327 List<jsAst.Property> statics = new List<jsAst.Property>();
318 ClassBuilder staticsBuilder = new ClassBuilder(namer); 328 ClassBuilder staticsBuilder = new ClassBuilder(namer);
319 if (emitFields(classElement, staticsBuilder, null, emitStatics: true)) { 329 if (emitFields(classElement, staticsBuilder, null, emitStatics: true)) {
320 statics.add(staticsBuilder.toObjectInitializer().properties.single); 330 statics.add(staticsBuilder.toObjectInitializer().properties.single);
321 } 331 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 computeTypeVariable = 605 computeTypeVariable =
596 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); 606 js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index);
597 } 607 }
598 jsAst.Expression convertRtiToRuntimeType = 608 jsAst.Expression convertRtiToRuntimeType =
599 namer.elementAccess(compiler.findHelper('convertRtiToRuntimeType')); 609 namer.elementAccess(compiler.findHelper('convertRtiToRuntimeType'));
600 builder.addProperty( 610 builder.addProperty(
601 name, js.fun( 611 name, js.fun(
602 [], [js.return_(convertRtiToRuntimeType(computeTypeVariable))])); 612 [], [js.return_(convertRtiToRuntimeType(computeTypeVariable))]));
603 } 613 }
604 } 614 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698