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

Side by Side Diff: pkg/kernel/lib/text/ast_to_text.dart

Issue 2610133002: Non-format-changing kernel offset changes (Closed)
Patch Set: Changed offset variable introduced in various methods in accessors.dart to a named parameter with d… Created 3 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
« no previous file with comments | « pkg/kernel/lib/kernel.dart ('k') | pkg/kernel/lib/transformations/async.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.ast_to_text; 4 library kernel.ast_to_text;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../import_table.dart'; 7 import '../import_table.dart';
8 import '../type_propagation/type_propagation.dart'; 8 import '../type_propagation/type_propagation.dart';
9 9
10 class Namer<T> { 10 class Namer<T> {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 /// A quick and dirty ambiguous text printer. 175 /// A quick and dirty ambiguous text printer.
176 class Printer extends Visitor<Null> { 176 class Printer extends Visitor<Null> {
177 final NameSystem syntheticNames; 177 final NameSystem syntheticNames;
178 final StringSink sink; 178 final StringSink sink;
179 final Annotator annotator; 179 final Annotator annotator;
180 ImportTable importTable; 180 ImportTable importTable;
181 int indentation = 0; 181 int indentation = 0;
182 int column = 0; 182 int column = 0;
183 bool showExternal; 183 bool showExternal;
184 bool showOffsets;
184 185
185 static int SPACE = 0; 186 static int SPACE = 0;
186 static int WORD = 1; 187 static int WORD = 1;
187 static int SYMBOL = 2; 188 static int SYMBOL = 2;
188 int state = SPACE; 189 int state = SPACE;
189 190
190 Printer(this.sink, 191 Printer(this.sink,
191 {NameSystem syntheticNames, 192 {NameSystem syntheticNames,
192 this.showExternal, 193 this.showExternal,
194 this.showOffsets,
193 this.importTable, 195 this.importTable,
194 this.annotator: const InferredValueAnnotator()}) 196 this.annotator: const InferredValueAnnotator()})
195 : this.syntheticNames = syntheticNames ?? new NameSystem(); 197 : this.syntheticNames = syntheticNames ?? new NameSystem();
196 198
197 Printer._inner(Printer parent, this.importTable) 199 Printer._inner(Printer parent, this.importTable)
198 : sink = parent.sink, 200 : sink = parent.sink,
199 syntheticNames = parent.syntheticNames, 201 syntheticNames = parent.syntheticNames,
200 annotator = parent.annotator, 202 annotator = parent.annotator,
201 showExternal = parent.showExternal; 203 showExternal = parent.showExternal,
204 showOffsets = parent.showOffsets;
202 205
203 String getLibraryName(Library node) { 206 String getLibraryName(Library node) {
204 return node.name ?? syntheticNames.nameLibrary(node); 207 return node.name ?? syntheticNames.nameLibrary(node);
205 } 208 }
206 209
207 String getLibraryReference(Library node) { 210 String getLibraryReference(Library node) {
208 if (node == null) return '<No Library>'; 211 if (node == null) return '<No Library>';
209 if (importTable != null && importTable.getImportIndex(node) != -1) { 212 if (importTable != null && importTable.getImportIndex(node) != -1) {
210 return syntheticNames.nameLibraryPrefix(node); 213 return syntheticNames.nameLibraryPrefix(node);
211 } 214 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (state == WORD) { 389 if (state == WORD) {
387 writeSpace(); 390 writeSpace();
388 } 391 }
389 } 392 }
390 393
391 void writeIndentation() { 394 void writeIndentation() {
392 writeSpace(' ' * indentation); 395 writeSpace(' ' * indentation);
393 } 396 }
394 397
395 void writeNode(Node node) { 398 void writeNode(Node node) {
399 if (showOffsets && node is TreeNode) {
400 writeWord("[${node.fileOffset}]");
401 }
396 node.accept(this); 402 node.accept(this);
397 } 403 }
398 404
399 void writeOptionalNode(Node node) { 405 void writeOptionalNode(Node node) {
400 if (node != null) { 406 if (node != null) {
401 node.accept(this); 407 node.accept(this);
402 } 408 }
403 } 409 }
404 410
405 void writeAnnotatedType(DartType type, String annotation) { 411 void writeAnnotatedType(DartType type, String annotation) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 endLine(); 485 endLine();
480 ++indentation; 486 ++indentation;
481 writeIndentation(); 487 writeIndentation();
482 writeComma(':'); 488 writeComma(':');
483 writeList(initializers, writeNode); 489 writeList(initializers, writeNode);
484 --indentation; 490 --indentation;
485 } 491 }
486 if (function.asyncMarker != AsyncMarker.Sync) { 492 if (function.asyncMarker != AsyncMarker.Sync) {
487 writeSpaced(getAsyncMarkerKeyword(function.asyncMarker)); 493 writeSpaced(getAsyncMarkerKeyword(function.asyncMarker));
488 } 494 }
495 if (!function.debuggable) writeSpaced("/* not debuggable */");
489 if (function.body != null) { 496 if (function.body != null) {
490 writeFunctionBody(function.body, terminateLine: terminateLine); 497 writeFunctionBody(function.body, terminateLine: terminateLine);
491 } else if (terminateLine) { 498 } else if (terminateLine) {
492 endLine(';'); 499 endLine(';');
493 } 500 }
494 } 501 }
495 502
496 String getAsyncMarkerKeyword(AsyncMarker marker) { 503 String getAsyncMarkerKeyword(AsyncMarker marker) {
497 switch (marker) { 504 switch (marker) {
498 case AsyncMarker.Sync: 505 case AsyncMarker.Sync:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 626
620 void writeVariableReference(VariableDeclaration variable) { 627 void writeVariableReference(VariableDeclaration variable) {
621 writeWord(getVariableReference(variable)); 628 writeWord(getVariableReference(variable));
622 } 629 }
623 630
624 void writeTypeParameterReference(TypeParameter node) { 631 void writeTypeParameterReference(TypeParameter node) {
625 writeWord(getTypeParameterReference(node)); 632 writeWord(getTypeParameterReference(node));
626 } 633 }
627 634
628 void writeExpression(Expression node, [int minimumPrecedence]) { 635 void writeExpression(Expression node, [int minimumPrecedence]) {
636 if (showOffsets) writeWord("[${node.fileOffset}]");
629 bool needsParenteses = false; 637 bool needsParenteses = false;
630 if (minimumPrecedence != null && getPrecedence(node) < minimumPrecedence) { 638 if (minimumPrecedence != null && getPrecedence(node) < minimumPrecedence) {
631 needsParenteses = true; 639 needsParenteses = true;
632 writeSymbol('('); 640 writeSymbol('(');
633 } 641 }
634 writeNode(node); 642 writeNode(node);
635 if (needsParenteses) { 643 if (needsParenteses) {
636 writeSymbol(')'); 644 writeSymbol(')');
637 } 645 }
638 } 646 }
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 } 1288 }
1281 1289
1282 visitFunctionDeclaration(FunctionDeclaration node) { 1290 visitFunctionDeclaration(FunctionDeclaration node) {
1283 writeIndentation(); 1291 writeIndentation();
1284 writeWord('function'); 1292 writeWord('function');
1285 writeFunction(node.function, name: getVariableName(node.variable)); 1293 writeFunction(node.function, name: getVariableName(node.variable));
1286 } 1294 }
1287 1295
1288 void writeVariableDeclaration(VariableDeclaration node, 1296 void writeVariableDeclaration(VariableDeclaration node,
1289 {bool useVarKeyword: false}) { 1297 {bool useVarKeyword: false}) {
1298 if (showOffsets) writeWord("[${node.fileOffset}]");
1290 writeModifier(node.isFinal, 'final'); 1299 writeModifier(node.isFinal, 'final');
1291 writeModifier(node.isConst, 'const'); 1300 writeModifier(node.isConst, 'const');
1292 if (node.type != null) { 1301 if (node.type != null) {
1293 writeAnnotatedType(node.type, annotator?.annotateVariable(this, node)); 1302 writeAnnotatedType(node.type, annotator?.annotateVariable(this, node));
1294 } 1303 }
1295 if (useVarKeyword && !node.isFinal && !node.isConst && node.type == null) { 1304 if (useVarKeyword && !node.isFinal && !node.isConst && node.type == null) {
1296 writeWord('var'); 1305 writeWord('var');
1297 } 1306 }
1298 writeWord(getVariableName(node)); 1307 writeWord(getVariableName(node));
1299 if (node.initializer != null) { 1308 if (node.initializer != null) {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 } 1544 }
1536 throw 'illegal ProcedureKind: $kind'; 1545 throw 'illegal ProcedureKind: $kind';
1537 } 1546 }
1538 1547
1539 class ExpressionPrinter { 1548 class ExpressionPrinter {
1540 final Printer writeer; 1549 final Printer writeer;
1541 final int minimumPrecedence; 1550 final int minimumPrecedence;
1542 1551
1543 ExpressionPrinter(this.writeer, this.minimumPrecedence); 1552 ExpressionPrinter(this.writeer, this.minimumPrecedence);
1544 } 1553 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/kernel.dart ('k') | pkg/kernel/lib/transformations/async.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698