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

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

Issue 11602016: Emit classes using ASTs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
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 StringBuffer buffer; 8 StringBuffer buffer;
9 List<CodeBufferMarker> markers; 9 List<CodeBufferMarker> markers;
10 int lastBufferOffset = 0; 10 int lastBufferOffset = 0;
(...skipping 27 matching lines...) Expand all
38 CodeBufferMarker firstMarker = other.markers[0]; 38 CodeBufferMarker firstMarker = other.markers[0];
39 int offsetDelta = 39 int offsetDelta =
40 buffer.length + firstMarker.offsetDelta - lastBufferOffset; 40 buffer.length + firstMarker.offsetDelta - lastBufferOffset;
41 markers.add(new CodeBufferMarker(offsetDelta, 41 markers.add(new CodeBufferMarker(offsetDelta,
42 firstMarker.sourcePosition)); 42 firstMarker.sourcePosition));
43 for (int i = 1; i < other.markers.length; ++i) { 43 for (int i = 1; i < other.markers.length; ++i) {
44 markers.add(other.markers[i]); 44 markers.add(other.markers[i]);
45 } 45 }
46 lastBufferOffset = buffer.length + other.lastBufferOffset; 46 lastBufferOffset = buffer.length + other.lastBufferOffset;
47 } 47 }
48 buffer.add(other.toString()); 48 buffer.add(other.getText());
49 } 49 }
50 50
51 CodeBuffer addAll(Collection<Object> objects) { 51 CodeBuffer addAll(Collection<Object> objects) {
52 for (Object obj in objects) { 52 for (Object obj in objects) {
53 add(obj); 53 add(obj);
54 } 54 }
55 return this; 55 return this;
56 } 56 }
57 57
58 CodeBuffer addCharCode(int charCode) { 58 CodeBuffer addCharCode(int charCode) {
59 return add(new String.fromCharCodes([charCode])); 59 return add(new String.fromCharCodes([charCode]));
60 } 60 }
61 61
62 CodeBuffer clear() { 62 CodeBuffer clear() {
63 buffer.clear(); 63 buffer.clear();
64 markers.clear(); 64 markers.clear();
65 lastBufferOffset = 0; 65 lastBufferOffset = 0;
66 return this; 66 return this;
67 } 67 }
68 68
69 String toString() { 69 String toString() {
70 throw "Don't use CodeBuffer.toString() since it drops sourcemap data.";
71 }
72
73 String getText() {
70 return buffer.toString(); 74 return buffer.toString();
71 } 75 }
72 76
73 void beginMappedRange() { 77 void beginMappedRange() {
74 ++mappedRangeCounter; 78 ++mappedRangeCounter;
75 } 79 }
76 80
77 void endMappedRange() { 81 void endMappedRange() {
78 assert(mappedRangeCounter > 0); 82 assert(mappedRangeCounter > 0);
79 --mappedRangeCounter; 83 --mappedRangeCounter;
(...skipping 13 matching lines...) Expand all
93 }); 97 });
94 } 98 }
95 } 99 }
96 100
97 class CodeBufferMarker { 101 class CodeBufferMarker {
98 final int offsetDelta; 102 final int offsetDelta;
99 final sourcePosition; 103 final sourcePosition;
100 104
101 CodeBufferMarker(this.offsetDelta, this.sourcePosition); 105 CodeBufferMarker(this.offsetDelta, this.sourcePosition);
102 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698