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

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

Issue 1196443002: Revert "cps-ir: Support foreign code." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 js.Expression visitCreateInvocationMirror( 610 js.Expression visitCreateInvocationMirror(
611 tree_ir.CreateInvocationMirror node) { 611 tree_ir.CreateInvocationMirror node) {
612 js.Expression name = js.string(node.selector.name); 612 js.Expression name = js.string(node.selector.name);
613 js.Expression internalName = js.string(glue.invocationName(node.selector)); 613 js.Expression internalName = js.string(glue.invocationName(node.selector));
614 js.Expression kind = js.number(node.selector.invocationMirrorKind); 614 js.Expression kind = js.number(node.selector.invocationMirrorKind);
615 js.Expression arguments = new js.ArrayInitializer( 615 js.Expression arguments = new js.ArrayInitializer(
616 visitExpressionList(node.arguments)); 616 visitExpressionList(node.arguments));
617 js.Expression argumentNames = new js.ArrayInitializer( 617 js.Expression argumentNames = new js.ArrayInitializer(
618 node.selector.namedArguments.map(js.string).toList(growable: false)); 618 node.selector.namedArguments.map(js.string).toList(growable: false));
619 return buildStaticHelperInvocation(glue.createInvocationMirrorMethod, 619 return buildStaticHelperInvocation(glue.createInvocationMirrorMethod,
620 <js.Expression>[name, internalName, kind, arguments, argumentNames]); 620 [name, internalName, kind, arguments, argumentNames]);
621 } 621 }
622 622
623 @override 623 @override
624 js.Expression visitGetField(tree_ir.GetField node) { 624 js.Expression visitGetField(tree_ir.GetField node) {
625 return new js.PropertyAccess.field( 625 return new js.PropertyAccess.field(
626 visitExpression(node.object), 626 visitExpression(node.object),
627 glue.instanceFieldPropertyName(node.field)); 627 glue.instanceFieldPropertyName(node.field));
628 } 628 }
629 629
630 @override 630 @override
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 [visitExpression(node.target), index]); 696 [visitExpression(node.target), index]);
697 } 697 }
698 } 698 }
699 699
700 @override 700 @override
701 js.Expression visitTypeExpression(tree_ir.TypeExpression node) { 701 js.Expression visitTypeExpression(tree_ir.TypeExpression node) {
702 List<js.Expression> arguments = visitExpressionList(node.arguments); 702 List<js.Expression> arguments = visitExpressionList(node.arguments);
703 return glue.generateTypeRepresentation(node.dartType, arguments); 703 return glue.generateTypeRepresentation(node.dartType, arguments);
704 } 704 }
705 705
706 js.Node handleForeignCode(tree_ir.ForeignCode node) {
707 registry.registerStaticUse(node.dependency);
708 return node.codeTemplate.instantiate(visitExpressionList(node.arguments));
709 }
710
711 @override
712 js.Expression visitForeignExpression(tree_ir.ForeignExpression node) {
713 return handleForeignCode(node);
714 }
715
716 @override
717 visitForeignStatement(tree_ir.ForeignStatement node) {
718 return handleForeignCode(node);
719 }
720
721 @override 706 @override
722 js.Expression visitApplyBuiltinOperator(tree_ir.ApplyBuiltinOperator node) { 707 js.Expression visitApplyBuiltinOperator(tree_ir.ApplyBuiltinOperator node) {
723 List<js.Expression> args = visitExpressionList(node.arguments); 708 List<js.Expression> args = visitExpressionList(node.arguments);
724 switch (node.operator) { 709 switch (node.operator) {
725 case BuiltinOperator.NumAdd: 710 case BuiltinOperator.NumAdd:
726 return new js.Binary('+', args[0], args[1]); 711 return new js.Binary('+', args[0], args[1]);
727 case BuiltinOperator.NumSubtract: 712 case BuiltinOperator.NumSubtract:
728 return new js.Binary('-', args[0], args[1]); 713 return new js.Binary('-', args[0], args[1]);
729 case BuiltinOperator.NumMultiply: 714 case BuiltinOperator.NumMultiply:
730 return new js.Binary('*', args[0], args[1]); 715 return new js.Binary('*', args[0], args[1]);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return js.js("typeof # === 'number' && Math.floor(#) === #", args); 747 return js.js("typeof # === 'number' && Math.floor(#) === #", args);
763 } 748 }
764 } 749 }
765 750
766 visitFunctionExpression(tree_ir.FunctionExpression node) { 751 visitFunctionExpression(tree_ir.FunctionExpression node) {
767 // FunctionExpressions are currently unused. 752 // FunctionExpressions are currently unused.
768 // We might need them if we want to emit raw JS nested functions. 753 // We might need them if we want to emit raw JS nested functions.
769 throw 'FunctionExpressions should not be used'; 754 throw 'FunctionExpressions should not be used';
770 } 755 }
771 } 756 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/js_tree_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698