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

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

Issue 11360228: Simplify runtime type support. (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 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 checkType(input, type); 2417 checkType(input, type);
2418 attachLocationToLast(node); 2418 attachLocationToLast(node);
2419 } 2419 }
2420 if (node.hasTypeInfo()) { 2420 if (node.hasTypeInfo()) {
2421 InterfaceType interfaceType = type; 2421 InterfaceType interfaceType = type;
2422 ClassElement cls = type.element; 2422 ClassElement cls = type.element;
2423 Link<DartType> arguments = interfaceType.arguments; 2423 Link<DartType> arguments = interfaceType.arguments;
2424 js.Expression result = pop(); 2424 js.Expression result = pop();
2425 for (TypeVariableType typeVariable in cls.typeVariables) { 2425 for (TypeVariableType typeVariable in cls.typeVariables) {
2426 use(node.typeInfoCall); 2426 use(node.typeInfoCall);
2427 // TODO(johnniwinther): Retrieve the type name properly and not through 2427 int index = RuntimeTypeInformation.getTypeVariableIndex(typeVariable);
2428 // [toString]. Note: Two cases below [typeVariable] and 2428 js.PropertyAccess field = new js.PropertyAccess.indexed(pop(), index);
2429 // [arguments.head].
2430 js.PropertyAccess field =
2431 new js.PropertyAccess.field(pop(), typeVariable.toString());
2432 RuntimeTypeInformation rti = backend.rti; 2429 RuntimeTypeInformation rti = backend.rti;
2433 String typeName = rti.buildStringRepresentation(arguments.head); 2430 String typeName = rti.getStringRepresentation(arguments.head);
2434 js.Expression genericName = new js.LiteralString("'$typeName'"); 2431 js.Expression genericName = new js.LiteralString("'$typeName'");
2435 js.Binary eqTest = new js.Binary('===', field, genericName); 2432 js.Binary eqTest = new js.Binary('===', field, genericName);
2436 // Also test for 'undefined' in case the object does not have 2433 // Also test for 'undefined' in case the object does not have
2437 // any type variable. 2434 // any type variable.
2438 js.Prefix undefinedTest = new js.Prefix('!', field); 2435 js.Prefix undefinedTest = new js.Prefix('!', field);
2439 result = new js.Binary( 2436 result = new js.Binary(
2440 '&&', result, new js.Binary('||', undefinedTest, eqTest)); 2437 '&&', result, new js.Binary('||', undefinedTest, eqTest));
2438 arguments = arguments.tail;
2441 } 2439 }
2442 push(result, node); 2440 push(result, node);
2443 } 2441 }
2444 if (node.nullOk) { 2442 if (node.nullOk) {
2445 checkNull(input); 2443 checkNull(input);
2446 push(new js.Binary('||', pop(), pop()), node); 2444 push(new js.Binary('||', pop(), pop()), node);
2447 } 2445 }
2448 } 2446 }
2449 2447
2450 void visitTypeConversion(HTypeConversion node) { 2448 void visitTypeConversion(HTypeConversion node) {
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 if (leftType.canBeNull() && rightType.canBeNull()) { 3052 if (leftType.canBeNull() && rightType.canBeNull()) {
3055 if (left.isConstantNull() || right.isConstantNull() || 3053 if (left.isConstantNull() || right.isConstantNull() ||
3056 (leftType.isPrimitive() && leftType == rightType)) { 3054 (leftType.isPrimitive() && leftType == rightType)) {
3057 return '=='; 3055 return '==';
3058 } 3056 }
3059 return null; 3057 return null;
3060 } else { 3058 } else {
3061 return '==='; 3059 return '===';
3062 } 3060 }
3063 } 3061 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698