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

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: Address comments. 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 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 ClassElement cls = type.element; 2478 ClassElement cls = type.element;
2479 Link<DartType> arguments = interfaceType.arguments; 2479 Link<DartType> arguments = interfaceType.arguments;
2480 js.Expression result = pop(); 2480 js.Expression result = pop();
2481 for (TypeVariableType typeVariable in cls.typeVariables) { 2481 for (TypeVariableType typeVariable in cls.typeVariables) {
2482 use(node.typeInfoCall); 2482 use(node.typeInfoCall);
2483 // TODO(johnniwinther): Retrieve the type name properly and not through 2483 // TODO(johnniwinther): Retrieve the type name properly and not through
2484 // [toString]. Note: Two cases below [typeVariable] and 2484 // [toString]. Note: Two cases below [typeVariable] and
2485 // [arguments.head]. 2485 // [arguments.head].
2486 js.PropertyAccess field = 2486 js.PropertyAccess field =
2487 new js.PropertyAccess.field(pop(), typeVariable.toString()); 2487 new js.PropertyAccess.field(pop(), typeVariable.toString());
2488 js.Expression genericName = new js.LiteralString("'${arguments.head}'"); 2488 RuntimeTypeInformation rti = backend.rti;
2489 String typeName = rti.buildStringRepresentation(arguments.head);
2490 js.Expression genericName = new js.LiteralString("'$typeName'");
2489 js.Binary eqTest = new js.Binary('===', field, genericName); 2491 js.Binary eqTest = new js.Binary('===', field, genericName);
2490 // Also test for 'undefined' in case the object does not have 2492 // Also test for 'undefined' in case the object does not have
2491 // any type variable. 2493 // any type variable.
2492 js.Prefix undefinedTest = new js.Prefix('!', field); 2494 js.Prefix undefinedTest = new js.Prefix('!', field);
2493 result = new js.Binary( 2495 result = new js.Binary(
2494 '&&', result, new js.Binary('||', undefinedTest, eqTest)); 2496 '&&', result, new js.Binary('||', undefinedTest, eqTest));
2495 } 2497 }
2496 push(result, node); 2498 push(result, node);
2497 } 2499 }
2498 if (node.nullOk) { 2500 if (node.nullOk) {
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 if (leftType.canBeNull() && rightType.canBeNull()) { 3110 if (leftType.canBeNull() && rightType.canBeNull()) {
3109 if (left.isConstantNull() || right.isConstantNull() || 3111 if (left.isConstantNull() || right.isConstantNull() ||
3110 (leftType.isPrimitive() && leftType == rightType)) { 3112 (leftType.isPrimitive() && leftType == rightType)) {
3111 return '=='; 3113 return '==';
3112 } 3114 }
3113 return null; 3115 return null;
3114 } else { 3116 } else {
3115 return '==='; 3117 return '===';
3116 } 3118 }
3117 } 3119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698