| 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 dev_compiler.src.codegen.js_codegen; | 5 library dev_compiler.src.codegen.js_codegen; |
| 6 | 6 |
| 7 import 'dart:collection' show HashSet; | 7 import 'dart:collection' show HashSet; |
| 8 import 'dart:io' show Directory, File; | 8 import 'dart:io' show Directory, File; |
| 9 | 9 |
| 10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| (...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 CheckerReporter reporter) { | 1929 CheckerReporter reporter) { |
| 1930 JS.Program jsTree = | 1930 JS.Program jsTree = |
| 1931 new JSCodegenVisitor(info, rules).generateLibrary(units, reporter); | 1931 new JSCodegenVisitor(info, rules).generateLibrary(units, reporter); |
| 1932 | 1932 |
| 1933 var outputPath = path.join(outDir, jsOutputPath(info, root)); | 1933 var outputPath = path.join(outDir, jsOutputPath(info, root)); |
| 1934 new Directory(path.dirname(outputPath)).createSync(recursive: true); | 1934 new Directory(path.dirname(outputPath)).createSync(recursive: true); |
| 1935 | 1935 |
| 1936 if (options.emitSourceMaps) { | 1936 if (options.emitSourceMaps) { |
| 1937 var outFilename = path.basename(outputPath); | 1937 var outFilename = path.basename(outputPath); |
| 1938 var printer = new srcmaps.Printer(outFilename); | 1938 var printer = new srcmaps.Printer(outFilename); |
| 1939 _writeNode( | 1939 _writeNode(new SourceMapPrintingContext( |
| 1940 new SourceMapPrintingContext(printer, path.dirname(outputPath)), | 1940 printer, path.dirname(outputPath)), jsTree); |
| 1941 jsTree); | |
| 1942 printer.add('//# sourceMappingURL=$outFilename.map'); | 1941 printer.add('//# sourceMappingURL=$outFilename.map'); |
| 1943 // Write output file and source map | 1942 // Write output file and source map |
| 1944 new File(outputPath).writeAsStringSync(printer.text); | 1943 new File(outputPath).writeAsStringSync(printer.text); |
| 1945 new File('$outputPath.map').writeAsStringSync(printer.map); | 1944 new File('$outputPath.map').writeAsStringSync(printer.map); |
| 1946 } else { | 1945 } else { |
| 1947 new File(outputPath).writeAsStringSync(jsNodeToString(jsTree)); | 1946 new File(outputPath).writeAsStringSync(jsNodeToString(jsTree)); |
| 1948 } | 1947 } |
| 1949 } | 1948 } |
| 1950 } | 1949 } |
| 1951 | 1950 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 | 2034 |
| 2036 // TODO(jmesserly): in many cases marking the end will be unncessary. | 2035 // TODO(jmesserly): in many cases marking the end will be unncessary. |
| 2037 printer.mark(_location(node.end)); | 2036 printer.mark(_location(node.end)); |
| 2038 } | 2037 } |
| 2039 | 2038 |
| 2040 String _getIdentifier(AstNode node) { | 2039 String _getIdentifier(AstNode node) { |
| 2041 if (node is SimpleIdentifier) return node.name; | 2040 if (node is SimpleIdentifier) return node.name; |
| 2042 return null; | 2041 return null; |
| 2043 } | 2042 } |
| 2044 } | 2043 } |
| OLD | NEW |