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

Unified Diff: pkg/analyzer2dart/lib/src/cps_generator.dart

Issue 867233004: Support constructor declarations in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer2dart/lib/src/dart_backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer2dart/lib/src/cps_generator.dart
diff --git a/pkg/analyzer2dart/lib/src/cps_generator.dart b/pkg/analyzer2dart/lib/src/cps_generator.dart
index 03cc77a337d7eee4065719783d1ec99e1ac2e103..11c8a8417b892ac9c488be293eefd3f1e8ab9096 100644
--- a/pkg/analyzer2dart/lib/src/cps_generator.dart
+++ b/pkg/analyzer2dart/lib/src/cps_generator.dart
@@ -45,6 +45,19 @@ class CpsElementVisitor extends analyzer.SimpleElementVisitor<ir.Node> {
VariableDeclaration variableDeclaration = node;
return visitor.handleFieldDeclaration(element, variableDeclaration);
}
+
+ @override
+ ir.ExecutableDefinition visitConstructorElement(
+ analyzer.ConstructorElement element) {
+ CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter, element);
+ if (!element.isFactory) {
+ ConstructorDeclaration constructorDeclaration = node;
+ return visitor.handleConstructorDeclaration(
+ element, constructorDeclaration);
+ }
+ // TODO(johnniwinther): Support factory constructors.
+ return null;
+ }
}
/// Visitor that converts analyzer AST nodes into CPS ir nodes.
@@ -64,6 +77,25 @@ class CpsGeneratingVisitor extends SemanticVisitor<ir.Node>
ir.Node visit(AstNode node) => node.accept(this);
+ ir.ConstructorDefinition handleConstructorDeclaration(
+ analyzer.ConstructorElement constructor, ConstructorDeclaration node) {
+ FunctionBody body = node.body;
+ dart2js.ConstructorElement element = converter.convertElement(constructor);
+ return withBuilder(
+ new DartIrBuilder(DART_CONSTANT_SYSTEM,
+ element,
+ // TODO(johnniwinther): Supported closure variables.
+ new NullCapturedVariableInfo()),
+ () {
+ irBuilder.buildFunctionHeader(
+ constructor.parameters.map(converter.convertElement));
+ // Visit the body directly to avoid processing the signature as
+ // expressions.
+ visit(node.body);
+ return irBuilder.makeConstructorDefinition(const [], const []);
+ });
+ }
+
ir.FieldDefinition handleFieldDeclaration(
analyzer.PropertyInducingElement field, VariableDeclaration node) {
dart2js.FieldElement element = converter.convertElement(field);
« no previous file with comments | « no previous file | pkg/analyzer2dart/lib/src/dart_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698