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

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

Issue 1160833003: Add support for null-aware operators to the CPS-IR. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
index b84a3786c9f7e2776b3731a97ca3d1d63889649b..e6e8a9c5cd1d878d7d5f439002f859e248d46062 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -2023,6 +2023,9 @@ abstract class IrBuilder {
{bool isTypeTest: false,
bool isNotCheck: false});
+ /// Creates a type test checking whether [value] is null.
+ ir.Primitive buildChecknull(ir.Primitive value);
+
/// Create a lazy and/or expression. [leftValue] is the value of the left
/// operand and [buildRightValue] is called to process the value of the right
/// operand in the context of its own [IrBuilder].
@@ -2323,6 +2326,12 @@ class DartIrBuilder extends IrBuilder {
(k) => new ir.TypeOperator(receiver, type, k, isTypeTest: isTypeTest));
return isNotCheck ? buildNegation(check) : check;
}
+
+ @override
+ ir.Primitive buildCheckNull(ir.Primitive value) {
Johnni Winther 2015/05/29 10:23:24 Move the implementation to IrBuilder.
Siggi Cherem (dart-lang) 2015/05/29 18:14:05 After addressing Kevin's comment, this moved just
+ assert(isOpen);
+ return addPrimitive(new ir.Identical(value, buildNullConstant()));
Kevin Millikin (Google) 2015/05/29 11:02:03 Identical is a 'JS specific' IR primitive, which m
Siggi Cherem (dart-lang) 2015/05/29 18:14:05 Great points - I moved most of the implementation
Siggi Cherem (dart-lang) 2015/05/29 19:02:02 Just synced and noticed that DartIrBuilder is gone
+ }
}
/// State shared between JsIrBuilders within the same function.
@@ -2695,6 +2704,11 @@ class JsIrBuilder extends IrBuilder {
return isNotCheck ? buildNegation(check) : check;
}
+ @override
+ ir.Primitive buildCheckNull(ir.Primitive value) {
Johnni Winther 2015/05/29 10:23:24 Remove this.
Siggi Cherem (dart-lang) 2015/05/29 18:14:05 Acknowledged.
+ assert(isOpen);
+ return addPrimitive(new ir.Identical(value, buildNullConstant()));
Kevin Millikin (Google) 2015/05/29 11:02:03 This is completely safe, but since buildNullConsta
Siggi Cherem (dart-lang) 2015/05/29 18:14:05 Done.
+ }
}

Powered by Google App Engine
This is Rietveld 408576698