OLD | NEW |
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 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 checkType(input, type); | 2468 checkType(input, type); |
2469 attachLocationToLast(node); | 2469 attachLocationToLast(node); |
2470 } | 2470 } |
2471 if (node.hasTypeInfo()) { | 2471 if (node.hasTypeInfo()) { |
2472 InterfaceType interfaceType = type; | 2472 InterfaceType interfaceType = type; |
2473 ClassElement cls = type.element; | 2473 ClassElement cls = type.element; |
2474 Link<DartType> arguments = interfaceType.arguments; | 2474 Link<DartType> arguments = interfaceType.arguments; |
2475 js.Expression result = pop(); | 2475 js.Expression result = pop(); |
2476 for (TypeVariableType typeVariable in cls.typeVariables) { | 2476 for (TypeVariableType typeVariable in cls.typeVariables) { |
2477 use(node.typeInfoCall); | 2477 use(node.typeInfoCall); |
2478 // TODO(johnniwinther): Retrieve the type name properly and not through | 2478 int index = RuntimeTypeInformation.getTypeVariableIndex(typeVariable); |
2479 // [toString]. Note: Two cases below [typeVariable] and | 2479 js.PropertyAccess field = new js.PropertyAccess.indexed(pop(), index); |
2480 // [arguments.head]. | |
2481 js.PropertyAccess field = | |
2482 new js.PropertyAccess.field(pop(), typeVariable.toString()); | |
2483 js.Expression genericName = new js.LiteralString("'${arguments.head}'"); | 2480 js.Expression genericName = new js.LiteralString("'${arguments.head}'"); |
2484 js.Binary eqTest = new js.Binary('===', field, genericName); | 2481 js.Binary eqTest = new js.Binary('===', field, genericName); |
2485 // Also test for 'undefined' in case the object does not have | 2482 // Also test for 'undefined' in case the object does not have |
2486 // any type variable. | 2483 // any type variable. |
2487 js.Prefix undefinedTest = new js.Prefix('!', field); | 2484 js.Prefix undefinedTest = new js.Prefix('!', field); |
2488 result = new js.Binary( | 2485 result = new js.Binary( |
2489 '&&', result, new js.Binary('||', undefinedTest, eqTest)); | 2486 '&&', result, new js.Binary('||', undefinedTest, eqTest)); |
| 2487 arguments = arguments.tail; |
2490 } | 2488 } |
2491 push(result, node); | 2489 push(result, node); |
2492 } | 2490 } |
2493 if (node.nullOk) { | 2491 if (node.nullOk) { |
2494 checkNull(input); | 2492 checkNull(input); |
2495 push(new js.Binary('||', pop(), pop()), node); | 2493 push(new js.Binary('||', pop(), pop()), node); |
2496 } | 2494 } |
2497 } | 2495 } |
2498 | 2496 |
2499 void visitTypeConversion(HTypeConversion node) { | 2497 void visitTypeConversion(HTypeConversion node) { |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3105 if (leftType.canBeNull() && rightType.canBeNull()) { | 3103 if (leftType.canBeNull() && rightType.canBeNull()) { |
3106 if (left.isConstantNull() || right.isConstantNull() || | 3104 if (left.isConstantNull() || right.isConstantNull() || |
3107 (leftType.isPrimitive() && leftType == rightType)) { | 3105 (leftType.isPrimitive() && leftType == rightType)) { |
3108 return '=='; | 3106 return '=='; |
3109 } | 3107 } |
3110 return null; | 3108 return null; |
3111 } else { | 3109 } else { |
3112 return '==='; | 3110 return '==='; |
3113 } | 3111 } |
3114 } | 3112 } |
OLD | NEW |