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 'package:compiler/src/apiimpl.dart' as api; | 8 import 'package:compiler/src/apiimpl.dart' as api; |
9 import 'package:compiler/src/dart2jslib.dart' show NullSink; | 9 import 'package:compiler/src/dart2jslib.dart' show NullSink; |
10 import "package:compiler/src/elements/elements.dart"; | 10 import 'package:compiler/src/elements/elements.dart'; |
| 11 import 'package:compiler/src/helpers/helpers.dart'; |
11 import 'package:compiler/src/filenames.dart'; | 12 import 'package:compiler/src/filenames.dart'; |
12 import 'package:compiler/src/io/source_file.dart'; | 13 import 'package:compiler/src/io/source_file.dart'; |
13 import 'package:compiler/src/io/source_information.dart'; | 14 import 'package:compiler/src/io/source_information.dart'; |
14 import 'package:compiler/src/js/js.dart' as js; | 15 import 'package:compiler/src/js/js.dart' as js; |
15 import 'package:compiler/src/js/js_debug.dart'; | 16 import 'package:compiler/src/js/js_debug.dart'; |
16 import 'package:compiler/src/js/js_source_mapping.dart'; | 17 import 'package:compiler/src/js/js_source_mapping.dart'; |
17 import 'package:compiler/src/js_backend/js_backend.dart'; | 18 import 'package:compiler/src/js_backend/js_backend.dart'; |
18 import 'package:compiler/src/source_file_provider.dart'; | 19 import 'package:compiler/src/source_file_provider.dart'; |
19 import '../memory_compiler.dart'; | 20 import '../memory_compiler.dart'; |
20 import '../output_collector.dart'; | 21 import '../output_collector.dart'; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 100 |
100 /// Creates a processor for the Dart file [filename]. | 101 /// Creates a processor for the Dart file [filename]. |
101 SourceMapProcessor(String filename, {this.outputToFile: false}) { | 102 SourceMapProcessor(String filename, {this.outputToFile: false}) { |
102 inputUri = Uri.base.resolve(nativeToUriPath(filename)); | 103 inputUri = Uri.base.resolve(nativeToUriPath(filename)); |
103 jsPath = 'out.js'; | 104 jsPath = 'out.js'; |
104 targetUri = Uri.base.resolve(jsPath); | 105 targetUri = Uri.base.resolve(jsPath); |
105 sourceMapFileUri = Uri.base.resolve('${jsPath}.map'); | 106 sourceMapFileUri = Uri.base.resolve('${jsPath}.map'); |
106 } | 107 } |
107 | 108 |
108 /// Computes the [SourceMapInfo] for the compiled elements. | 109 /// Computes the [SourceMapInfo] for the compiled elements. |
109 Future<List<SourceMapInfo>> process(List<String> options) async { | 110 Future<List<SourceMapInfo>> process( |
| 111 List<String> options, |
| 112 {bool verbose: true}) async { |
110 OutputProvider outputProvider = outputToFile | 113 OutputProvider outputProvider = outputToFile |
111 ? new OutputProvider() | 114 ? new OutputProvider() |
112 : new CloningOutputProvider(targetUri, sourceMapFileUri); | 115 : new CloningOutputProvider(targetUri, sourceMapFileUri); |
113 if (options.contains('--use-new-source-info')) { | 116 if (options.contains('--use-new-source-info')) { |
114 print('Using the new source information system.'); | 117 if (verbose) print('Using the new source information system.'); |
115 useNewSourceInfo = true; | 118 useNewSourceInfo = true; |
116 } | 119 } |
117 api.Compiler compiler = await compilerFor({}, | 120 api.Compiler compiler = await compilerFor({}, |
118 outputProvider: outputProvider, | 121 outputProvider: outputProvider, |
| 122 // TODO(johnniwinther): Use [verbose] to avoid showing diagnostics. |
119 options: ['--out=$targetUri', '--source-map=$sourceMapFileUri'] | 123 options: ['--out=$targetUri', '--source-map=$sourceMapFileUri'] |
120 ..addAll(options)); | 124 ..addAll(options)); |
121 if (options.contains('--disable-inlining')) { | 125 if (options.contains('--disable-inlining')) { |
122 print('Inlining disabled'); | 126 if (verbose) print('Inlining disabled'); |
123 compiler.disableInlining = true; | 127 compiler.disableInlining = true; |
124 } | 128 } |
125 | 129 |
126 JavaScriptBackend backend = compiler.backend; | 130 JavaScriptBackend backend = compiler.backend; |
127 var handler = compiler.handler; | 131 var handler = compiler.handler; |
128 SourceFileProvider sourceFileProvider = handler.provider; | 132 SourceFileProvider sourceFileProvider = handler.provider; |
129 sourceFileManager = new ProviderSourceFileManager(sourceFileProvider); | 133 sourceFileManager = new ProviderSourceFileManager(sourceFileProvider); |
130 await compiler.runCompiler(inputUri); | 134 await compiler.runCompiler(inputUri); |
131 | 135 |
132 List<SourceMapInfo> infoList = <SourceMapInfo>[]; | 136 List<SourceMapInfo> infoList = <SourceMapInfo>[]; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 this.jsCode, | 326 this.jsCode, |
323 this.sourceLocation, | 327 this.sourceLocation, |
324 this.dartCode, | 328 this.dartCode, |
325 {this.isMissing: false}); | 329 {this.isMissing: false}); |
326 | 330 |
327 String toString() { | 331 String toString() { |
328 return 'CodePoint[kind=$kind,js=$jsCode,dart=$dartCode,' | 332 return 'CodePoint[kind=$kind,js=$jsCode,dart=$dartCode,' |
329 'location=$sourceLocation]'; | 333 'location=$sourceLocation]'; |
330 } | 334 } |
331 } | 335 } |
OLD | NEW |