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

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

Issue 1562893002: dart2js cps: Generate increment and compound operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Also compound string concatenation 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 | « no previous file | pkg/compiler/lib/src/js_backend/codegen/codegen.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/builtin_operator.dart
diff --git a/pkg/compiler/lib/src/cps_ir/builtin_operator.dart b/pkg/compiler/lib/src/cps_ir/builtin_operator.dart
index 699e755fb3b75c2376a6f8e4616cd2d6522c7e6e..2db4ac5bf62d70ee7a348e735609df5152f1abfd 100644
--- a/pkg/compiler/lib/src/cps_ir/builtin_operator.dart
+++ b/pkg/compiler/lib/src/cps_ir/builtin_operator.dart
@@ -158,26 +158,41 @@ enum BuiltinOperator {
/// A method supported natively in the CPS and Tree IRs using the
/// `ApplyBuiltinMethod` instructions.
-///
+///
/// These methods all operate on a distinguished 'object' argument, and
/// take zero or more additional arguments.
-///
+///
/// These methods may mutate and depend on the state of the object argument,
/// but may not depend on or mutate any other state. An exception is thrown
/// if the object is null, but otherwise they cannot throw or diverge.
enum BuiltinMethod {
/// Add an item to a native list.
- ///
+ ///
/// Takes any number of arguments, each argument will be added to the
/// list on the order given (as per the JS `push` method).
- ///
+ ///
/// Compiles to `object.push(x1, ..., xN)`.
Push,
/// Remove and return the last item from a native list.
- ///
+ ///
/// Takes no arguments.
- ///
+ ///
/// Compiles to `object.pop()`.
Pop,
}
+
+/// True for the built-in operators that may be used in a compound assignment.
+bool isCompoundableOperator(BuiltinOperator operator) {
+ switch(operator) {
+ case BuiltinOperator.NumAdd:
+ case BuiltinOperator.NumSubtract:
+ case BuiltinOperator.NumMultiply:
+ case BuiltinOperator.NumDivide:
+ case BuiltinOperator.NumRemainder:
+ case BuiltinOperator.StringConcatenate:
+ return true;
+ default:
+ return false;
+ }
+}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698