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

Unified Diff: pkg/compiler/lib/src/constant_system_dart.dart

Issue 1493693002: Make ?? a compile-time constant operator. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Move VM/analyzer parts to separate CLs. Created 4 years, 11 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 | « docs/language/dartLangSpec.tex ('k') | pkg/compiler/lib/src/constants/constant_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/constant_system_dart.dart
diff --git a/pkg/compiler/lib/src/constant_system_dart.dart b/pkg/compiler/lib/src/constant_system_dart.dart
index 4a15ac9aff7cba10487fe95cb9a8086619ee39ea..c2c819ed7c53988d3abc9be1107861a5e94b6eea 100644
--- a/pkg/compiler/lib/src/constant_system_dart.dart
+++ b/pkg/compiler/lib/src/constant_system_dart.dart
@@ -332,6 +332,16 @@ class IdentityOperation implements BinaryOperation {
apply(left, right) => identical(left, right);
}
+class IfNullOperation implements BinaryOperation {
+ final String name = '??';
+ const IfNullOperation();
+ ConstantValue fold(ConstantValue left, ConstantValue right) {
+ if (left.isNull) return right;
+ return left;
+ }
+ apply(left, right) => left ?? right;
+}
+
abstract class CodeUnitAtOperation implements BinaryOperation {
final String name = 'charCodeAt';
const CodeUnitAtOperation();
@@ -382,6 +392,7 @@ class DartConstantSystem extends ConstantSystem {
final greaterEqual = const GreaterEqualOperation();
final greater = const GreaterOperation();
final identity = const IdentityOperation();
+ final ifNull = const IfNullOperation();
final lessEqual = const LessEqualOperation();
final less = const LessOperation();
final modulo = const ModuloOperation();
« no previous file with comments | « docs/language/dartLangSpec.tex ('k') | pkg/compiler/lib/src/constants/constant_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698