Chromium Code Reviews| 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; |