| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library code_generator; | 5 library code_generator; |
| 6 | 6 |
| 7 import 'glue.dart'; | 7 import 'glue.dart'; |
| 8 | 8 |
| 9 import '../../closure.dart' show | 9 import '../../closure.dart' show |
| 10 ClosureClassElement; | 10 ClosureClassElement; |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 } | 742 } |
| 743 js.Expression update = makeSequence(node.updates); | 743 js.Expression update = makeSequence(node.updates); |
| 744 loopNode = new js.For(init, condition, update, body); | 744 loopNode = new js.For(init, condition, update, body); |
| 745 } | 745 } |
| 746 accumulator.add(insertLabel(node.label, loopNode)); | 746 accumulator.add(insertLabel(node.label, loopNode)); |
| 747 visitStatement(node.next); | 747 visitStatement(node.next); |
| 748 } | 748 } |
| 749 | 749 |
| 750 @override | 750 @override |
| 751 void visitWhileTrue(tree_ir.WhileTrue node) { | 751 void visitWhileTrue(tree_ir.WhileTrue node) { |
| 752 js.Expression condition = new js.LiteralBool(true); | |
| 753 // A short break in the while will jump to the current fallthrough target. | 752 // A short break in the while will jump to the current fallthrough target. |
| 754 shortBreak.push(fallthrough.target); | 753 shortBreak.push(fallthrough.target); |
| 755 shortContinue.push(node); | 754 shortContinue.push(node); |
| 756 fallthrough.push(node); | 755 fallthrough.push(node); |
| 757 emitUnreachableAsReturn.add(true); | 756 emitUnreachableAsReturn.add(true); |
| 758 js.Statement jsBody = buildBodyStatement(node.body); | 757 js.Statement jsBody = buildBodyStatement(node.body); |
| 759 emitUnreachableAsReturn.removeLast(); | 758 emitUnreachableAsReturn.removeLast(); |
| 760 fallthrough.pop(); | 759 fallthrough.pop(); |
| 761 shortContinue.pop(); | 760 shortContinue.pop(); |
| 762 if (shortBreak.useCount > 0) { | 761 if (shortBreak.useCount > 0) { |
| 763 // Short breaks use the current fallthrough target. | 762 // Short breaks use the current fallthrough target. |
| 764 fallthrough.use(); | 763 fallthrough.use(); |
| 765 } | 764 } |
| 766 shortBreak.pop(); | 765 shortBreak.pop(); |
| 767 accumulator.add(insertLabel(node.label, new js.While(condition, jsBody))); | 766 accumulator.add( |
| 767 insertLabel(node.label, new js.For(null, null, null, jsBody))); |
| 768 } | 768 } |
| 769 | 769 |
| 770 bool isNull(tree_ir.Expression node) { | 770 bool isNull(tree_ir.Expression node) { |
| 771 return node is tree_ir.Constant && node.value.isNull; | 771 return node is tree_ir.Constant && node.value.isNull; |
| 772 } | 772 } |
| 773 | 773 |
| 774 @override | 774 @override |
| 775 void visitReturn(tree_ir.Return node) { | 775 void visitReturn(tree_ir.Return node) { |
| 776 if (isNull(node.value) && fallthrough.target == null) { | 776 if (isNull(node.value) && fallthrough.target == null) { |
| 777 // Do nothing. Implicitly return JS undefined by falling over the end. | 777 // Do nothing. Implicitly return JS undefined by falling over the end. |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 void registerDefaultParameterValues(ExecutableElement element) { | 1225 void registerDefaultParameterValues(ExecutableElement element) { |
| 1226 if (element is! FunctionElement) return; | 1226 if (element is! FunctionElement) return; |
| 1227 FunctionElement function = element; | 1227 FunctionElement function = element; |
| 1228 if (function.isStatic) return; // Defaults are inlined at call sites. | 1228 if (function.isStatic) return; // Defaults are inlined at call sites. |
| 1229 function.functionSignature.forEachOptionalParameter((param) { | 1229 function.functionSignature.forEachOptionalParameter((param) { |
| 1230 ConstantValue constant = glue.getDefaultParameterValue(param); | 1230 ConstantValue constant = glue.getDefaultParameterValue(param); |
| 1231 registry.registerCompileTimeConstant(constant); | 1231 registry.registerCompileTimeConstant(constant); |
| 1232 }); | 1232 }); |
| 1233 } | 1233 } |
| 1234 } | 1234 } |
| OLD | NEW |