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 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2464 checkType(input, type); | 2464 checkType(input, type); |
2465 attachLocationToLast(node); | 2465 attachLocationToLast(node); |
2466 } | 2466 } |
2467 if (node.hasTypeInfo()) { | 2467 if (node.hasTypeInfo()) { |
2468 InterfaceType interfaceType = type; | 2468 InterfaceType interfaceType = type; |
2469 ClassElement cls = type.element; | 2469 ClassElement cls = type.element; |
2470 Link<DartType> arguments = interfaceType.arguments; | 2470 Link<DartType> arguments = interfaceType.arguments; |
2471 js.Expression result = pop(); | 2471 js.Expression result = pop(); |
2472 for (TypeVariableType typeVariable in cls.typeVariables) { | 2472 for (TypeVariableType typeVariable in cls.typeVariables) { |
2473 use(node.typeInfoCall); | 2473 use(node.typeInfoCall); |
2474 // TODO(johnniwinther): Retrieve the type name properly and not through | 2474 int index = RuntimeTypeInformation.getTypeVariableIndex(typeVariable); |
2475 // [toString]. Note: Two cases below [typeVariable] and | 2475 js.PropertyAccess field = new js.PropertyAccess.indexed(pop(), index); |
2476 // [arguments.head]. | |
2477 js.PropertyAccess field = | |
2478 new js.PropertyAccess.field(pop(), typeVariable.toString()); | |
2479 js.Expression genericName = new js.LiteralString("'${arguments.head}'"); | 2476 js.Expression genericName = new js.LiteralString("'${arguments.head}'"); |
2480 js.Binary eqTest = new js.Binary('===', field, genericName); | 2477 js.Binary eqTest = new js.Binary('===', field, genericName); |
2481 // Also test for 'undefined' in case the object does not have | 2478 // Also test for 'undefined' in case the object does not have |
2482 // any type variable. | 2479 // any type variable. |
2483 js.Prefix undefinedTest = new js.Prefix('!', field); | 2480 js.Prefix undefinedTest = new js.Prefix('!', field); |
2484 result = new js.Binary( | 2481 result = new js.Binary( |
2485 '&&', result, new js.Binary('||', undefinedTest, eqTest)); | 2482 '&&', result, new js.Binary('||', undefinedTest, eqTest)); |
2483 arguments = arguments.tail; | |
ngeoffray
2012/11/15 08:58:09
Was it not tested before?
karlklose
2012/11/16 13:37:19
It was, but the tests were marked as failing.
| |
2486 } | 2484 } |
2487 push(result, node); | 2485 push(result, node); |
2488 } | 2486 } |
2489 if (node.nullOk) { | 2487 if (node.nullOk) { |
2490 checkNull(input); | 2488 checkNull(input); |
2491 push(new js.Binary('||', pop(), pop()), node); | 2489 push(new js.Binary('||', pop(), pop()), node); |
2492 } | 2490 } |
2493 } | 2491 } |
2494 | 2492 |
2495 void visitTypeConversion(HTypeConversion node) { | 2493 void visitTypeConversion(HTypeConversion node) { |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3101 if (leftType.canBeNull() && rightType.canBeNull()) { | 3099 if (leftType.canBeNull() && rightType.canBeNull()) { |
3102 if (left.isConstantNull() || right.isConstantNull() || | 3100 if (left.isConstantNull() || right.isConstantNull() || |
3103 (leftType.isPrimitive() && leftType == rightType)) { | 3101 (leftType.isPrimitive() && leftType == rightType)) { |
3104 return '=='; | 3102 return '=='; |
3105 } | 3103 } |
3106 return null; | 3104 return null; |
3107 } else { | 3105 } else { |
3108 return '==='; | 3106 return '==='; |
3109 } | 3107 } |
3110 } | 3108 } |
OLD | NEW |