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 1b92edc489bef36a9aacd5851442f493a5dd5873..3cce915a869466190552c449216349503f997d6a 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart |
| @@ -60,10 +60,15 @@ class CpsFragment { |
| CpsFragment([this.sourceInformation, this.context]); |
| - /// Asserts that the fragment is closed and returns the IR that was built. |
| + bool get isOpen => root == null || context != null; |
| + bool get isClosed => !isOpen; |
| + bool get isEmpty => root == null; |
| + |
| + /// Asserts that the fragment is non-empty and closed and returns the IR that |
| + /// was built. |
| Expression get result { |
| - assert(context == null); |
| - assert(root != null); |
| + assert(!isEmpty); |
| + assert(isClosed); |
| return root; |
| } |
| @@ -99,6 +104,8 @@ class CpsFragment { |
| Primitive makeZero() => makeConstant(new IntConstantValue(0)); |
| Primitive makeOne() => makeConstant(new IntConstantValue(1)); |
| Primitive makeNull() => makeConstant(new NullConstantValue()); |
| + Primitive makeTrue() => makeConstant(new TrueConstantValue()); |
| + Primitive makeFalse() => makeConstant(new FalseConstantValue()); |
| /// Invoke a built-in operator. |
| Primitive applyBuiltin(BuiltinOperator op, List<Primitive> args) { |
| @@ -263,4 +270,20 @@ class CpsFragment { |
| other.context = null; |
| other.root = null; |
| } |
| + |
| + Primitive getMutable(MutableVariable variable) { |
|
floitsch
2015/07/08 18:45:50
add dartdocs (here and for the other methods).
asgerf
2015/07/09 10:22:40
Done.
|
| + return letPrim(new GetMutableVariable(variable)); |
| + } |
| + |
| + void setMutable(MutableVariable variable, Primitive value) { |
| + SetMutableVariable setter = new SetMutableVariable(variable, value); |
| + put(setter); |
| + context = setter; |
| + } |
| + |
| + void letMutable(MutableVariable variable, Primitive initialValue) { |
| + LetMutable let = new LetMutable(variable, initialValue); |
| + put(let); |
| + context = let; |
| + } |
| } |