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

Unified Diff: pkg/compiler/lib/src/js/js.dart

Issue 1617083002: Base JavaScript code position computation on JavaScript tracer. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/io/start_end_information.dart ('k') | pkg/compiler/lib/src/js/js_debug.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/js.dart
diff --git a/pkg/compiler/lib/src/js/js.dart b/pkg/compiler/lib/src/js/js.dart
index 313330d7afcb0a8cf8cf493269024cde77dc8c54..274236a9763031f30433d85ab9a9b616fb8b5162 100644
--- a/pkg/compiler/lib/src/js/js.dart
+++ b/pkg/compiler/lib/src/js/js.dart
@@ -20,12 +20,30 @@ import '../js_emitter/js_emitter.dart' show
import 'js_source_mapping.dart';
-CodeBuffer prettyPrint(Node node,
- Compiler compiler,
- {DumpInfoTask monitor,
- bool allowVariableMinification: true,
- Renamer renamerForNames:
- JavaScriptPrintingOptions.identityRenamer}) {
+String prettyPrint(
+ Node node,
+ Compiler compiler,
+ {bool allowVariableMinification: true,
+ Renamer renamerForNames: JavaScriptPrintingOptions.identityRenamer}) {
+ // TODO(johnniwinther): Do we need all the options here?
+ JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(
+ shouldCompressOutput: compiler.enableMinification,
+ minifyLocalVariables: allowVariableMinification,
+ preferSemicolonToNewlineInMinifiedOutput: USE_LAZY_EMITTER,
+ renamerForNames: renamerForNames);
+ SimpleJavaScriptPrintingContext context =
+ new SimpleJavaScriptPrintingContext();
+ Printer printer = new Printer(options, context);
+ printer.visit(node);
+ return context.getText();
+}
+
+CodeBuffer createCodeBuffer(
+ Node node,
+ Compiler compiler,
+ {DumpInfoTask monitor,
+ bool allowVariableMinification: true,
+ Renamer renamerForNames: JavaScriptPrintingOptions.identityRenamer}) {
JavaScriptSourceInformationStrategy sourceInformationFactory =
compiler.backend.sourceInformationStrategy;
JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(
@@ -35,14 +53,14 @@ CodeBuffer prettyPrint(Node node,
renamerForNames: renamerForNames);
CodeBuffer outBuffer = new CodeBuffer();
SourceInformationProcessor sourceInformationProcessor =
- sourceInformationFactory.createProcessor(
- new SourceLocationsMapper(outBuffer));
+ sourceInformationFactory.createProcessor(
+ new SourceLocationsMapper(outBuffer));
Dart2JSJavaScriptPrintingContext context =
new Dart2JSJavaScriptPrintingContext(
compiler.reporter, monitor, outBuffer, sourceInformationProcessor);
Printer printer = new Printer(options, context);
printer.visit(node);
- sourceInformationProcessor.process(node);
+ sourceInformationProcessor.process(node, outBuffer);
return outBuffer;
}
@@ -143,7 +161,7 @@ class UnparsedNode extends DeferredString
LiteralString get _literal {
if (_cachedLiteral == null) {
- String text = prettyPrint(tree, _compiler).getText();
+ String text = prettyPrint(tree, _compiler);
if (_protectForEval) {
if (tree is Fun) text = '($text)';
if (tree is LiteralExpression) {
« no previous file with comments | « pkg/compiler/lib/src/io/start_end_information.dart ('k') | pkg/compiler/lib/src/js/js_debug.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698