| 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/commandline_options.dart'; |
| 12 import 'package:compiler/src/null_compiler_output.dart' show NullSink; | |
| 13 import 'package:compiler/src/elements/elements.dart'; | 12 import 'package:compiler/src/elements/elements.dart'; |
| 14 import 'package:compiler/src/elements/entities.dart'; | 13 import 'package:compiler/src/elements/entities.dart'; |
| 15 import 'package:compiler/src/helpers/helpers.dart'; | |
| 16 import 'package:compiler/src/filenames.dart'; | 14 import 'package:compiler/src/filenames.dart'; |
| 17 import 'package:compiler/src/io/code_output.dart'; | 15 import 'package:compiler/src/io/code_output.dart'; |
| 18 import 'package:compiler/src/io/source_file.dart'; | 16 import 'package:compiler/src/io/source_file.dart'; |
| 19 import 'package:compiler/src/io/source_information.dart'; | 17 import 'package:compiler/src/io/source_information.dart'; |
| 20 import 'package:compiler/src/io/position_information.dart'; | 18 import 'package:compiler/src/io/position_information.dart'; |
| 21 import 'package:compiler/src/js/js.dart' as js; | 19 import 'package:compiler/src/js/js.dart' as js; |
| 22 import 'package:compiler/src/js/js_debug.dart'; | 20 import 'package:compiler/src/js/js_debug.dart'; |
| 23 import 'package:compiler/src/js/js_source_mapping.dart'; | 21 import 'package:compiler/src/js/js_source_mapping.dart'; |
| 24 import 'package:compiler/src/js_backend/js_backend.dart'; | 22 import 'package:compiler/src/js_backend/js_backend.dart'; |
| 25 import 'package:compiler/src/source_file_provider.dart'; | 23 import 'package:compiler/src/source_file_provider.dart'; |
| 26 import 'package:kernel/ast.dart' show Location; | |
| 27 import '../memory_compiler.dart'; | 24 import '../memory_compiler.dart'; |
| 28 import '../output_collector.dart'; | 25 import '../output_collector.dart'; |
| 29 | 26 |
| 30 class SourceFileSink implements OutputSink { | 27 class SourceFileSink implements OutputSink { |
| 31 final String filename; | 28 final String filename; |
| 32 StringBuffer sb = new StringBuffer(); | 29 StringBuffer sb = new StringBuffer(); |
| 33 SourceFile sourceFile; | 30 SourceFile sourceFile; |
| 34 | 31 |
| 35 SourceFileSink(this.filename); | 32 SourceFileSink(this.filename); |
| 36 | 33 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 if (options.contains(Flags.disableInlining)) { | 315 if (options.contains(Flags.disableInlining)) { |
| 319 if (verbose) print('Inlining disabled'); | 316 if (verbose) print('Inlining disabled'); |
| 320 } | 317 } |
| 321 api.CompilerImpl compiler = await compilerFor( | 318 api.CompilerImpl compiler = await compilerFor( |
| 322 outputProvider: outputProvider, | 319 outputProvider: outputProvider, |
| 323 // TODO(johnniwinther): Use [verbose] to avoid showing diagnostics. | 320 // TODO(johnniwinther): Use [verbose] to avoid showing diagnostics. |
| 324 options: ['--out=$targetUri', '--source-map=$sourceMapFileUri'] | 321 options: ['--out=$targetUri', '--source-map=$sourceMapFileUri'] |
| 325 ..addAll(options)); | 322 ..addAll(options)); |
| 326 | 323 |
| 327 JavaScriptBackend backend = compiler.backend; | 324 JavaScriptBackend backend = compiler.backend; |
| 328 var handler = compiler.handler; | 325 dynamic handler = compiler.handler; |
| 329 SourceFileProvider sourceFileProvider = handler.provider; | 326 SourceFileProvider sourceFileProvider = handler.provider; |
| 330 sourceFileManager = | 327 sourceFileManager = |
| 331 new ProviderSourceFileManager(sourceFileProvider, outputProvider); | 328 new ProviderSourceFileManager(sourceFileProvider, outputProvider); |
| 332 RecordingSourceInformationStrategy strategy = | 329 RecordingSourceInformationStrategy strategy = |
| 333 new RecordingSourceInformationStrategy( | 330 new RecordingSourceInformationStrategy( |
| 334 backend.sourceInformationStrategy); | 331 backend.sourceInformationStrategy); |
| 335 backend.sourceInformationStrategy = strategy; | 332 backend.sourceInformationStrategy = strategy; |
| 336 await compiler.run(inputUri); | 333 await compiler.run(inputUri); |
| 337 | 334 |
| 338 SourceMapInfo mainSourceMapInfo; | 335 SourceMapInfo mainSourceMapInfo; |
| 339 Map<Element, SourceMapInfo> elementSourceMapInfos = | 336 Map<Element, SourceMapInfo> elementSourceMapInfos = |
| 340 <Element, SourceMapInfo>{}; | 337 <Element, SourceMapInfo>{}; |
| 341 if (perElement) { | 338 if (perElement) { |
| 342 backend.generatedCode | 339 backend.generatedCode.forEach((_element, js.Expression node) { |
| 343 .forEach((MemberElement element, js.Expression node) { | 340 MemberElement element = _element; |
| 344 RecordedSourceInformationProcess subProcess = | 341 RecordedSourceInformationProcess subProcess = |
| 345 strategy.subProcessForNode(node); | 342 strategy.subProcessForNode(node); |
| 346 if (subProcess == null) { | 343 if (subProcess == null) { |
| 347 // TODO(johnniwinther): Find out when this is happening and if it | 344 // TODO(johnniwinther): Find out when this is happening and if it |
| 348 // is benign. (Known to happen for `bool#fromString`) | 345 // is benign. (Known to happen for `bool#fromString`) |
| 349 print('No subProcess found for $element'); | 346 print('No subProcess found for $element'); |
| 350 return; | 347 return; |
| 351 } | 348 } |
| 352 LocationMap nodeMap = subProcess.nodeToSourceLocationsMap; | 349 LocationMap nodeMap = subProcess.nodeToSourceLocationsMap; |
| 353 String code = subProcess.code; | 350 String code = subProcess.code; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 absoluteUri = base.resolveUri(uri); | 569 absoluteUri = base.resolveUri(uri); |
| 573 } else { | 570 } else { |
| 574 absoluteUri = base.resolve(uri); | 571 absoluteUri = base.resolve(uri); |
| 575 } | 572 } |
| 576 return sourceFiles.putIfAbsent(absoluteUri, () { | 573 return sourceFiles.putIfAbsent(absoluteUri, () { |
| 577 String text = new File.fromUri(absoluteUri).readAsStringSync(); | 574 String text = new File.fromUri(absoluteUri).readAsStringSync(); |
| 578 return new StringSourceFile.fromUri(absoluteUri, text); | 575 return new StringSourceFile.fromUri(absoluteUri, text); |
| 579 }); | 576 }); |
| 580 } | 577 } |
| 581 } | 578 } |
| OLD | NEW |