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

Side by Side Diff: pkg/compiler/lib/src/io/source_map_builder.dart

Issue 2654023003: Add no-info mappings at start of out.js and after mapped functions (Closed)
Patch Set: fixes 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
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 dart2js.source_map_builder; 5 library dart2js.source_map_builder;
6 6
7 import '../util/uri_extras.dart' show relativize; 7 import '../util/uri_extras.dart' show relativize;
8 import '../util/util.dart'; 8 import '../util/util.dart';
9 import 'line_column_provider.dart'; 9 import 'line_column_provider.dart';
10 import 'source_information.dart' show SourceLocation; 10 import 'source_information.dart' show SourceLocation;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 Map<Uri, LineColumnMap<SourceMapEntry>> sourceLocationMap = 45 Map<Uri, LineColumnMap<SourceMapEntry>> sourceLocationMap =
46 <Uri, LineColumnMap<SourceMapEntry>>{}; 46 <Uri, LineColumnMap<SourceMapEntry>>{};
47 entries.forEach((SourceMapEntry sourceMapEntry) { 47 entries.forEach((SourceMapEntry sourceMapEntry) {
48 int line = lineColumnProvider.getLine(sourceMapEntry.targetOffset); 48 int line = lineColumnProvider.getLine(sourceMapEntry.targetOffset);
49 int column = 49 int column =
50 lineColumnProvider.getColumn(line, sourceMapEntry.targetOffset); 50 lineColumnProvider.getColumn(line, sourceMapEntry.targetOffset);
51 lineColumnMap.add(line, column, sourceMapEntry); 51 lineColumnMap.add(line, column, sourceMapEntry);
52 52
53 SourceLocation location = sourceMapEntry.sourceLocation; 53 SourceLocation location = sourceMapEntry.sourceLocation;
54 if (location != null) { 54 if (location != null) {
55 LineColumnMap<SourceMapEntry> sourceLineColumnMap = 55 if (location.sourceUri != null) {
56 sourceLocationMap.putIfAbsent( 56 LineColumnMap<SourceMapEntry> sourceLineColumnMap =
57 location.sourceUri, () => new LineColumnMap<SourceMapEntry>()); 57 sourceLocationMap.putIfAbsent(location.sourceUri,
58 sourceLineColumnMap.add(location.line, location.column, sourceMapEntry); 58 () => new LineColumnMap<SourceMapEntry>());
59 sourceLineColumnMap.add(
60 location.line, location.column, sourceMapEntry);
61 }
59 } 62 }
60 }); 63 });
61 64
62 return _build(lineColumnMap); 65 return _build(lineColumnMap);
63 } 66 }
64 67
65 String _build(LineColumnMap<SourceMapEntry> lineColumnMap) { 68 String _build(LineColumnMap<SourceMapEntry> lineColumnMap) {
66 IndexMap<Uri> uriMap = new IndexMap<Uri>(); 69 IndexMap<Uri> uriMap = new IndexMap<Uri>();
67 IndexMap<String> nameMap = new IndexMap<String>(); 70 IndexMap<String> nameMap = new IndexMap<String>();
68 71
69 lineColumnMap.forEachElement((SourceMapEntry entry) { 72 lineColumnMap.forEachElement((SourceMapEntry entry) {
70 SourceLocation sourceLocation = entry.sourceLocation; 73 SourceLocation sourceLocation = entry.sourceLocation;
71 if (sourceLocation != null) { 74 if (sourceLocation != null) {
72 uriMap.register(sourceLocation.sourceUri); 75 if (sourceLocation.sourceUri != null) {
73 if (sourceLocation.sourceName != null) { 76 uriMap.register(sourceLocation.sourceUri);
74 nameMap.register(sourceLocation.sourceName); 77 if (sourceLocation.sourceName != null) {
78 nameMap.register(sourceLocation.sourceName);
79 }
75 } 80 }
76 } 81 }
77 }); 82 });
78 83
79 StringBuffer mappingsBuffer = new StringBuffer(); 84 StringBuffer mappingsBuffer = new StringBuffer();
80 writeEntries(lineColumnMap, uriMap, nameMap, mappingsBuffer); 85 writeEntries(lineColumnMap, uriMap, nameMap, mappingsBuffer);
81 86
82 StringBuffer buffer = new StringBuffer(); 87 StringBuffer buffer = new StringBuffer();
83 buffer.write('{\n'); 88 buffer.write('{\n');
84 buffer.write(' "version": 3,\n'); 89 buffer.write(' "version": 3,\n');
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 141 }
137 firstEntryInLine = false; 142 firstEntryInLine = false;
138 143
139 targetColumnEncoder.encode(output, targetColumn); 144 targetColumnEncoder.encode(output, targetColumn);
140 145
141 if (sourceLocation == null) { 146 if (sourceLocation == null) {
142 return; 147 return;
143 } 148 }
144 149
145 Uri sourceUri = sourceLocation.sourceUri; 150 Uri sourceUri = sourceLocation.sourceUri;
146 sourceUriIndexEncoder.encode(output, uriMap[sourceUri]); 151 if (sourceUri != null) {
147 sourceLineEncoder.encode(output, sourceLocation.line); 152 sourceUriIndexEncoder.encode(output, uriMap[sourceUri]);
148 sourceColumnEncoder.encode(output, sourceLocation.column); 153 sourceLineEncoder.encode(output, sourceLocation.line);
154 sourceColumnEncoder.encode(output, sourceLocation.column);
155 }
149 156
150 String sourceName = sourceLocation.sourceName; 157 String sourceName = sourceLocation.sourceName;
151 if (sourceName != null) { 158 if (sourceName != null) {
152 sourceNameIndexEncoder.encode(output, nameMap[sourceName]); 159 sourceNameIndexEncoder.encode(output, nameMap[sourceName]);
153 } 160 }
154 161
155 previousSourceLocation = sourceLocation; 162 previousSourceLocation = sourceLocation;
156 }); 163 });
157 } 164 }
158 } 165 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 int register(T element) { 298 int register(T element) {
292 return map.putIfAbsent(element, () => map.length); 299 return map.putIfAbsent(element, () => map.length);
293 } 300 }
294 301
295 /// Returns the index of [element]. 302 /// Returns the index of [element].
296 int operator [](T element) => map[element]; 303 int operator [](T element) => map[element];
297 304
298 /// Returns the indexed elements. 305 /// Returns the indexed elements.
299 Iterable<T> get elements => map.keys; 306 Iterable<T> get elements => map.keys;
300 } 307 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/io/source_information.dart ('k') | tests/compiler/dart2js/sourcemaps/js_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698