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

Side by Side Diff: lib/compiler/implementation/source_map_builder.dart

Issue 10636003: Use JSON.printOn in SourceMapBuilder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 #library('source_map_builder'); 5 #library('source_map_builder');
6 6
7 #import('dart:json'); 7 #import('dart:json');
8 8
9 #import('source_file.dart'); 9 #import('source_file.dart');
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 String build(List<SourceMappingEntry> mappingEntries, SourceFile targetFile) { 59 String build(List<SourceMappingEntry> mappingEntries, SourceFile targetFile) {
60 StringBuffer buffer = new StringBuffer(); 60 StringBuffer buffer = new StringBuffer();
61 buffer.add('{\n'); 61 buffer.add('{\n');
62 buffer.add(' "version": 3,\n'); 62 buffer.add(' "version": 3,\n');
63 buffer.add(' "mappings": "'); 63 buffer.add(' "mappings": "');
64 mappingEntries.forEach((SourceMappingEntry entry) { 64 mappingEntries.forEach((SourceMappingEntry entry) {
65 writeEntry(entry, targetFile, buffer); 65 writeEntry(entry, targetFile, buffer);
66 }); 66 });
67 buffer.add('",\n'); 67 buffer.add('",\n');
68 // TODO(podivilov): serialize lists directly to buffer. 68 buffer.add(' "sources": ');
69 buffer.add(' "sources": ${JSON.stringify(sourceUrlList)},\n'); 69 JSON.printOn(sourceUrlList, buffer);
70 buffer.add(' "names": ${JSON.stringify(sourceNameList)}\n'); 70 buffer.add(',\n');
71 buffer.add('}\n'); 71 buffer.add(' "names": ');
72 JSON.printOn(sourceNameList, buffer);
73 buffer.add('\n}\n');
72 return buffer.toString(); 74 return buffer.toString();
73 } 75 }
74 76
75 void writeEntry(SourceMappingEntry entry, 77 void writeEntry(SourceMappingEntry entry,
76 SourceFile targetFile, 78 SourceFile targetFile,
77 StringBuffer output) { 79 StringBuffer output) {
78 if (entry.sourceFile === null) { 80 if (entry.sourceFile === null) {
79 return; 81 return;
80 } 82 }
81 int targetLine = targetFile.getLine(entry.targetOffset); 83 int targetLine = targetFile.getLine(entry.targetOffset);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 do { 144 do {
143 int digit = value & VLQ_BASE_MASK; 145 int digit = value & VLQ_BASE_MASK;
144 value >>= VLQ_BASE_SHIFT; 146 value >>= VLQ_BASE_SHIFT;
145 if (value > 0) { 147 if (value > 0) {
146 digit |= VLQ_CONTINUATION_BIT; 148 digit |= VLQ_CONTINUATION_BIT;
147 } 149 }
148 output.add(BASE64_DIGITS[digit]); 150 output.add(BASE64_DIGITS[digit]);
149 } while (value > 0); 151 } while (value > 0);
150 } 152 }
151 } 153 }
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