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

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

Issue 1713983002: dart2js cps: Add SetLength instruction. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Use trust-primitives and refine type of length to uint32' Created 4 years, 10 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/cps_ir/type_propagation.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index 1d2549d7ed4116569b3a2413ce37791b3616a5c7..4d0f49709bb157cb289afe8722d6d774dbb08d0b 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -1211,20 +1211,20 @@ class CodeGenerator extends tree_ir.StatementVisitor
return js.js('# >>> 0', [op]);
}
-
- /// The JS name of a built-in method.
- static final Map<BuiltinMethod, String> builtinMethodName =
- const <BuiltinMethod, String>{
- BuiltinMethod.Push: 'push',
- BuiltinMethod.Pop: 'pop',
- };
-
@override
js.Expression visitApplyBuiltinMethod(tree_ir.ApplyBuiltinMethod node) {
- String name = builtinMethodName[node.method];
js.Expression receiver = visitExpression(node.receiver);
List<js.Expression> args = visitExpressionList(node.arguments);
- return js.js('#.#(#)', [receiver, name, args]);
+ switch (node.method) {
+ case BuiltinMethod.Push:
+ return js.js('#.push(#)', [receiver, args]);
+
+ case BuiltinMethod.Pop:
+ return js.js('#.pop()', [receiver]);
+
+ case BuiltinMethod.SetLength:
+ return js.js('#.length = #', [receiver, args[0]]);
+ }
}
@override
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698