| 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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 | 6 |
| 7 final JavaScriptBackend backend; | 7 final JavaScriptBackend backend; |
| 8 | 8 |
| 9 SsaCodeGeneratorTask(JavaScriptBackend backend) | 9 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 10 : this.backend = backend, | 10 : this.backend = backend, |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 bool visitLoopInfo(HLoopBlockInformation info) { | 803 bool visitLoopInfo(HLoopBlockInformation info) { |
| 804 HExpressionInformation condition = info.condition; | 804 HExpressionInformation condition = info.condition; |
| 805 bool isConditionExpression = isJSCondition(condition); | 805 bool isConditionExpression = isJSCondition(condition); |
| 806 | 806 |
| 807 js.Loop loop; | 807 js.Loop loop; |
| 808 | 808 |
| 809 switch (info.kind) { | 809 switch (info.kind) { |
| 810 // Treate all three "test-first" loops the same way. | 810 // Treate all three "test-first" loops the same way. |
| 811 case HLoopBlockInformation.FOR_LOOP: | 811 case HLoopBlockInformation.FOR_LOOP: |
| 812 case HLoopBlockInformation.WHILE_LOOP: | 812 case HLoopBlockInformation.WHILE_LOOP: |
| 813 case HLoopBlockInformation.FOR_IN_LOOP: { | 813 case HLoopBlockInformation.FOR_IN_LOOP: |
| 814 HBlockInformation initialization = info.initializer; | 814 HBlockInformation initialization = info.initializer; |
| 815 int initializationType = TYPE_STATEMENT; | 815 int initializationType = TYPE_STATEMENT; |
| 816 if (initialization !== null) { | 816 if (initialization !== null) { |
| 817 initializationType = expressionType(initialization); | 817 initializationType = expressionType(initialization); |
| 818 if (initializationType == TYPE_STATEMENT) { | 818 if (initializationType == TYPE_STATEMENT) { |
| 819 generateStatements(initialization); | 819 generateStatements(initialization); |
| 820 initialization = null; | 820 initialization = null; |
| 821 } | 821 } |
| 822 } | 822 } |
| 823 if (isConditionExpression && | 823 if (isConditionExpression && |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 wrapLoopBodyForContinue(info); | 905 wrapLoopBodyForContinue(info); |
| 906 generateStatements(info.updates); | 906 generateStatements(info.updates); |
| 907 } else { | 907 } else { |
| 908 visitBodyIgnoreLabels(info); | 908 visitBodyIgnoreLabels(info); |
| 909 } | 909 } |
| 910 currentContainer = oldContainer; | 910 currentContainer = oldContainer; |
| 911 body = unwrapStatement(body); | 911 body = unwrapStatement(body); |
| 912 loop = new js.While(jsCondition, body); | 912 loop = new js.While(jsCondition, body); |
| 913 } | 913 } |
| 914 break; | 914 break; |
| 915 } | 915 case HLoopBlockInformation.DO_WHILE_LOOP: |
| 916 case HLoopBlockInformation.DO_WHILE_LOOP: { | |
| 917 // Generate do-while loop in all cases. | 916 // Generate do-while loop in all cases. |
| 918 if (info.initializer !== null) { | 917 if (info.initializer !== null) { |
| 919 generateStatements(info.initializer); | 918 generateStatements(info.initializer); |
| 920 } | 919 } |
| 921 js.Block oldContainer = currentContainer; | 920 js.Block oldContainer = currentContainer; |
| 922 js.Statement body = new js.Block.empty(); | 921 js.Statement body = new js.Block.empty(); |
| 923 currentContainer = body; | 922 currentContainer = body; |
| 924 if (!isConditionExpression || info.updates !== null) { | 923 if (!isConditionExpression || info.updates !== null) { |
| 925 wrapLoopBodyForContinue(info); | 924 wrapLoopBodyForContinue(info); |
| 926 } else { | 925 } else { |
| 927 visitBodyIgnoreLabels(info); | 926 visitBodyIgnoreLabels(info); |
| 928 } | 927 } |
| 929 if (info.updates !== null) { | 928 if (info.updates !== null) { |
| 930 generateStatements(info.updates); | 929 generateStatements(info.updates); |
| 931 } | 930 } |
| 932 if (isConditionExpression) { | 931 if (isConditionExpression) { |
| 933 push(generateExpression(condition)); | 932 push(generateExpression(condition)); |
| 934 } else { | 933 } else { |
| 935 generateStatements(condition); | 934 generateStatements(condition); |
| 936 use(condition.conditionExpression); | 935 use(condition.conditionExpression); |
| 937 } | 936 } |
| 938 js.Expression jsCondition = pop(); | 937 js.Expression jsCondition = pop(); |
| 939 currentContainer = oldContainer; | 938 currentContainer = oldContainer; |
| 940 body = unwrapStatement(body); | 939 body = unwrapStatement(body); |
| 941 loop = new js.Do(body, jsCondition); | 940 loop = new js.Do(body, jsCondition); |
| 942 break; | 941 break; |
| 943 } | |
| 944 default: | 942 default: |
| 945 compiler.internalError( | 943 compiler.internalError( |
| 946 'Unexpected loop kind: ${info.kind}', | 944 'Unexpected loop kind: ${info.kind}', |
| 947 instruction: condition.conditionExpression); | 945 instruction: condition.conditionExpression); |
| 948 } | 946 } |
| 949 attachLocationRange(loop, info.sourcePosition, info.endSourcePosition); | 947 attachLocationRange(loop, info.sourcePosition, info.endSourcePosition); |
| 950 pushStatement(wrapIntoLabels(loop, info.labels)); | 948 pushStatement(wrapIntoLabels(loop, info.labels)); |
| 951 return true; | 949 return true; |
| 952 } | 950 } |
| 953 | 951 |
| (...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2984 if (leftType.canBeNull() && rightType.canBeNull()) { | 2982 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2985 if (left.isConstantNull() || right.isConstantNull() || | 2983 if (left.isConstantNull() || right.isConstantNull() || |
| 2986 (leftType.isPrimitive() && leftType == rightType)) { | 2984 (leftType.isPrimitive() && leftType == rightType)) { |
| 2987 return '=='; | 2985 return '=='; |
| 2988 } | 2986 } |
| 2989 return null; | 2987 return null; |
| 2990 } else { | 2988 } else { |
| 2991 return '==='; | 2989 return '==='; |
| 2992 } | 2990 } |
| 2993 } | 2991 } |
| OLD | NEW |