Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_fragment.dart

Issue 1229563005: dart2js cps: Rewrite iterator/moveNext/current into JS array accesses. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Run redundant phi elimination before type propagation Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6eda70742528e37e653693eee459ff277fda8980 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,23 @@ class CpsFragment {
other.context = null;
other.root = null;
}
+
+ /// Reads the value of the given mutable variable.
+ Primitive getMutable(MutableVariable variable) {
+ return letPrim(new GetMutableVariable(variable));
+ }
+
+ /// Sets the value of the given mutable variable.
+ void setMutable(MutableVariable variable, Primitive value) {
+ SetMutableVariable setter = new SetMutableVariable(variable, value);
+ put(setter);
+ context = setter;
+ }
+
+ /// Declare a new mutable variable.
+ void letMutable(MutableVariable variable, Primitive initialValue) {
+ LetMutable let = new LetMutable(variable, initialValue);
+ put(let);
+ context = let;
+ }
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698