OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 sourcemap.helper; | 5 library sourcemap.helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'package:compiler/compiler_new.dart'; | 9 import 'package:compiler/compiler_new.dart'; |
10 import 'package:compiler/src/apiimpl.dart' as api; | 10 import 'package:compiler/src/apiimpl.dart' as api; |
| 11 import 'package:compiler/src/commandline_options.dart'; |
11 import 'package:compiler/src/null_compiler_output.dart' show NullSink; | 12 import 'package:compiler/src/null_compiler_output.dart' show NullSink; |
12 import 'package:compiler/src/elements/elements.dart'; | 13 import 'package:compiler/src/elements/elements.dart'; |
13 import 'package:compiler/src/helpers/helpers.dart'; | 14 import 'package:compiler/src/helpers/helpers.dart'; |
14 import 'package:compiler/src/filenames.dart'; | 15 import 'package:compiler/src/filenames.dart'; |
15 import 'package:compiler/src/io/code_output.dart'; | 16 import 'package:compiler/src/io/code_output.dart'; |
16 import 'package:compiler/src/io/source_file.dart'; | 17 import 'package:compiler/src/io/source_file.dart'; |
17 import 'package:compiler/src/io/source_information.dart'; | 18 import 'package:compiler/src/io/source_information.dart'; |
18 import 'package:compiler/src/io/position_information.dart'; | 19 import 'package:compiler/src/io/position_information.dart'; |
19 import 'package:compiler/src/js/js.dart' as js; | 20 import 'package:compiler/src/js/js.dart' as js; |
20 import 'package:compiler/src/js/js_debug.dart'; | 21 import 'package:compiler/src/js/js_debug.dart'; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 if (add) { | 265 if (add) { |
265 nodes.add(node); | 266 nodes.add(node); |
266 } | 267 } |
267 node.visitChildren(this); | 268 node.visitChildren(this); |
268 if (node == soughtNode) { | 269 if (node == soughtNode) { |
269 add = false; | 270 add = false; |
270 } | 271 } |
271 } | 272 } |
272 } | 273 } |
273 | 274 |
274 const String USE_NEW_SOURCE_INFO = '--use-new-source-info'; | |
275 const String DISABLE_INLINING = '--disable-inlining'; | 275 const String DISABLE_INLINING = '--disable-inlining'; |
276 | 276 |
277 /// Processor that computes [SourceMapInfo] for the JavaScript compiled for a | 277 /// Processor that computes [SourceMapInfo] for the JavaScript compiled for a |
278 /// given Dart file. | 278 /// given Dart file. |
279 class SourceMapProcessor { | 279 class SourceMapProcessor { |
280 /// If `true` the output from the compilation is written to files. | 280 /// If `true` the output from the compilation is written to files. |
281 final bool outputToFile; | 281 final bool outputToFile; |
282 | 282 |
283 /// The [Uri] of the Dart entrypoint. | 283 /// The [Uri] of the Dart entrypoint. |
284 Uri inputUri; | 284 Uri inputUri; |
(...skipping 20 matching lines...) Expand all Loading... |
305 | 305 |
306 /// Computes the [SourceMapInfo] for the compiled elements. | 306 /// Computes the [SourceMapInfo] for the compiled elements. |
307 Future<SourceMaps> process( | 307 Future<SourceMaps> process( |
308 List<String> options, | 308 List<String> options, |
309 {bool verbose: true, | 309 {bool verbose: true, |
310 bool perElement: true, | 310 bool perElement: true, |
311 bool forMain: false}) async { | 311 bool forMain: false}) async { |
312 OutputProvider outputProvider = outputToFile | 312 OutputProvider outputProvider = outputToFile |
313 ? new CloningOutputProvider(targetUri, sourceMapFileUri) | 313 ? new CloningOutputProvider(targetUri, sourceMapFileUri) |
314 : new OutputProvider(); | 314 : new OutputProvider(); |
315 if (options.contains(USE_NEW_SOURCE_INFO)) { | 315 if (options.contains(Flags.useNewSourceInfo)) { |
316 if (verbose) print('Using the new source information system.'); | 316 if (verbose) print('Using the new source information system.'); |
317 useNewSourceInfo = true; | |
318 } | 317 } |
319 api.CompilerImpl compiler = await compilerFor( | 318 api.CompilerImpl compiler = await compilerFor( |
320 outputProvider: outputProvider, | 319 outputProvider: outputProvider, |
321 // TODO(johnniwinther): Use [verbose] to avoid showing diagnostics. | 320 // TODO(johnniwinther): Use [verbose] to avoid showing diagnostics. |
322 options: ['--out=$targetUri', '--source-map=$sourceMapFileUri'] | 321 options: ['--out=$targetUri', '--source-map=$sourceMapFileUri'] |
323 ..addAll(options)); | 322 ..addAll(options)); |
324 if (options.contains(DISABLE_INLINING)) { | 323 if (options.contains(DISABLE_INLINING)) { |
325 if (verbose) print('Inlining disabled'); | 324 if (verbose) print('Inlining disabled'); |
326 compiler.disableInlining = true; | 325 compiler.disableInlining = true; |
327 } | 326 } |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 absoluteUri = base.resolveUri(uri); | 587 absoluteUri = base.resolveUri(uri); |
589 } else { | 588 } else { |
590 absoluteUri = base.resolve(uri); | 589 absoluteUri = base.resolve(uri); |
591 } | 590 } |
592 return sourceFiles.putIfAbsent(absoluteUri, () { | 591 return sourceFiles.putIfAbsent(absoluteUri, () { |
593 String text = new File.fromUri(absoluteUri).readAsStringSync(); | 592 String text = new File.fromUri(absoluteUri).readAsStringSync(); |
594 return new StringSourceFile.fromUri(absoluteUri, text); | 593 return new StringSourceFile.fromUri(absoluteUri, text); |
595 }); | 594 }); |
596 } | 595 } |
597 } | 596 } |
OLD | NEW |