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

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

Issue 1083043002: cps-ir: Register instantiated type at InvokeConstructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return new js.Call(elementAccess, arguments, 232 return new js.Call(elementAccess, arguments,
233 sourceInformation: sourceInformation); 233 sourceInformation: sourceInformation);
234 } 234 }
235 } 235 }
236 236
237 @override 237 @override
238 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { 238 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
239 checkStaticTargetIsValid(node, node.target); 239 checkStaticTargetIsValid(node, node.target);
240 if (node.constant != null) return giveup(node); 240 if (node.constant != null) return giveup(node);
241 241
242 ClassElement instantiatedClass = node.target.enclosingClass; 242 registry.registerInstantiatedType(node.type);
243 registry.registerInstantiatedClass(instantiatedClass);
244 Selector selector = node.selector; 243 Selector selector = node.selector;
245 FunctionElement target = node.target; 244 FunctionElement target = node.target;
246 List<js.Expression> arguments = visitArguments(node.arguments); 245 List<js.Expression> arguments = visitArguments(node.arguments);
247 return buildStaticInvoke(selector, target, arguments); 246 return buildStaticInvoke(selector, target, arguments);
248 } 247 }
249 248
250 void registerMethodInvoke(tree_ir.InvokeMethod node) { 249 void registerMethodInvoke(tree_ir.InvokeMethod node) {
251 Selector selector = node.selector; 250 Selector selector = node.selector;
252 if (selector.isGetter) { 251 if (selector.isGetter) {
253 registry.registerDynamicGetter(selector); 252 registry.registerDynamicGetter(selector);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 522 }
524 523
525 @override 524 @override
526 js.Expression visitCreateBox(tree_ir.CreateBox node) { 525 js.Expression visitCreateBox(tree_ir.CreateBox node) {
527 return new js.ObjectInitializer([]); 526 return new js.ObjectInitializer([]);
528 } 527 }
529 528
530 @override 529 @override
531 js.Expression visitCreateInstance(tree_ir.CreateInstance node) { 530 js.Expression visitCreateInstance(tree_ir.CreateInstance node) {
532 ClassElement cls = node.classElement; 531 ClassElement cls = node.classElement;
532 // TODO(asgerf): To allow inlining of InvokeConstructor, CreateInstance must
533 // carry a DartType so we can register the instantiated type
534 // with its type arguments. Otherwise dataflow analysis is
535 // needed to reconstruct the instantiated type.
533 registry.registerInstantiatedClass(cls); 536 registry.registerInstantiatedClass(cls);
534 js.Expression instance = new js.New( 537 js.Expression instance = new js.New(
535 glue.constructorAccess(cls), 538 glue.constructorAccess(cls),
536 node.arguments.map(visitExpression).toList()); 539 node.arguments.map(visitExpression).toList());
537 540
538 List<tree_ir.Expression> typeInformation = node.typeInformation; 541 List<tree_ir.Expression> typeInformation = node.typeInformation;
539 assert(typeInformation.isEmpty || 542 assert(typeInformation.isEmpty ||
540 typeInformation.length == cls.typeVariables.length); 543 typeInformation.length == cls.typeVariables.length);
541 if (typeInformation.isNotEmpty) { 544 if (typeInformation.isNotEmpty) {
542 FunctionElement helper = glue.getAddRuntimeTypeInformation(); 545 FunctionElement helper = glue.getAddRuntimeTypeInformation();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 626
624 @override 627 @override
625 visitVariableDeclaration(tree_ir.VariableDeclaration node) { 628 visitVariableDeclaration(tree_ir.VariableDeclaration node) {
626 return errorUnsupportedNode(node); 629 return errorUnsupportedNode(node);
627 } 630 }
628 631
629 errorUnsupportedNode(tree_ir.DartSpecificNode node) { 632 errorUnsupportedNode(tree_ir.DartSpecificNode node) {
630 throw "Unsupported node in JS backend: $node"; 633 throw "Unsupported node in JS backend: $node";
631 } 634 }
632 } 635 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698