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

Unified Diff: pkg/compiler/lib/src/js_backend/constant_system_javascript.dart

Issue 585173002: dart2js: Support new const operations on strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase and status file updates. Created 5 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 | « pkg/compiler/lib/src/constant_system_dart.dart ('k') | tests/language/compile_time_constant12_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
diff --git a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
index 9afb0884159877713bf17eeb219686b89e7f93c7..deadc5f7549f5390c579fd4e3cc5bb1a1f5913f7 100644
--- a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
@@ -97,6 +97,23 @@ class JavaScriptNegateOperation implements UnaryOperation {
}
}
+class JavaScriptAddOperation implements BinaryOperation {
+ final _addOperation = const AddOperation();
+ String get name => _addOperation.name;
+
+ const JavaScriptAddOperation();
+
+ ConstantValue fold(ConstantValue left, ConstantValue right) {
+ ConstantValue result = _addOperation.fold(left, right);
+ if (result != null && result.isNum) {
+ return JAVA_SCRIPT_CONSTANT_SYSTEM.convertToJavaScriptConstant(result);
+ }
+ return result;
+ }
+
+ apply(left, right) => _addOperation.apply(left, right);
+}
+
class JavaScriptBinaryArithmeticOperation implements BinaryOperation {
final BinaryOperation dartArithmeticOperation;
@@ -146,7 +163,7 @@ class JavaScriptConstantSystem extends ConstantSystem {
final int BITS31 = 0x8FFFFFFF;
final int BITS32 = 0xFFFFFFFF;
- final add = const JavaScriptBinaryArithmeticOperation(const AddOperation());
+ final add = const JavaScriptAddOperation();
final bitAnd = const JavaScriptBinaryBitOperation(const BitAndOperation());
final bitNot = const JavaScriptBitNotOperation();
final bitOr = const JavaScriptBinaryBitOperation(const BitOrOperation());
« no previous file with comments | « pkg/compiler/lib/src/constant_system_dart.dart ('k') | tests/language/compile_time_constant12_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698