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

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

Issue 11413219: Canonicalize raw type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment 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 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 } 2383 }
2384 if (node.hasTypeInfo()) { 2384 if (node.hasTypeInfo()) {
2385 InterfaceType interfaceType = type; 2385 InterfaceType interfaceType = type;
2386 ClassElement cls = type.element; 2386 ClassElement cls = type.element;
2387 Link<DartType> arguments = interfaceType.typeArguments; 2387 Link<DartType> arguments = interfaceType.typeArguments;
2388 js.Expression result = pop(); 2388 js.Expression result = pop();
2389 for (TypeVariableType typeVariable in cls.typeVariables) { 2389 for (TypeVariableType typeVariable in cls.typeVariables) {
2390 use(node.typeInfoCall); 2390 use(node.typeInfoCall);
2391 int index = RuntimeTypeInformation.getTypeVariableIndex(typeVariable); 2391 int index = RuntimeTypeInformation.getTypeVariableIndex(typeVariable);
2392 js.PropertyAccess field = new js.PropertyAccess.indexed(pop(), index); 2392 js.PropertyAccess field = new js.PropertyAccess.indexed(pop(), index);
2393 RuntimeTypeInformation rti = backend.rti;
2394 String typeName = rti.getStringRepresentation(arguments.head);
2395 js.Expression genericName = new js.LiteralString("'$typeName'");
2396 js.Binary eqTest = new js.Binary('===', field, genericName);
2397 // Also test for 'undefined' in case the object does not have 2393 // Also test for 'undefined' in case the object does not have
2398 // any type variable. 2394 // any type variable.
2399 js.Prefix undefinedTest = new js.Prefix('!', field); 2395 js.Prefix undefinedTest = new js.Prefix('!', field);
2400 result = new js.Binary( 2396 if (arguments.head == compiler.types.dynamicType) {
2401 '&&', result, new js.Binary('||', undefinedTest, eqTest)); 2397 result = new js.Binary('&&', result, undefinedTest);
2398 } else {
2399 RuntimeTypeInformation rti = backend.rti;
2400 String typeName = rti.getStringRepresentation(arguments.head);
2401 js.Expression genericName = new js.LiteralString("'$typeName'");
2402 js.Binary eqTest = new js.Binary('===', field, genericName);
2403 result = new js.Binary(
2404 '&&', result, new js.Binary('||', undefinedTest, eqTest));
2405 }
2402 arguments = arguments.tail; 2406 arguments = arguments.tail;
2403 } 2407 }
2404 push(result, node); 2408 push(result, node);
2405 } 2409 }
2406 if (node.nullOk) { 2410 if (node.nullOk) {
2407 checkNull(input); 2411 checkNull(input);
2408 push(new js.Binary('||', pop(), pop()), node); 2412 push(new js.Binary('||', pop(), pop()), node);
2409 } 2413 }
2410 } 2414 }
2411 2415
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 if (leftType.canBeNull() && rightType.canBeNull()) { 3020 if (leftType.canBeNull() && rightType.canBeNull()) {
3017 if (left.isConstantNull() || right.isConstantNull() || 3021 if (left.isConstantNull() || right.isConstantNull() ||
3018 (leftType.isPrimitive() && leftType == rightType)) { 3022 (leftType.isPrimitive() && leftType == rightType)) {
3019 return '=='; 3023 return '==';
3020 } 3024 }
3021 return null; 3025 return null;
3022 } else { 3026 } else {
3023 return '==='; 3027 return '===';
3024 } 3028 }
3025 } 3029 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698