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

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

Issue 2400853003: dart2js: Constant fold num.round() (Closed)
Patch Set: Created 4 years, 2 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/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 0f9a0d6225185ee4b6755eb6473fe564bc29324c..e1d468df5e05de6363e5362ab8b0d18fbb56f547 100644
--- a/pkg/compiler/lib/src/constant_system_dart.dart
+++ b/pkg/compiler/lib/src/constant_system_dart.dart
@@ -348,20 +348,13 @@ class IfNullOperation implements BinaryOperation {
apply(left, right) => left ?? right;
}
-abstract class CodeUnitAtOperation implements BinaryOperation {
- final String name = 'charCodeAt';
+class CodeUnitAtOperation implements BinaryOperation {
+ String get name => 'charCodeAt';
const CodeUnitAtOperation();
+ ConstantValue fold(ConstantValue left, ConstantValue right) => null;
apply(left, right) => left.codeUnitAt(right);
}
-class CodeUnitAtConstantOperation extends CodeUnitAtOperation {
- const CodeUnitAtConstantOperation();
- ConstantValue fold(ConstantValue left, ConstantValue right) {
- // 'a'.codeUnitAt(0) is not a constant expression.
- return null;
- }
-}
-
class CodeUnitAtRuntimeOperation extends CodeUnitAtOperation {
const CodeUnitAtRuntimeOperation();
IntConstantValue fold(ConstantValue left, ConstantValue right) {
@@ -379,6 +372,14 @@ class CodeUnitAtRuntimeOperation extends CodeUnitAtOperation {
}
}
+class UnfoldedUnaryOperation implements UnaryOperation {
+ final String name;
+ const UnfoldedUnaryOperation(this.name);
+ ConstantValue fold(ConstantValue constant) {
+ return null;
+ }
+}
+
/**
* A constant system implementing the Dart semantics. This system relies on
* the underlying runtime-system. That is, if dart2js is run in an environment
@@ -409,7 +410,8 @@ class DartConstantSystem extends ConstantSystem {
final shiftRight = const ShiftRightOperation();
final subtract = const SubtractOperation();
final truncatingDivide = const TruncatingDivideOperation();
- final codeUnitAt = const CodeUnitAtConstantOperation();
+ final codeUnitAt = const CodeUnitAtOperation();
+ final round = const UnfoldedUnaryOperation('round');
const DartConstantSystem();
« no previous file with comments | « no previous file | pkg/compiler/lib/src/constants/constant_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698