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

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

Issue 831133004: Use closure conversion in new dart2js backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/closure.dart » ('j') | pkg/compiler/lib/src/closure.dart » ('J')
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 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 Source get currentSource => element.source; 58 Source get currentSource => element.source;
59 59
60 analyzer.LibraryElement get currentLibrary => element.library; 60 analyzer.LibraryElement get currentLibrary => element.library;
61 61
62 ir.Node visit(AstNode node) => node.accept(this); 62 ir.Node visit(AstNode node) => node.accept(this);
63 63
64 ir.FieldDefinition handleFieldDeclaration( 64 ir.FieldDefinition handleFieldDeclaration(
65 analyzer.PropertyInducingElement field, VariableDeclaration node) { 65 analyzer.PropertyInducingElement field, VariableDeclaration node) {
66 dart2js.FieldElement element = converter.convertElement(field); 66 dart2js.FieldElement element = converter.convertElement(field);
67 return withBuilder( 67 return withBuilder(
68 new IrBuilder(DART_CONSTANT_SYSTEM, 68 new DartIrBuilder(DART_CONSTANT_SYSTEM,
69 element, 69 element,
Kevin Millikin (Google) 2015/01/13 08:25:36 The arguments were aligned before, now they're off
asgerf 2015/01/13 10:04:26 Thanks
70 // TODO(johnniwinther): Supported closure variables. 70 // TODO(johnniwinther): Supported closure variables.
71 const <dart2js.Local>[]), 71 new NullClosureVariableInfo()),
72 () { 72 () {
73 irBuilder.beginField();
73 ir.Primitive initializer = build(node.initializer); 74 ir.Primitive initializer = build(node.initializer);
74 return irBuilder.makeFieldDefinition(initializer); 75 return irBuilder.makeFieldDefinition(initializer);
75 }); 76 });
76 } 77 }
77 78
78 ir.FunctionDefinition handleFunctionDeclaration( 79 ir.FunctionDefinition handleFunctionDeclaration(
79 analyzer.FunctionElement function, FunctionExpression node) { 80 analyzer.FunctionElement function, FunctionExpression node) {
80 dart2js.FunctionElement element = converter.convertElement(function); 81 dart2js.FunctionElement element = converter.convertElement(function);
81 return withBuilder( 82 return withBuilder(
82 new IrBuilder(DART_CONSTANT_SYSTEM, 83 new DartIrBuilder(DART_CONSTANT_SYSTEM,
83 element, 84 element,
Kevin Millikin (Google) 2015/01/13 08:25:36 Same: 4-space indent.
84 // TODO(johnniwinther): Supported closure variables. 85 // TODO(johnniwinther): Supported closure variables.
85 const <dart2js.Local>[]), 86 new NullClosureVariableInfo()),
86 () { 87 () {
87 function.parameters.forEach((analyzer.ParameterElement parameter) { 88 irBuilder.beginFunction(
88 // TODO(johnniwinther): Support "closure variables", that is variables 89 function.parameters.map(converter.convertElement));
89 // accessed from an inner function.
90 irBuilder.createFunctionParameter(converter.convertElement(parameter));
91 });
92 // Visit the body directly to avoid processing the signature as 90 // Visit the body directly to avoid processing the signature as
93 // expressions. 91 // expressions.
94 visit(node.body); 92 visit(node.body);
95 return irBuilder.makeFunctionDefinition(const []); 93 return irBuilder.makeFunctionDefinition(const []);
96 }); 94 });
97 } 95 }
98 96
99 @override 97 @override
100 ir.Primitive visitFunctionExpression(FunctionExpression node) { 98 ir.Primitive visitFunctionExpression(FunctionExpression node) {
101 return irBuilder.buildFunctionExpression( 99 return irBuilder.buildFunctionExpression(
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 512 }
515 513
516 @override 514 @override
517 ir.Primitive visitAsExpression(AsExpression node) { 515 ir.Primitive visitAsExpression(AsExpression node) {
518 return irBuilder.buildTypeOperator( 516 return irBuilder.buildTypeOperator(
519 visit(node.expression), 517 visit(node.expression),
520 converter.convertType(node.type.type), 518 converter.convertType(node.type.type),
521 isTypeTest: false); 519 isTypeTest: false);
522 } 520 }
523 } 521 }
522
523 class NullClosureVariableInfo extends ClosureVariableInfo {
524 Iterable get capturedVariables => const [];
525 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/closure.dart » ('j') | pkg/compiler/lib/src/closure.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698