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

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

Issue 3004713002: Remove use of Compiler in inferrer engines. (Closed)
Patch Set: Created 3 years, 3 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 'package:kernel/ast.dart' show Location; 7 import 'package:kernel/ast.dart' show Location;
8 import '../../compiler_new.dart' show OutputSink, OutputType; 8 import '../../compiler_new.dart' show CompilerOutput, OutputSink, OutputType;
9 import '../util/uri_extras.dart' show relativize; 9 import '../util/uri_extras.dart' show relativize;
10 import '../util/util.dart'; 10 import '../util/util.dart';
11 import 'location_provider.dart'; 11 import 'location_provider.dart';
12 import 'code_output.dart' show SourceLocationsProvider, SourceLocations; 12 import 'code_output.dart' show SourceLocationsProvider, SourceLocations;
13 import 'source_information.dart' show SourceLocation; 13 import 'source_information.dart' show SourceLocation;
14 14
15 class SourceMapBuilder { 15 class SourceMapBuilder {
16 final String version; 16 final String version;
17 17
18 /// The URI of the source map file. 18 /// The URI of the source map file.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 /// [sourceLocationsProvider] for the .js code in [locationProvider] 187 /// [sourceLocationsProvider] for the .js code in [locationProvider]
188 /// [sourceMapUri] is used to relativizes the URIs of the referenced source 188 /// [sourceMapUri] is used to relativizes the URIs of the referenced source
189 /// files and the target [fileUri]. [name] and [outputProvider] are used to 189 /// files and the target [fileUri]. [name] and [outputProvider] are used to
190 /// create the [OutputSink] for the source map text. 190 /// create the [OutputSink] for the source map text.
191 static void outputSourceMap( 191 static void outputSourceMap(
192 SourceLocationsProvider sourceLocationsProvider, 192 SourceLocationsProvider sourceLocationsProvider,
193 LocationProvider locationProvider, 193 LocationProvider locationProvider,
194 String name, 194 String name,
195 Uri sourceMapUri, 195 Uri sourceMapUri,
196 Uri fileUri, 196 Uri fileUri,
197 OutputSink outputProvider( 197 CompilerOutput compilerOutput) {
198 String name, String extension, OutputType type)) {
199 // Create a source file for the compilation output. This allows using 198 // Create a source file for the compilation output. This allows using
200 // [:getLine:] to transform offsets to line numbers in [SourceMapBuilder]. 199 // [:getLine:] to transform offsets to line numbers in [SourceMapBuilder].
201 int index = 0; 200 int index = 0;
202 sourceLocationsProvider.sourceLocations 201 sourceLocationsProvider.sourceLocations
203 .forEach((SourceLocations sourceLocations) { 202 .forEach((SourceLocations sourceLocations) {
204 SourceMapBuilder sourceMapBuilder = new SourceMapBuilder( 203 SourceMapBuilder sourceMapBuilder = new SourceMapBuilder(
205 sourceLocations.name, sourceMapUri, fileUri, locationProvider); 204 sourceLocations.name, sourceMapUri, fileUri, locationProvider);
206 sourceLocations.forEachSourceLocation(sourceMapBuilder.addMapping); 205 sourceLocations.forEachSourceLocation(sourceMapBuilder.addMapping);
207 String sourceMap = sourceMapBuilder.build(); 206 String sourceMap = sourceMapBuilder.build();
208 String extension = 'js.map'; 207 String extension = 'js.map';
209 if (index > 0) { 208 if (index > 0) {
210 if (name == '') { 209 if (name == '') {
211 name = fileUri != null ? fileUri.pathSegments.last : 'out.js'; 210 name = fileUri != null ? fileUri.pathSegments.last : 'out.js';
212 extension = 'map.${sourceLocations.name}'; 211 extension = 'map.${sourceLocations.name}';
213 } else { 212 } else {
214 extension = 'js.map.${sourceLocations.name}'; 213 extension = 'js.map.${sourceLocations.name}';
215 } 214 }
216 } 215 }
217 outputProvider(name, extension, OutputType.sourceMap) 216 compilerOutput.createOutputSink(name, extension, OutputType.sourceMap)
218 ..add(sourceMap) 217 ..add(sourceMap)
219 ..close(); 218 ..close();
220 index++; 219 index++;
221 }); 220 });
222 } 221 }
223 } 222 }
224 223
225 /// Encoder for value deltas in VLQ format. 224 /// Encoder for value deltas in VLQ format.
226 class DeltaEncoder { 225 class DeltaEncoder {
227 /// The last emitted value of the encoder. 226 /// The last emitted value of the encoder.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 int register(T element) { 357 int register(T element) {
359 return map.putIfAbsent(element, () => map.length); 358 return map.putIfAbsent(element, () => map.length);
360 } 359 }
361 360
362 /// Returns the index of [element]. 361 /// Returns the index of [element].
363 int operator [](T element) => map[element]; 362 int operator [](T element) => map[element];
364 363
365 /// Returns the indexed elements. 364 /// Returns the indexed elements.
366 Iterable<T> get elements => map.keys; 365 Iterable<T> get elements => map.keys;
367 } 366 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698