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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1223813006: dart2js cps: Direct access on JS arrays. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update unit tests and remove unused functions Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir;
10 import '../../tree_ir/tree_ir_nodes.dart' show BuiltinOperator; 10 import '../../tree_ir/tree_ir_nodes.dart' show BuiltinOperator;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 657
658 @override 658 @override
659 js.Expression visitSetStatic(tree_ir.SetStatic node) { 659 js.Expression visitSetStatic(tree_ir.SetStatic node) {
660 assert(node.element is FieldElement); 660 assert(node.element is FieldElement);
661 registry.registerStaticUse(node.element.declaration); 661 registry.registerStaticUse(node.element.declaration);
662 js.Expression field = glue.staticFieldAccess(node.element); 662 js.Expression field = glue.staticFieldAccess(node.element);
663 js.Expression value = visitExpression(node.value); 663 js.Expression value = visitExpression(node.value);
664 return new js.Assignment(field, value); 664 return new js.Assignment(field, value);
665 } 665 }
666 666
667 @override
668 js.Expression visitGetLength(tree_ir.GetLength node) {
669 return new js.PropertyAccess.field(visitExpression(node.object), 'length');
670 }
671
672 @override
673 js.Expression visitGetIndex(tree_ir.GetIndex node) {
674 return new js.PropertyAccess(
675 visitExpression(node.object),
676 visitExpression(node.index));
677 }
678
679 @override
680 js.Expression visitSetIndex(tree_ir.SetIndex node) {
681 return js.js('#[#] = #',
682 [visitExpression(node.object),
683 visitExpression(node.index),
684 visitExpression(node.value)]);
685 }
686
667 js.Expression buildStaticHelperInvocation(FunctionElement helper, 687 js.Expression buildStaticHelperInvocation(FunctionElement helper,
668 List<js.Expression> arguments) { 688 List<js.Expression> arguments) {
669 registry.registerStaticUse(helper); 689 registry.registerStaticUse(helper);
670 return buildStaticInvoke(helper, arguments); 690 return buildStaticInvoke(helper, arguments);
671 } 691 }
672 692
673 @override 693 @override
674 js.Expression visitReifyRuntimeType(tree_ir.ReifyRuntimeType node) { 694 js.Expression visitReifyRuntimeType(tree_ir.ReifyRuntimeType node) {
675 FunctionElement createType = glue.getCreateRuntimeType(); 695 FunctionElement createType = glue.getCreateRuntimeType();
676 FunctionElement typeToString = glue.getRuntimeTypeToString(); 696 FunctionElement typeToString = glue.getRuntimeTypeToString();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 return js.js("typeof # === 'number' && Math.floor(#) === #", args); 786 return js.js("typeof # === 'number' && Math.floor(#) === #", args);
767 } 787 }
768 } 788 }
769 789
770 visitFunctionExpression(tree_ir.FunctionExpression node) { 790 visitFunctionExpression(tree_ir.FunctionExpression node) {
771 // FunctionExpressions are currently unused. 791 // FunctionExpressions are currently unused.
772 // We might need them if we want to emit raw JS nested functions. 792 // We might need them if we want to emit raw JS nested functions.
773 throw 'FunctionExpressions should not be used'; 793 throw 'FunctionExpressions should not be used';
774 } 794 }
775 } 795 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698