Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: pkg/compiler/lib/src/js/js.dart

Issue 1284593003: Remove dart2jslib.dart (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 '../io/code_output.dart' show CodeOutput, CodeBuffer; 10 import '../compiler.dart' show
11 import '../js_emitter/js_emitter.dart' show USE_LAZY_EMITTER; 11 Compiler;
12 import '../dart2jslib.dart' as leg; 12 import '../diagnostics/spannable.dart' show
13 import '../util/util.dart' show NO_LOCATION_SPANNABLE, Indentation, Tagging; 13 NO_LOCATION_SPANNABLE;
14 import '../dump_info.dart' show DumpInfoTask; 14 import '../dump_info.dart' show
15 DumpInfoTask;
16 import '../io/code_output.dart' show
17 CodeBuffer,
18 CodeOutput;
19 import '../js_emitter/js_emitter.dart' show
20 USE_LAZY_EMITTER;
21
15 import 'js_source_mapping.dart'; 22 import 'js_source_mapping.dart';
16 23
17 CodeBuffer prettyPrint(Node node, 24 CodeBuffer prettyPrint(Node node,
18 leg.Compiler compiler, 25 Compiler compiler,
19 {DumpInfoTask monitor, 26 {DumpInfoTask monitor,
20 bool allowVariableMinification: true, 27 bool allowVariableMinification: true,
21 Renamer renamerForNames: 28 Renamer renamerForNames:
22 JavaScriptPrintingOptions.identityRenamer}) { 29 JavaScriptPrintingOptions.identityRenamer}) {
23 JavaScriptSourceInformationStrategy sourceInformationFactory = 30 JavaScriptSourceInformationStrategy sourceInformationFactory =
24 compiler.backend.sourceInformationStrategy; 31 compiler.backend.sourceInformationStrategy;
25 JavaScriptPrintingOptions options = new JavaScriptPrintingOptions( 32 JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(
26 shouldCompressOutput: compiler.enableMinification, 33 shouldCompressOutput: compiler.enableMinification,
27 minifyLocalVariables: allowVariableMinification, 34 minifyLocalVariables: allowVariableMinification,
28 preferSemicolonToNewlineInMinifiedOutput: USE_LAZY_EMITTER, 35 preferSemicolonToNewlineInMinifiedOutput: USE_LAZY_EMITTER,
29 renamerForNames: renamerForNames); 36 renamerForNames: renamerForNames);
30 CodeBuffer outBuffer = new CodeBuffer(); 37 CodeBuffer outBuffer = new CodeBuffer();
31 SourceInformationProcessor sourceInformationProcessor = 38 SourceInformationProcessor sourceInformationProcessor =
32 sourceInformationFactory.createProcessor( 39 sourceInformationFactory.createProcessor(
33 new SourceLocationsMapper(outBuffer)); 40 new SourceLocationsMapper(outBuffer));
34 Dart2JSJavaScriptPrintingContext context = 41 Dart2JSJavaScriptPrintingContext context =
35 new Dart2JSJavaScriptPrintingContext( 42 new Dart2JSJavaScriptPrintingContext(
36 compiler, monitor, outBuffer, sourceInformationProcessor); 43 compiler, monitor, outBuffer, sourceInformationProcessor);
37 Printer printer = new Printer(options, context); 44 Printer printer = new Printer(options, context);
38 printer.visit(node); 45 printer.visit(node);
39 sourceInformationProcessor.process(node); 46 sourceInformationProcessor.process(node);
40 return outBuffer; 47 return outBuffer;
41 } 48 }
42 49
43 class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext { 50 class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext {
44 final leg.Compiler compiler; 51 final Compiler compiler;
45 final DumpInfoTask monitor; 52 final DumpInfoTask monitor;
46 final CodeBuffer outBuffer; 53 final CodeBuffer outBuffer;
47 final CodePositionListener codePositionListener; 54 final CodePositionListener codePositionListener;
48 55
49 Dart2JSJavaScriptPrintingContext( 56 Dart2JSJavaScriptPrintingContext(
50 this.compiler, 57 this.compiler,
51 this.monitor, 58 this.monitor,
52 this.outBuffer, 59 this.outBuffer,
53 this.codePositionListener); 60 this.codePositionListener);
54 61
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 /// Represents the LiteralString resulting from unparsing [expression]. The 122 /// Represents the LiteralString resulting from unparsing [expression]. The
116 /// actual unparsing is done on demand when requesting the [value] of this 123 /// actual unparsing is done on demand when requesting the [value] of this
117 /// node. 124 /// node.
118 /// 125 ///
119 /// This is used when generated code needs to be represented as a string, 126 /// This is used when generated code needs to be represented as a string,
120 /// for example by the lazy emitter or when generating code generators. 127 /// for example by the lazy emitter or when generating code generators.
121 class UnparsedNode extends DeferredString 128 class UnparsedNode extends DeferredString
122 implements AstContainer { 129 implements AstContainer {
123 @override 130 @override
124 final Node tree; 131 final Node tree;
125 final leg.Compiler _compiler; 132 final Compiler _compiler;
126 final bool _protectForEval; 133 final bool _protectForEval;
127 LiteralString _cachedLiteral; 134 LiteralString _cachedLiteral;
128 135
129 Iterable<Node> get containedNodes => [tree]; 136 Iterable<Node> get containedNodes => [tree];
130 137
131 /// A [js.Literal] that represents the string result of unparsing [ast]. 138 /// A [js.Literal] that represents the string result of unparsing [ast].
132 /// 139 ///
133 /// When its string [value] is requested, the node pretty-prints the given 140 /// When its string [value] is requested, the node pretty-prints the given
134 /// [ast] and, if [protectForEval] is true, wraps the resulting 141 /// [ast] and, if [protectForEval] is true, wraps the resulting
135 /// string in parenthesis. The result is also escaped. 142 /// string in parenthesis. The result is also escaped.
(...skipping 14 matching lines...) Expand all
150 } 157 }
151 } 158 }
152 _cachedLiteral = js.escapedString(text); 159 _cachedLiteral = js.escapedString(text);
153 } 160 }
154 return _cachedLiteral; 161 return _cachedLiteral;
155 } 162 }
156 163
157 @override 164 @override
158 String get value => _literal.value; 165 String get value => _literal.value;
159 } 166 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/io/start_end_information.dart ('k') | pkg/compiler/lib/src/js/rewrite_async.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698