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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart

Issue 642813005: dart2js: Emit constants in new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove code that isn't yet used. Created 6 years, 2 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
Index: sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart
index b15bbafd38ea558ff6211502acedb44c059aef81..69ab828293dc50c500d2a33c319bc96a656832db 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart
@@ -42,11 +42,11 @@ class ProgramBuilder {
/// generate the deferredLoadingMap (to know which hunks to load).
final Map<OutputUnit, Output> _outputs = <OutputUnit, Output>{};
- Program buildProgram() {
- Set<ClassElement> neededClasses = _task.neededClasses;
- Iterable<Element> neededStatics = backend.generatedCode.keys
- .where((Element e) => !e.isInstanceMember && !e.isField);
+ /// Mapping from [ConstantValue] to constructed [Constant]. We need this to
+ /// update field-initializers to point to the ConstantModel.
+ final Map<ConstantValue, Constant> _constants = <ConstantValue, Constant>{};
+ Program buildProgram() {
_task.outputClassLists.forEach(_registry.registerElements);
_task.outputStaticLists.forEach(_registry.registerElements);
@@ -96,6 +96,7 @@ class ProgramBuilder {
"", // The empty string is the name for the main output file.
namer.elementAccess(_compiler.mainFunction),
_buildLibraries(fragment),
+ _buildConstants(_task.outputConstantLists[fragment.outputUnit]),
_registry.holders.toList(growable: false));
_outputs[fragment.outputUnit] = result;
return result;
@@ -115,11 +116,25 @@ class ProgramBuilder {
Fragment fragment) {
DeferredOutput result = new DeferredOutput(
_outputFileName(fragment.name), fragment.name,
- mainOutput, _buildLibraries(fragment));
+ mainOutput, _buildLibraries(fragment),
+ _buildConstants(_task.outputConstantLists[fragment.outputUnit]));
_outputs[fragment.outputUnit] = result;
return result;
}
+ List<Constant> _buildConstants(List<ConstantValue> constantValues) {
kasperl 2014/10/16 07:01:57 Should this be _buildConstantsForFragment to avoid
floitsch 2014/10/16 12:59:54 Done.
+ if (constantValues == null) return const <Constant>[];
+ return constantValues.map((ConstantValue constantValue) {
+ assert(!_constants.containsKey(constantValue));
+ String name = namer.constantName(constantValue);
+ String constantObject = namer.globalObjectForConstant(constantValue);
+ Holder holder = _registry.registerHolder(constantObject);
+ Constant constant = new Constant(name, holder, constantValue);
+ _constants[constantValue] = constant;
+ return constant;
+ }).toList();
+ }
+
List<Library> _buildLibraries(Fragment fragment) {
List<Library> libraries = new List<Library>(fragment.length);
int count = 0;

Powered by Google App Engine
This is Rietveld 408576698