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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/code_buffer.dart

Issue 259643002: Don't emit repeated null SourceLocations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 dart2js; 5 part of dart2js;
6 6
7 class CodeBuffer implements StringBuffer { 7 class CodeBuffer implements StringBuffer {
8 8
9 StringBuffer buffer = new StringBuffer(); 9 StringBuffer buffer = new StringBuffer();
10 List<CodeBufferMarker> markers = new List<CodeBufferMarker>(); 10 List<CodeBufferMarker> markers = new List<CodeBufferMarker>();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void beginMappedRange() { 97 void beginMappedRange() {
98 ++mappedRangeCounter; 98 ++mappedRangeCounter;
99 } 99 }
100 100
101 void endMappedRange() { 101 void endMappedRange() {
102 assert(mappedRangeCounter > 0); 102 assert(mappedRangeCounter > 0);
103 --mappedRangeCounter; 103 --mappedRangeCounter;
104 } 104 }
105 105
106 void setSourceLocation(var sourcePosition) { 106 void setSourceLocation(var sourcePosition) {
107 if (sourcePosition == null) {
108 if (markers.length > 0 && markers.last.sourcePosition == null) return;
109 }
107 int offsetDelta = buffer.length - lastBufferOffset; 110 int offsetDelta = buffer.length - lastBufferOffset;
108 markers.add(new CodeBufferMarker(offsetDelta, sourcePosition)); 111 markers.add(new CodeBufferMarker(offsetDelta, sourcePosition));
109 lastBufferOffset = buffer.length; 112 lastBufferOffset = buffer.length;
110 } 113 }
111 114
112 void forEachSourceLocation(void f(int targetOffset, var sourcePosition)) { 115 void forEachSourceLocation(void f(int targetOffset, var sourcePosition)) {
113 int targetOffset = 0; 116 int targetOffset = 0;
114 markers.forEach((marker) { 117 markers.forEach((marker) {
115 targetOffset += marker.offsetDelta; 118 targetOffset += marker.offsetDelta;
116 f(targetOffset, marker.sourcePosition); 119 f(targetOffset, marker.sourcePosition);
117 }); 120 });
118 } 121 }
119 } 122 }
120 123
121 class CodeBufferMarker { 124 class CodeBufferMarker {
122 final int offsetDelta; 125 final int offsetDelta;
123 final sourcePosition; 126 final sourcePosition;
124 127
125 CodeBufferMarker(this.offsetDelta, this.sourcePosition); 128 CodeBufferMarker(this.offsetDelta, this.sourcePosition);
126 } 129 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698