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 js; | 5 library js; |
6 | 6 |
7 import 'package:js_ast/js_ast.dart'; | 7 import 'package:js_ast/js_ast.dart'; |
8 export 'package:js_ast/js_ast.dart'; | 8 export 'package:js_ast/js_ast.dart'; |
9 | 9 |
10 import '../compiler.dart' show | 10 import '../compiler.dart' show |
11 Compiler; | 11 Compiler; |
| 12 import '../diagnostics/diagnostic_listener.dart' show |
| 13 DiagnosticReporter; |
12 import '../diagnostics/spannable.dart' show | 14 import '../diagnostics/spannable.dart' show |
13 NO_LOCATION_SPANNABLE; | 15 NO_LOCATION_SPANNABLE; |
14 import '../dump_info.dart' show | 16 import '../dump_info.dart' show |
15 DumpInfoTask; | 17 DumpInfoTask; |
16 import '../io/code_output.dart' show | 18 import '../io/code_output.dart' show |
17 CodeBuffer, | 19 CodeBuffer, |
18 CodeOutput; | 20 CodeOutput; |
19 import '../js_emitter/js_emitter.dart' show | 21 import '../js_emitter/js_emitter.dart' show |
20 USE_LAZY_EMITTER; | 22 USE_LAZY_EMITTER; |
21 | 23 |
(...skipping 11 matching lines...) Expand all Loading... |
33 shouldCompressOutput: compiler.enableMinification, | 35 shouldCompressOutput: compiler.enableMinification, |
34 minifyLocalVariables: allowVariableMinification, | 36 minifyLocalVariables: allowVariableMinification, |
35 preferSemicolonToNewlineInMinifiedOutput: USE_LAZY_EMITTER, | 37 preferSemicolonToNewlineInMinifiedOutput: USE_LAZY_EMITTER, |
36 renamerForNames: renamerForNames); | 38 renamerForNames: renamerForNames); |
37 CodeBuffer outBuffer = new CodeBuffer(); | 39 CodeBuffer outBuffer = new CodeBuffer(); |
38 SourceInformationProcessor sourceInformationProcessor = | 40 SourceInformationProcessor sourceInformationProcessor = |
39 sourceInformationFactory.createProcessor( | 41 sourceInformationFactory.createProcessor( |
40 new SourceLocationsMapper(outBuffer)); | 42 new SourceLocationsMapper(outBuffer)); |
41 Dart2JSJavaScriptPrintingContext context = | 43 Dart2JSJavaScriptPrintingContext context = |
42 new Dart2JSJavaScriptPrintingContext( | 44 new Dart2JSJavaScriptPrintingContext( |
43 compiler, monitor, outBuffer, sourceInformationProcessor); | 45 compiler.reporter, monitor, outBuffer, sourceInformationProcessor); |
44 Printer printer = new Printer(options, context); | 46 Printer printer = new Printer(options, context); |
45 printer.visit(node); | 47 printer.visit(node); |
46 sourceInformationProcessor.process(node); | 48 sourceInformationProcessor.process(node); |
47 return outBuffer; | 49 return outBuffer; |
48 } | 50 } |
49 | 51 |
50 class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext { | 52 class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext { |
51 final Compiler compiler; | 53 final DiagnosticReporter reporter; |
52 final DumpInfoTask monitor; | 54 final DumpInfoTask monitor; |
53 final CodeBuffer outBuffer; | 55 final CodeBuffer outBuffer; |
54 final CodePositionListener codePositionListener; | 56 final CodePositionListener codePositionListener; |
55 | 57 |
56 Dart2JSJavaScriptPrintingContext( | 58 Dart2JSJavaScriptPrintingContext( |
57 this.compiler, | 59 this.reporter, |
58 this.monitor, | 60 this.monitor, |
59 this.outBuffer, | 61 this.outBuffer, |
60 this.codePositionListener); | 62 this.codePositionListener); |
61 | 63 |
62 @override | 64 @override |
63 void error(String message) { | 65 void error(String message) { |
64 compiler.internalError(NO_LOCATION_SPANNABLE, message); | 66 reporter.internalError(NO_LOCATION_SPANNABLE, message); |
65 } | 67 } |
66 | 68 |
67 @override | 69 @override |
68 void emit(String string) { | 70 void emit(String string) { |
69 outBuffer.add(string); | 71 outBuffer.add(string); |
70 } | 72 } |
71 | 73 |
72 @override | 74 @override |
73 void enterNode(Node, int startPosition) {} | 75 void enterNode(Node, int startPosition) {} |
74 | 76 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 159 } |
158 } | 160 } |
159 _cachedLiteral = js.escapedString(text); | 161 _cachedLiteral = js.escapedString(text); |
160 } | 162 } |
161 return _cachedLiteral; | 163 return _cachedLiteral; |
162 } | 164 } |
163 | 165 |
164 @override | 166 @override |
165 String get value => _literal.value; | 167 String get value => _literal.value; |
166 } | 168 } |
OLD | NEW |