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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 11299009: Support type literals as compile-time constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 ClassElement cls = type.element; 2475 ClassElement cls = type.element;
2476 Link<DartType> arguments = interfaceType.arguments; 2476 Link<DartType> arguments = interfaceType.arguments;
2477 js.Expression result = pop(); 2477 js.Expression result = pop();
2478 for (TypeVariableType typeVariable in cls.typeVariables) { 2478 for (TypeVariableType typeVariable in cls.typeVariables) {
2479 use(node.typeInfoCall); 2479 use(node.typeInfoCall);
2480 // TODO(johnniwinther): Retrieve the type name properly and not through 2480 // TODO(johnniwinther): Retrieve the type name properly and not through
2481 // [toString]. Note: Two cases below [typeVariable] and 2481 // [toString]. Note: Two cases below [typeVariable] and
2482 // [arguments.head]. 2482 // [arguments.head].
2483 js.PropertyAccess field = 2483 js.PropertyAccess field =
2484 new js.PropertyAccess.field(pop(), typeVariable.toString()); 2484 new js.PropertyAccess.field(pop(), typeVariable.toString());
2485 js.Expression genericName = new js.LiteralString("'${arguments.head}'"); 2485 RuntimeTypeInformation rti = compiler.enqueuer.codegen.universe.rti;
2486 String typeName = rti.buildStringRepresentation(arguments.head);
2487 js.Expression genericName = new js.LiteralString("'$typeName'");
2486 js.Binary eqTest = new js.Binary('===', field, genericName); 2488 js.Binary eqTest = new js.Binary('===', field, genericName);
2487 // Also test for 'undefined' in case the object does not have 2489 // Also test for 'undefined' in case the object does not have
2488 // any type variable. 2490 // any type variable.
2489 js.Prefix undefinedTest = new js.Prefix('!', field); 2491 js.Prefix undefinedTest = new js.Prefix('!', field);
2490 result = new js.Binary( 2492 result = new js.Binary(
2491 '&&', result, new js.Binary('||', undefinedTest, eqTest)); 2493 '&&', result, new js.Binary('||', undefinedTest, eqTest));
2492 } 2494 }
2493 push(result, node); 2495 push(result, node);
2494 } 2496 }
2495 if (node.nullOk) { 2497 if (node.nullOk) {
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 if (leftType.canBeNull() && rightType.canBeNull()) { 3107 if (leftType.canBeNull() && rightType.canBeNull()) {
3106 if (left.isConstantNull() || right.isConstantNull() || 3108 if (left.isConstantNull() || right.isConstantNull() ||
3107 (leftType.isPrimitive() && leftType == rightType)) { 3109 (leftType.isPrimitive() && leftType == rightType)) {
3108 return '=='; 3110 return '==';
3109 } 3111 }
3110 return null; 3112 return null;
3111 } else { 3113 } else {
3112 return '==='; 3114 return '===';
3113 } 3115 }
3114 } 3116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698