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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 12210138: Add substitution for classes that use type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 10 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 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 if (a.isClosure()) return true; 1267 if (a.isClosure()) return true;
1268 return a.typeVariables == b.typeVariables; 1268 return a.typeVariables == b.typeVariables;
1269 } 1269 }
1270 1270
1271 if (superclass != null && superclass != compiler.objectClass && 1271 if (superclass != null && superclass != compiler.objectClass &&
1272 !haveSameTypeVariables(cls, superclass)) { 1272 !haveSameTypeVariables(cls, superclass)) {
1273 // We cannot inherit the generated substitutions, because the type 1273 // We cannot inherit the generated substitutions, because the type
1274 // variable layout for this class is different. Instead we generate 1274 // variable layout for this class is different. Instead we generate
1275 // substitutions for all checks and make emitSubstitution a NOP for the 1275 // substitutions for all checks and make emitSubstitution a NOP for the
1276 // rest of this function. 1276 // rest of this function.
1277 for (ClassElement check in checkedClasses) { 1277 Set<ClassElement> emitted = new Set<ClassElement>();
1278 for (DartType supertype in cls.allSupertypes) { 1278 // TODO(karlklose): move the computation of these checks to
1279 if (supertype.element == check) { 1279 // RuntimeTypeInformation.
1280 if (compiler.world.needsRti(cls)) {
1281 emitSubstitution(superclass, emitNull: true);
1282 emitted.add(superclass);
1283 }
1284 for (DartType supertype in cls.allSupertypes) {
1285 for (ClassElement check in checkedClasses) {
ngeoffray 2013/02/12 21:56:15 Any reason why you changed the order of the loops
1286 if (supertype.element == check && !emitted.contains(check)) {
1280 // Generate substitution. If no substitution is necessary, emit 1287 // Generate substitution. If no substitution is necessary, emit
1281 // [:null:] to overwrite a (possibly) existing substitution from the 1288 // [:null:] to overwrite a (possibly) existing substitution from the
1282 // super classes. 1289 // super classes.
1283 emitSubstitution(check, emitNull: true); 1290 emitSubstitution(check, emitNull: true);
1291 emitted.add(check);
1284 } 1292 }
1285 } 1293 }
1286 } 1294 }
1287 void emitNothing(_, {emitNull}) {}; 1295 void emitNothing(_, {emitNull}) {};
1288 emitSubstitution = emitNothing; 1296 emitSubstitution = emitNothing;
1289 } 1297 }
1290 1298
1291 Set<Element> generated = new Set<Element>(); 1299 Set<Element> generated = new Set<Element>();
1292 // A class that defines a [:call:] method implicitly implements 1300 // A class that defines a [:call:] method implicitly implements
1293 // [Function] and needs checks for all typedefs that are used in is-checks. 1301 // [Function] and needs checks for all typedefs that are used in is-checks.
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 """; 2424 """;
2417 const String HOOKS_API_USAGE = """ 2425 const String HOOKS_API_USAGE = """
2418 // The code supports the following hooks: 2426 // The code supports the following hooks:
2419 // dartPrint(message) - if this function is defined it is called 2427 // dartPrint(message) - if this function is defined it is called
2420 // instead of the Dart [print] method. 2428 // instead of the Dart [print] method.
2421 // dartMainRunner(main) - if this function is defined, the Dart [main] 2429 // dartMainRunner(main) - if this function is defined, the Dart [main]
2422 // method will not be invoked directly. 2430 // method will not be invoked directly.
2423 // Instead, a closure that will invoke [main] is 2431 // Instead, a closure that will invoke [main] is
2424 // passed to [dartMainRunner]. 2432 // passed to [dartMainRunner].
2425 """; 2433 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698