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

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

Issue 742023002: Handle named and optional arguments in cps-ir. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix formatting Created 6 years, 1 month 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 | Annotate | Revision Log
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 '../../js/js.dart' as js; 10 import '../../js/js.dart' as js;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 @override 137 @override
138 js.Expression visitConditional(tree_ir.Conditional node) { 138 js.Expression visitConditional(tree_ir.Conditional node) {
139 return new js.Conditional( 139 return new js.Conditional(
140 visit(node.condition), 140 visit(node.condition),
141 visit(node.thenExpression), 141 visit(node.thenExpression),
142 visit(node.elseExpression)); 142 visit(node.elseExpression));
143 } 143 }
144 144
145 js.Expression buildConstant(ConstantValue constant) {
146 registry.registerCompileTimeConstant(constant);
147 return glue.constantReference(constant);
148 }
149
145 @override 150 @override
146 js.Expression visitConstant(tree_ir.Constant node) { 151 js.Expression visitConstant(tree_ir.Constant node) {
147 ConstantValue constant = node.expression.value; 152 return buildConstant(node.expression.value);
148 registry.registerCompileTimeConstant(constant);
149 return glue.constantReference(constant);
150 } 153 }
151 154
152 @override 155 @override
153 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) { 156 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) {
154 return giveup(node); 157 return giveup(node);
155 // TODO: implement visitFunctionExpression 158 // TODO: implement visitFunctionExpression
156 } 159 }
157 160
158 @override 161 @override
159 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { 162 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
160 return giveup(node); 163 return giveup(node);
161 // TODO: implement visitInvokeConstructor 164 // TODO: implement visitInvokeConstructor
162 } 165 }
163 166
164 @override 167 @override
165 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { 168 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) {
166 return giveup(node); 169 return giveup(node);
167 // TODO: implement visitInvokeMethod 170 // TODO: implement visitInvokeMethod
168 } 171 }
169 172
170 @override 173 @override
171 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { 174 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) {
172 Element element = node.target; 175 Element element = node.target;
173 176
174 registry.registerStaticInvocation(element); 177 registry.registerStaticInvocation(element.declaration);
178
179 js.Expression compileConstant(ParameterElement parameter) {
180 return buildConstant(glue.getConstantForVariable(parameter).value);
181 }
175 182
176 js.Expression elementAccess = glue.elementAccess(node.target); 183 js.Expression elementAccess = glue.elementAccess(node.target);
177 return new js.Call(elementAccess, visitArguments(node.arguments)); 184 List<js.Expression> arguments =
185 node.selector.makeArgumentsList(node.arguments, element.implementation,
186 visitExpression,
187 compileConstant);
188 return new js.Call(elementAccess, arguments);
178 } 189 }
179 190
180 @override 191 @override
181 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { 192 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) {
182 return giveup(node); 193 return giveup(node);
183 // TODO: implement visitInvokeSuperMethod 194 // TODO: implement visitInvokeSuperMethod
184 } 195 }
185 196
186 @override 197 @override
187 js.Expression visitLiteralList(tree_ir.LiteralList node) { 198 js.Expression visitLiteralList(tree_ir.LiteralList node) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 304 }
294 305
295 @override 306 @override
296 void visitReturn(tree_ir.Return node) { 307 void visitReturn(tree_ir.Return node) {
297 accumulator.add(new js.Return(visitExpression(node.value))); 308 accumulator.add(new js.Return(visitExpression(node.value)));
298 } 309 }
299 310
300 bool isNullLiteral(js.Expression exp) => exp is js.LiteralNull; 311 bool isNullLiteral(js.Expression exp) => exp is js.LiteralNull;
301 312
302 } 313 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compile_time_constants.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698