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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
910 currentBlockInformation = info.body.start.blockFlow.body; | 910 currentBlockInformation = info.body.start.blockFlow.body; |
911 generateStatements(info.body); | 911 generateStatements(info.body); |
912 currentBlockInformation = oldInfo; | 912 currentBlockInformation = oldInfo; |
913 } else { | 913 } else { |
914 generateStatements(info.body); | 914 generateStatements(info.body); |
915 } | 915 } |
916 } | 916 } |
917 | 917 |
918 bool visitLoopInfo(HLoopBlockInformation info) { | 918 bool visitLoopInfo(HLoopBlockInformation info) { |
919 HExpressionInformation condition = info.condition; | 919 HExpressionInformation condition = info.condition; |
920 bool isConditionExpression = isJSCondition(condition); | 920 bool isConditionExpression = condition == null |
floitsch
2012/11/06 12:13:33
bool isConditionExpression = (condition == null) |
ngeoffray
2012/11/06 12:19:14
Done.
| |
921 ? true | |
922 : isJSCondition(condition); | |
921 | 923 |
922 js.Loop loop; | 924 js.Loop loop; |
923 | 925 |
924 switch (info.kind) { | 926 switch (info.kind) { |
925 // Treate all three "test-first" loops the same way. | 927 // Treate all three "test-first" loops the same way. |
926 case HLoopBlockInformation.FOR_LOOP: | 928 case HLoopBlockInformation.FOR_LOOP: |
927 case HLoopBlockInformation.WHILE_LOOP: | 929 case HLoopBlockInformation.WHILE_LOOP: |
928 case HLoopBlockInformation.FOR_IN_LOOP: | 930 case HLoopBlockInformation.FOR_IN_LOOP: |
929 HBlockInformation initialization = info.initializer; | 931 HBlockInformation initialization = info.initializer; |
930 int initializationType = TYPE_STATEMENT; | 932 int initializationType = TYPE_STATEMENT; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 js.Statement body = new js.Block.empty(); | 1039 js.Statement body = new js.Block.empty(); |
1038 currentContainer = body; | 1040 currentContainer = body; |
1039 if (!isConditionExpression || info.updates != null) { | 1041 if (!isConditionExpression || info.updates != null) { |
1040 wrapLoopBodyForContinue(info); | 1042 wrapLoopBodyForContinue(info); |
1041 } else { | 1043 } else { |
1042 visitBodyIgnoreLabels(info); | 1044 visitBodyIgnoreLabels(info); |
1043 } | 1045 } |
1044 if (info.updates != null) { | 1046 if (info.updates != null) { |
1045 generateStatements(info.updates); | 1047 generateStatements(info.updates); |
1046 } | 1048 } |
1047 if (isConditionExpression) { | 1049 if (condition == null) { |
1050 push(newLiteralBool(false)); | |
1051 } else if (isConditionExpression) { | |
1048 push(generateExpression(condition)); | 1052 push(generateExpression(condition)); |
1049 } else { | 1053 } else { |
1050 generateStatements(condition); | 1054 generateStatements(condition); |
1051 use(condition.conditionExpression); | 1055 use(condition.conditionExpression); |
1052 } | 1056 } |
1053 js.Expression jsCondition = pop(); | 1057 js.Expression jsCondition = pop(); |
1054 currentContainer = oldContainer; | 1058 currentContainer = oldContainer; |
1055 body = unwrapStatement(body); | 1059 body = unwrapStatement(body); |
1056 loop = new js.Do(body, jsCondition); | 1060 loop = new js.Do(body, jsCondition); |
1057 break; | 1061 break; |
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3142 if (leftType.canBeNull() && rightType.canBeNull()) { | 3146 if (leftType.canBeNull() && rightType.canBeNull()) { |
3143 if (left.isConstantNull() || right.isConstantNull() || | 3147 if (left.isConstantNull() || right.isConstantNull() || |
3144 (leftType.isPrimitive() && leftType == rightType)) { | 3148 (leftType.isPrimitive() && leftType == rightType)) { |
3145 return '=='; | 3149 return '=='; |
3146 } | 3150 } |
3147 return null; | 3151 return null; |
3148 } else { | 3152 } else { |
3149 return '==='; | 3153 return '==='; |
3150 } | 3154 } |
3151 } | 3155 } |
OLD | NEW |