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

Side by Side Diff: pkg/compiler/lib/src/closure.dart

Issue 1892093003: Support deserialized compilation of the empty program. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments Created 4 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 closureToClassMapper; 5 library closureToClassMapper;
6 6
7 import 'common.dart'; 7 import 'common.dart';
8 import 'common/names.dart' show Identifiers; 8 import 'common/names.dart' show Identifiers;
9 import 'common/resolution.dart' show Parsing, Resolution; 9 import 'common/resolution.dart' show Parsing, Resolution;
10 import 'common/tasks.dart' show CompilerTask; 10 import 'common/tasks.dart' show CompilerTask;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 bool get hasNode => false; 124 bool get hasNode => false;
125 125
126 Node get node { 126 Node get node {
127 throw new SpannableAssertionFailure( 127 throw new SpannableAssertionFailure(
128 local, 'Should not access node of ClosureFieldElement.'); 128 local, 'Should not access node of ClosureFieldElement.');
129 } 129 }
130 130
131 bool get hasResolvedAst => hasTreeElements; 131 bool get hasResolvedAst => hasTreeElements;
132 132
133 ResolvedAst get resolvedAst { 133 ResolvedAst get resolvedAst {
134 return new ParsedResolvedAst(this, null, treeElements); 134 return new ParsedResolvedAst(this, null, null, treeElements);
135 } 135 }
136 136
137 Expression get initializer { 137 Expression get initializer {
138 throw new SpannableAssertionFailure( 138 throw new SpannableAssertionFailure(
139 local, 'Should not access initializer of ClosureFieldElement.'); 139 local, 'Should not access initializer of ClosureFieldElement.');
140 } 140 }
141 141
142 bool get isInstanceMember => true; 142 bool get isInstanceMember => true;
143 bool get isAssignable => false; 143 bool get isAssignable => false;
144 144
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return closureClass.methodElement.memberContext; 339 return closureClass.methodElement.memberContext;
340 } 340 }
341 341
342 bool get hasNode => expression.hasNode; 342 bool get hasNode => expression.hasNode;
343 343
344 FunctionExpression get node => expression.node; 344 FunctionExpression get node => expression.node;
345 345
346 FunctionExpression parseNode(Parsing parsing) => node; 346 FunctionExpression parseNode(Parsing parsing) => node;
347 347
348 ResolvedAst get resolvedAst { 348 ResolvedAst get resolvedAst {
349 return new ParsedResolvedAst(this, node, treeElements); 349 return new ParsedResolvedAst(this, node, node.body, treeElements);
350 } 350 }
351 351
352 Element get analyzableElement => closureClass.methodElement.analyzableElement; 352 Element get analyzableElement => closureClass.methodElement.analyzableElement;
353 353
354 accept(ElementVisitor visitor, arg) { 354 accept(ElementVisitor visitor, arg) {
355 return visitor.visitMethodElement(this, arg); 355 return visitor.visitMethodElement(this, arg);
356 } 356 }
357 } 357 }
358 358
359 // The box-element for a scope, and the captured variables that need to be 359 // The box-element for a scope, and the captured variables that need to be
(...skipping 12 matching lines...) Expand all
372 bool hasBoxedLoopVariables() => !boxedLoopVariables.isEmpty; 372 bool hasBoxedLoopVariables() => !boxedLoopVariables.isEmpty;
373 373
374 bool isCapturedVariable(VariableElement variable) { 374 bool isCapturedVariable(VariableElement variable) {
375 return capturedVariables.containsKey(variable); 375 return capturedVariables.containsKey(variable);
376 } 376 }
377 377
378 void forEachCapturedVariable( 378 void forEachCapturedVariable(
379 f(LocalVariableElement variable, BoxFieldElement boxField)) { 379 f(LocalVariableElement variable, BoxFieldElement boxField)) {
380 capturedVariables.forEach(f); 380 capturedVariables.forEach(f);
381 } 381 }
382
383 String toString() {
sra1 2016/04/19 03:07:30 I prefer toString() methods to print so that they
Johnni Winther 2016/04/19 07:22:23 Will do in a follow-up.
384 StringBuffer sb = new StringBuffer();
385 if (boxElement != null) {
386 sb.write('box=$boxElement');
387 }
388 if (boxedLoopVariables.isNotEmpty) {
389 if (sb.isNotEmpty) {
390 sb.write(',');
391 }
sra1 2016/04/19 03:07:30 I usually do this like so: var separator = '';
Johnni Winther 2016/04/19 07:22:23 Will do in a follow-up.
392 sb.write('boxedLoopVariables=${boxedLoopVariables}');
393 }
394 if (capturedVariables.isNotEmpty) {
395 if (sb.isNotEmpty) {
396 sb.write(',');
397 }
398 sb.write('capturedVariables=');
399 capturedVariables.forEach((Local local, BoxFieldElement field) {
sra1 2016/04/19 03:07:30 Might as well just print the map.
Johnni Winther 2016/04/19 07:22:23 Some of the default toString implementations print
400 sb.write('$local->${field} ');
401 });
402 }
403 return sb.toString();
404 }
382 } 405 }
383 406
384 class ClosureClassMap { 407 class ClosureClassMap {
385 // The closure's element before any translation. Will be null for methods. 408 // The closure's element before any translation. Will be null for methods.
386 final LocalFunctionElement closureElement; 409 final LocalFunctionElement closureElement;
387 // The closureClassElement will be null for methods that are not local 410 // The closureClassElement will be null for methods that are not local
388 // closures. 411 // closures.
389 final ClosureClassElement closureClassElement; 412 final ClosureClassElement closureClassElement;
390 // The callElement will be null for methods that are not local closures. 413 // The callElement will be null for methods that are not local closures.
391 final FunctionElement callElement; 414 final FunctionElement callElement;
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 /// 1169 ///
1147 /// Move the below classes to a JS model eventually. 1170 /// Move the below classes to a JS model eventually.
1148 /// 1171 ///
1149 abstract class JSEntity implements Entity { 1172 abstract class JSEntity implements Entity {
1150 Entity get declaredEntity; 1173 Entity get declaredEntity;
1151 } 1174 }
1152 1175
1153 abstract class PrivatelyNamedJSEntity implements JSEntity { 1176 abstract class PrivatelyNamedJSEntity implements JSEntity {
1154 Entity get rootOfScope; 1177 Entity get rootOfScope;
1155 } 1178 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/common/backend_api.dart » ('j') | pkg/compiler/lib/src/compiler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698