| 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);
|
|
|