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

Side by Side Diff: pkg/compiler/lib/src/dart_backend/outputter.dart

Issue 824103005: Revert "Remove Compiler.assembledCode." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of dart_backend; 5 part of dart_backend;
6 6
7 typedef bool IsSafeToRemoveTypeDeclarations( 7 typedef bool IsSafeToRemoveTypeDeclarations(
8 Map<ClassElement, Iterable<Element>> classMembers); 8 Map<ClassElement, Iterable<Element>> classMembers);
9 typedef void ElementCallback<E>(E element); 9 typedef void ElementCallback<E>(E element);
10 typedef void ElementPostProcessFunction( 10 typedef void ElementPostProcessFunction(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 /// referenced in the program. 48 /// referenced in the program.
49 /// 49 ///
50 /// [instantiatedClasses] is the set of classes that are potentially 50 /// [instantiatedClasses] is the set of classes that are potentially
51 /// instantiated in the program. 51 /// instantiated in the program.
52 /// 52 ///
53 /// [resolvedElements] is the set of methods, constructors, and fields that 53 /// [resolvedElements] is the set of methods, constructors, and fields that
54 /// are potentially accessed/called in the program. 54 /// are potentially accessed/called in the program.
55 /// 55 ///
56 /// The [sortElements] function is used to sort [instantiatedClasses] and 56 /// The [sortElements] function is used to sort [instantiatedClasses] and
57 /// [resolvedElements] in the generated output. 57 /// [resolvedElements] in the generated output.
58 /// 58 String assembleProgram({
59 /// Returns the total size of the generated code.
60 int assembleProgram({
61 MirrorRenamer mirrorRenamer: const MirrorRenamer(), 59 MirrorRenamer mirrorRenamer: const MirrorRenamer(),
62 Iterable<LibraryElement> libraries, 60 Iterable<LibraryElement> libraries,
63 Iterable<Element> instantiatedClasses, 61 Iterable<Element> instantiatedClasses,
64 Iterable<Element> resolvedElements, 62 Iterable<Element> resolvedElements,
65 Iterable<ClassElement> usedTypeLiterals: const <ClassElement>[], 63 Iterable<ClassElement> usedTypeLiterals: const <ClassElement>[],
66 FunctionElement mainFunction, 64 FunctionElement mainFunction,
67 Uri outputUri, 65 Uri outputUri,
68 ElementPostProcessFunction postProcessElementAst, 66 ElementPostProcessFunction postProcessElementAst,
69 ComputeElementAstFunction computeElementAst, 67 ComputeElementAstFunction computeElementAst,
70 ElementFilter shouldOutput, 68 ElementFilter shouldOutput,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 elementInfo); 113 elementInfo);
116 114
117 renamer = createRenamer( 115 renamer = createRenamer(
118 collector, 116 collector,
119 libraryInfo, 117 libraryInfo,
120 elementInfo, 118 elementInfo,
121 enableMinification: enableMinification, 119 enableMinification: enableMinification,
122 forceStripTypes: forceStripTypes, 120 forceStripTypes: forceStripTypes,
123 isSafeToRemoveTypeDeclarations: isSafeToRemoveTypeDeclarations); 121 isSafeToRemoveTypeDeclarations: isSafeToRemoveTypeDeclarations);
124 122
123 String assembledCode;
125 if (outputAst) { 124 if (outputAst) {
126 String code = astOutput(listener, elementInfo); 125 assembledCode = astOutput(listener, elementInfo);
127 outputProvider("", "dart")
128 ..add(code)
129 ..close();
130 return code.length;
131 } else { 126 } else {
132 output = new MainOutputGenerator(); 127 output = new MainOutputGenerator();
133 return output.generateCode( 128 assembledCode = output.generateCode(
134 libraryInfo, 129 libraryInfo,
135 elementInfo, 130 elementInfo,
136 collector, 131 collector,
137 renamer, 132 renamer,
138 mainFunction, 133 mainFunction,
139 outputUri, 134 outputUri,
140 outputProvider, 135 outputProvider,
141 mirrorRenamer, 136 mirrorRenamer,
142 multiFile: multiFile, 137 multiFile: multiFile,
143 forceStripTypes: forceStripTypes, 138 forceStripTypes: forceStripTypes,
144 enableMinification: enableMinification); 139 enableMinification: enableMinification);
145 } 140 }
141 return assembledCode;
146 } 142 }
147 143
148 static PlaceholderCollector collectPlaceholders( 144 static PlaceholderCollector collectPlaceholders(
149 DiagnosticListener listener, 145 DiagnosticListener listener,
150 MirrorRenamer mirrorRenamer, 146 MirrorRenamer mirrorRenamer,
151 FunctionElement mainFunction, 147 FunctionElement mainFunction,
152 LibraryInfo libraryInfo, 148 LibraryInfo libraryInfo,
153 ElementInfo elementInfo) { 149 ElementInfo elementInfo) {
154 // Create all necessary placeholders. 150 // Create all necessary placeholders.
155 PlaceholderCollector collector = new PlaceholderCollector( 151 PlaceholderCollector collector = new PlaceholderCollector(
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 424 }
429 } 425 }
430 426
431 /// Main output generator for [DartOutputter] that emits dart code through a 427 /// Main output generator for [DartOutputter] that emits dart code through a
432 /// [CompilerOutputProvider]. 428 /// [CompilerOutputProvider].
433 class MainOutputGenerator { 429 class MainOutputGenerator {
434 final Map<ClassNode, List<Node>> memberNodes = 430 final Map<ClassNode, List<Node>> memberNodes =
435 new Map<ClassNode, List<Node>>(); 431 new Map<ClassNode, List<Node>>();
436 final List<Node> topLevelNodes = <Node>[]; 432 final List<Node> topLevelNodes = <Node>[];
437 433
438 /// Generates the code and returns the total size. 434 String generateCode(
439 int generateCode(
440 LibraryInfo libraryInfo, 435 LibraryInfo libraryInfo,
441 ElementInfo elementInfo, 436 ElementInfo elementInfo,
442 PlaceholderCollector collector, 437 PlaceholderCollector collector,
443 PlaceholderRenamer placeholderRenamer, 438 PlaceholderRenamer placeholderRenamer,
444 FunctionElement mainFunction, 439 FunctionElement mainFunction,
445 Uri outputUri, 440 Uri outputUri,
446 CompilerOutputProvider outputProvider, 441 CompilerOutputProvider outputProvider,
447 MirrorRenamer mirrorRenamer, 442 MirrorRenamer mirrorRenamer,
448 {bool multiFile: false, 443 {bool multiFile: false,
449 bool forceStripTypes: false, 444 bool forceStripTypes: false,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 if (node is ClassNode) { 532 if (node is ClassNode) {
538 // TODO(smok): Filter out default constructors here. 533 // TODO(smok): Filter out default constructors here.
539 unparser.unparseClassWithBody(node, memberNodes[node]); 534 unparser.unparseClassWithBody(node, memberNodes[node]);
540 } else { 535 } else {
541 unparser.unparse(node); 536 unparser.unparse(node);
542 } 537 }
543 unparser.newline(); 538 unparser.newline();
544 } 539 }
545 540
546 int totalSize = 0; 541 int totalSize = 0;
542 String assembledCode;
547 if (multiFile) { 543 if (multiFile) {
548 for(LibraryElement outputLibrary in libraryInfo.userLibraries) { 544 for(LibraryElement outputLibrary in libraryInfo.userLibraries) {
549 // TODO(sigurdm): Make the unparser output directly into the buffer 545 // TODO(sigurdm): Make the unparser output directly into the buffer
550 // instead of caching in `.result`. 546 // instead of caching in `.result`.
551 String code = unparsers[outputLibrary].result; 547 String code = unparsers[outputLibrary].result;
552 totalSize += code.length; 548 totalSize += code.length;
553 outputProvider(outputPaths[outputLibrary], "dart") 549 outputProvider(outputPaths[outputLibrary], "dart")
554 ..add(code) 550 ..add(code)
555 ..close(); 551 ..close();
556 } 552 }
553 // TODO(sigurdm): We should get rid of compiler.assembledCode.
554 assembledCode = unparsers[mainFunction.library].result;
557 } else { 555 } else {
558 String code = mainUnparser.result; 556 assembledCode = mainUnparser.result;
559 outputProvider("", "dart") 557 outputProvider("", "dart")
560 ..add(code) 558 ..add(assembledCode)
561 ..close(); 559 ..close();
562 560
563 totalSize = code.length; 561 totalSize = assembledCode.length;
564 } 562 }
565 563
566 return totalSize; 564 return assembledCode;
567 } 565 }
568 } 566 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698