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

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

Issue 11418173: Canonicalize raw type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 8 years 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 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 } 2416 }
2417 if (node.hasTypeInfo()) { 2417 if (node.hasTypeInfo()) {
2418 InterfaceType interfaceType = type; 2418 InterfaceType interfaceType = type;
2419 ClassElement cls = type.element; 2419 ClassElement cls = type.element;
2420 Link<DartType> arguments = interfaceType.typeArguments; 2420 Link<DartType> arguments = interfaceType.typeArguments;
2421 js.Expression result = pop(); 2421 js.Expression result = pop();
2422 for (TypeVariableType typeVariable in cls.typeVariables) { 2422 for (TypeVariableType typeVariable in cls.typeVariables) {
2423 use(node.typeInfoCall); 2423 use(node.typeInfoCall);
2424 int index = RuntimeTypeInformation.getTypeVariableIndex(typeVariable); 2424 int index = RuntimeTypeInformation.getTypeVariableIndex(typeVariable);
2425 js.PropertyAccess field = new js.PropertyAccess.indexed(pop(), index); 2425 js.PropertyAccess field = new js.PropertyAccess.indexed(pop(), index);
2426 RuntimeTypeInformation rti = backend.rti;
2427 String typeName = rti.getStringRepresentation(arguments.head);
2428 js.Expression genericName = new js.LiteralString("'$typeName'");
2429 js.Binary eqTest = new js.Binary('===', field, genericName);
2430 // Also test for 'undefined' in case the object does not have 2426 // Also test for 'undefined' in case the object does not have
2431 // any type variable. 2427 // any type variable.
2432 js.Prefix undefinedTest = new js.Prefix('!', field); 2428 js.Prefix undefinedTest = new js.Prefix('!', field);
2433 result = new js.Binary( 2429 if (arguments.head == compiler.types.dynamicType) {
2434 '&&', result, new js.Binary('||', undefinedTest, eqTest)); 2430 result = new js.Binary('&&', result, undefinedTest);
2431 } else {
2432 RuntimeTypeInformation rti = backend.rti;
2433 String typeName = rti.getStringRepresentation(arguments.head);
2434 js.Expression genericName = new js.LiteralString("'$typeName'");
2435 js.Binary eqTest = new js.Binary('===', field, genericName);
2436 result = new js.Binary(
2437 '&&', result, new js.Binary('||', undefinedTest, eqTest));
2438 }
2435 arguments = arguments.tail; 2439 arguments = arguments.tail;
2436 } 2440 }
2437 push(result, node); 2441 push(result, node);
2438 } 2442 }
2439 if (node.nullOk) { 2443 if (node.nullOk) {
2440 checkNull(input); 2444 checkNull(input);
2441 push(new js.Binary('||', pop(), pop()), node); 2445 push(new js.Binary('||', pop(), pop()), node);
2442 } 2446 }
2443 } 2447 }
2444 2448
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
3049 if (leftType.canBeNull() && rightType.canBeNull()) { 3053 if (leftType.canBeNull() && rightType.canBeNull()) {
3050 if (left.isConstantNull() || right.isConstantNull() || 3054 if (left.isConstantNull() || right.isConstantNull() ||
3051 (leftType.isPrimitive() && leftType == rightType)) { 3055 (leftType.isPrimitive() && leftType == rightType)) {
3052 return '=='; 3056 return '==';
3053 } 3057 }
3054 return null; 3058 return null;
3055 } else { 3059 } else {
3056 return '==='; 3060 return '===';
3057 } 3061 }
3058 } 3062 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698