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

Side by Side Diff: pkg/compiler/lib/src/js/printer.dart

Issue 893963005: Refactor handling of source map information. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 10 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 | « pkg/compiler/lib/src/js/nodes.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/task.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) 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 part of js; 5 part of js;
6 6
7 class Printer extends Indentation implements NodeVisitor { 7 class Printer extends Indentation implements NodeVisitor {
8 final bool shouldCompressOutput; 8 final bool shouldCompressOutput;
9 leg.DiagnosticListener diagnosticListener; 9 leg.DiagnosticListener diagnosticListener;
10 CodeBuffer outBuffer; 10 CodeBuffer outBuffer;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 void outIndent(String str) { indent(); out(str); } 106 void outIndent(String str) { indent(); out(str); }
107 void outIndentLn(String str) { indent(); outLn(str); } 107 void outIndentLn(String str) { indent(); outLn(str); }
108 void indent() { 108 void indent() {
109 if (!shouldCompressOutput) { 109 if (!shouldCompressOutput) {
110 out(indentation); 110 out(indentation);
111 } 111 }
112 } 112 }
113 113
114 void beginSourceRange(Node node) { 114 void beginSourceRange(Node node) {
115 if (node.sourcePosition != null) { 115 if (node.sourceInformation != null) {
116 outBuffer.beginMappedRange(); 116 node.sourceInformation.beginMapping(outBuffer);
117 outBuffer.setSourceLocation(node.sourcePosition);
118 } 117 }
119 } 118 }
120 119
121 void endSourceRange(Node node) { 120 void endSourceRange(Node node) {
122 if (node.endSourcePosition != null) { 121 if (node.sourceInformation != null) {
123 outBuffer.setSourceLocation(node.endSourcePosition); 122 node.sourceInformation.endMapping(outBuffer);
124 }
125 if (node.sourcePosition != null) {
126 outBuffer.endMappedRange();
127 } 123 }
128 } 124 }
129 125
130 visit(Node node) { 126 visit(Node node) {
131 beginSourceRange(node); 127 beginSourceRange(node);
132 if (monitor != null) monitor.enteringAst(node, outBuffer.length); 128 if (monitor != null) monitor.enteringAst(node, outBuffer.length);
133 129
134 node.accept(this); 130 node.accept(this);
135 131
136 if (monitor != null) monitor.exitingAst(node, outBuffer.length); 132 if (monitor != null) monitor.exitingAst(node, outBuffer.length);
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); 1185 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS));
1190 } 1186 }
1191 codes.add(charCodes.$0 + digit); 1187 codes.add(charCodes.$0 + digit);
1192 newName = new String.fromCharCodes(codes); 1188 newName = new String.fromCharCodes(codes);
1193 } 1189 }
1194 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); 1190 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName));
1195 maps.last[oldName] = newName; 1191 maps.last[oldName] = newName;
1196 return newName; 1192 return newName;
1197 } 1193 }
1198 } 1194 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js/nodes.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698