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

Side by Side Diff: pkg/analyzer2dart/lib/src/cps_generator.dart

Issue 900403003: Support default constructors in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
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 analyzer2dart.cps_generator; 5 library analyzer2dart.cps_generator;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 8
9 import 'package:compiler/src/dart_types.dart' as dart2js; 9 import 'package:compiler/src/dart_types.dart' as dart2js;
10 import 'package:compiler/src/elements/elements.dart' as dart2js; 10 import 'package:compiler/src/elements/elements.dart' as dart2js;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 ir.FieldDefinition visitTopLevelVariableElement( 49 ir.FieldDefinition visitTopLevelVariableElement(
50 analyzer.TopLevelVariableElement element) { 50 analyzer.TopLevelVariableElement element) {
51 CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter, element); 51 CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter, element);
52 VariableDeclaration variableDeclaration = node; 52 VariableDeclaration variableDeclaration = node;
53 return visitor.handleFieldDeclaration(element, variableDeclaration); 53 return visitor.handleFieldDeclaration(element, variableDeclaration);
54 } 54 }
55 55
56 @override 56 @override
57 ir.ExecutableDefinition visitConstructorElement( 57 ir.ExecutableDefinition visitConstructorElement(
58 analyzer.ConstructorElement element) { 58 analyzer.ConstructorElement element) {
59 if (element.isSynthetic) {
60 // Don't generate CPS for synthetic (default) constructors.
sigurdm 2015/02/10 09:37:56 For the js-case it makes sense to represent these
Johnni Winther 2015/02/10 13:51:57 Reverted.
61 return null;
62 }
59 CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter, element); 63 CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter, element);
60 if (!element.isFactory) { 64 if (!element.isFactory) {
61 ConstructorDeclaration constructorDeclaration = node; 65 ConstructorDeclaration constructorDeclaration = node;
62 FunctionBody body; 66 return visitor.handleConstructorDeclaration(element,
63 if (constructorDeclaration != null) { 67 constructorDeclaration.body);
64 body = constructorDeclaration.body;
65 } else {
66 assert(element.isSynthetic);
67 }
68 return visitor.handleConstructorDeclaration(element, body);
69 } 68 }
70 // TODO(johnniwinther): Support factory constructors. 69 // TODO(johnniwinther): Support factory constructors.
71 return null; 70 return null;
72 } 71 }
73 } 72 }
74 73
75 /// Visitor that converts analyzer AST nodes into CPS ir nodes. 74 /// Visitor that converts analyzer AST nodes into CPS ir nodes.
76 class CpsGeneratingVisitor extends SemanticVisitor<ir.Node> 75 class CpsGeneratingVisitor extends SemanticVisitor<ir.Node>
77 with IrBuilderMixin<AstNode> { 76 with IrBuilderMixin<AstNode> {
78 /// Promote the type of [irBuilder] to [DartIrBuilder]. 77 /// Promote the type of [irBuilder] to [DartIrBuilder].
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return irBuilder.buildTypeOperator( 568 return irBuilder.buildTypeOperator(
570 visit(node.expression), 569 visit(node.expression),
571 converter.convertType(node.type.type), 570 converter.convertType(node.type.type),
572 isTypeTest: false); 571 isTypeTest: false);
573 } 572 }
574 } 573 }
575 574
576 class NullCapturedVariableInfo extends DartCapturedVariableInfo { 575 class NullCapturedVariableInfo extends DartCapturedVariableInfo {
577 Iterable get capturedVariables => const []; 576 Iterable get capturedVariables => const [];
578 } 577 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698