Chromium Code Reviews| Index: pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
| diff --git a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
| index cc06b498c2f77e038b62b7ce2b03870a4900de10..4805bfcea9929ec1490378c341e626cce8cc080b 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
| @@ -10,6 +10,7 @@ import '../universe/selector.dart' show Selector; |
| import '../types/types.dart' show TypeMask; |
| import '../io/source_information.dart'; |
| import '../elements/elements.dart'; |
| +import 'cps_fragment.dart'; |
|
Siggi Cherem (dart-lang)
2016/01/08 23:51:34
remove self import?
asgerf
2016/01/11 19:07:07
I must have been confused when I wrote that
|
| /// Builds a CPS fragment that can be plugged into another CPS term. |
| /// |
| @@ -189,31 +190,39 @@ class CpsFragment { |
| /// Branch on [condition]. |
| /// |
| - /// Returns a new fragment for the 'then' branch. |
| + /// Returns a new fragment for the 'then' branch, or the 'else' branch |
| + /// if [negate] is true. |
| /// |
| - /// The 'else' branch becomes the new hole. |
| - CpsFragment ifTruthy(Primitive condition) { |
| + /// The other branch becomes the new hole. |
| + CpsFragment branch(Primitive condition, |
| + {bool negate: false, |
| + bool strict: false}) { |
| Continuation trueCont = new Continuation(<Parameter>[]); |
| Continuation falseCont = new Continuation(<Parameter>[]); |
| put(new LetCont.two(trueCont, falseCont, |
| - new Branch.loose(condition, trueCont, falseCont))); |
| - context = falseCont; |
| - return new CpsFragment(sourceInformation, trueCont); |
| + new Branch(condition, trueCont, falseCont, strict: strict))); |
| + if (negate) { |
| + context = trueCont; |
| + return new CpsFragment(sourceInformation, falseCont); |
| + } else { |
| + context = falseCont; |
| + return new CpsFragment(sourceInformation, trueCont); |
| + } |
| } |
| /// Branch on [condition]. |
| /// |
| + /// Returns a new fragment for the 'then' branch. |
| + /// |
| + /// The 'else' branch becomes the new hole. |
| + CpsFragment ifTruthy(Primitive condition) => branch(condition); |
| + |
| + /// Branch on [condition]. |
| + /// |
| /// Returns a new fragment for the 'else' branch. |
| /// |
| /// The 'then' branch becomes the new hole. |
| - CpsFragment ifFalsy(Primitive condition) { |
| - Continuation trueCont = new Continuation(<Parameter>[]); |
| - Continuation falseCont = new Continuation(<Parameter>[]); |
| - put(new LetCont.two(trueCont, falseCont, |
| - new Branch.loose(condition, trueCont, falseCont))); |
| - context = trueCont; |
| - return new CpsFragment(sourceInformation, falseCont); |
| - } |
| + CpsFragment ifFalsy(Primitive condition) => branch(condition, negate: true); |
| /// Create a new empty continuation and bind it here. |
| /// |