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

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

Issue 764593002: Invoking constructors in js cps (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_basic.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 js.Expression visitConstant(tree_ir.Constant node) { 155 js.Expression visitConstant(tree_ir.Constant node) {
156 return buildConstant(node.expression.value); 156 return buildConstant(node.expression.value);
157 } 157 }
158 158
159 @override 159 @override
160 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) { 160 js.Expression visitFunctionExpression(tree_ir.FunctionExpression node) {
161 return giveup(node); 161 return giveup(node);
162 // TODO: implement visitFunctionExpression 162 // TODO: implement visitFunctionExpression
163 } 163 }
164 164
165 js.Expression buildStaticInvoke(Selector selector,
166 Element target,
167 List<tree_ir.Expression> arguments) {
168
karlklose 2014/11/26 14:27:29 Remove line.
sigurdm 2014/11/26 14:49:52 Done.
169 registry.registerStaticInvocation(target.declaration);
170
171 js.Expression compileConstant(ParameterElement parameter) {
karlklose 2014/11/26 14:27:29 Make that a member? It is currently only used here
sigurdm 2014/11/26 14:49:52 Done.
172 return buildConstant(glue.getConstantForVariable(parameter).value);
173 }
174
175 js.Expression elementAccess = glue.elementAccess(target);
176 List<js.Expression> compiledArguments =
177 selector.makeArgumentsList(arguments, target.implementation,
karlklose 2014/11/26 14:27:29 I think this should also have four spaces indentat
sigurdm 2014/11/26 14:49:52 Done.
178 visitExpression,
179 compileConstant);
180 return new js.Call(elementAccess, compiledArguments);
181 }
182
165 @override 183 @override
166 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { 184 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
167 return giveup(node); 185 if (node.constant != null) return giveup(node);
168 // TODO: implement visitInvokeConstructor 186 return buildStaticInvoke(node.selector, node.target, node.arguments);
karlklose 2014/11/26 14:27:29 Is there a common superclass of InvokeConstructor
sigurdm 2014/11/26 14:49:52 There is `Invoke` but it is also common with Invok
169 } 187 }
170 188
171 @override 189 @override
172 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { 190 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) {
173 return giveup(node); 191 return giveup(node);
174 // TODO: implement visitInvokeMethod 192 // TODO: implement visitInvokeMethod
175 } 193 }
176 194
177 @override 195 @override
178 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { 196 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) {
179 Element element = node.target; 197 return buildStaticInvoke(node.selector, node.target, node.arguments);
180
181 registry.registerStaticInvocation(element.declaration);
182
183 js.Expression compileConstant(ParameterElement parameter) {
184 return buildConstant(glue.getConstantForVariable(parameter).value);
185 }
186
187 js.Expression elementAccess = glue.elementAccess(node.target);
188 List<js.Expression> arguments =
189 node.selector.makeArgumentsList(node.arguments, element.implementation,
190 visitExpression,
191 compileConstant);
192 return new js.Call(elementAccess, arguments);
193 } 198 }
194 199
195 @override 200 @override
196 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { 201 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) {
197 return giveup(node); 202 return giveup(node);
198 // TODO: implement visitInvokeSuperMethod 203 // TODO: implement visitInvokeSuperMethod
199 } 204 }
200 205
201 @override 206 @override
202 js.Expression visitLiteralList(tree_ir.LiteralList node) { 207 js.Expression visitLiteralList(tree_ir.LiteralList node) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 accumulator.add( 376 accumulator.add(
372 buildWhile(new js.LiteralBool(true), node.body, node.label, node)); 377 buildWhile(new js.LiteralBool(true), node.body, node.label, node));
373 } 378 }
374 379
375 @override 380 @override
376 void visitReturn(tree_ir.Return node) { 381 void visitReturn(tree_ir.Return node) {
377 accumulator.add(new js.Return(visitExpression(node.value))); 382 accumulator.add(new js.Return(visitExpression(node.value)));
378 } 383 }
379 384
380 } 385 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_basic.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698