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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/program_builder.dart

Issue 849933003: dart2js: register static non final fields in the model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase 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 | « no previous file | pkg/compiler/lib/src/js_emitter/registry.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 library dart2js.js_emitter.program_builder; 5 library dart2js.js_emitter.program_builder;
6 6
7 import 'js_emitter.dart' show computeMixinClass; 7 import 'js_emitter.dart' show computeMixinClass;
8 import 'model.dart'; 8 import 'model.dart';
9 9
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 final Map<OutputUnit, Fragment> _outputs = <OutputUnit, Fragment>{}; 54 final Map<OutputUnit, Fragment> _outputs = <OutputUnit, Fragment>{};
55 55
56 /// Mapping from [ConstantValue] to constructed [Constant]. We need this to 56 /// Mapping from [ConstantValue] to constructed [Constant]. We need this to
57 /// update field-initializers to point to the ConstantModel. 57 /// update field-initializers to point to the ConstantModel.
58 final Map<ConstantValue, Constant> _constants = <ConstantValue, Constant>{}; 58 final Map<ConstantValue, Constant> _constants = <ConstantValue, Constant>{};
59 59
60 Program buildProgram() { 60 Program buildProgram() {
61 _task.outputClassLists.forEach(_registry.registerElements); 61 _task.outputClassLists.forEach(_registry.registerElements);
62 _task.outputStaticLists.forEach(_registry.registerElements); 62 _task.outputStaticLists.forEach(_registry.registerElements);
63 _task.outputConstantLists.forEach(_registerConstants); 63 _task.outputConstantLists.forEach(_registerConstants);
64 _task.outputStaticNonFinalFieldLists.forEach(_registry.registerElements);
64 65
65 // TODO(kasperl): There's code that implicitly needs access to the special 66 // TODO(kasperl): There's code that implicitly needs access to the special
66 // $ holder so we have to register that. Can we track if we have to? 67 // $ holder so we have to register that. Can we track if we have to?
67 _registry.registerHolder(r'$'); 68 _registry.registerHolder(r'$');
68 69
69 MainFragment mainOutput = _buildMainOutput(_registry.mainLibrariesMap); 70 MainFragment mainOutput = _buildMainOutput(_registry.mainLibrariesMap);
70 Iterable<Fragment> deferredOutputs = _registry.deferredLibrariesMap 71 Iterable<Fragment> deferredOutputs = _registry.deferredLibrariesMap
71 .map((librariesMap) => _buildDeferredOutput(mainOutput, librariesMap)); 72 .map((librariesMap) => _buildDeferredOutput(mainOutput, librariesMap));
72 73
73 List<Fragment> outputs = new List<Fragment>(_registry.librariesMapCount); 74 List<Fragment> outputs = new List<Fragment>(_registry.librariesMapCount);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 StaticMethod _buildStaticMethodTearOff(FunctionElement element) { 431 StaticMethod _buildStaticMethodTearOff(FunctionElement element) {
431 String name = namer.getStaticClosureName(element); 432 String name = namer.getStaticClosureName(element);
432 String holder = namer.globalObjectFor(element); 433 String holder = namer.globalObjectFor(element);
433 // TODO(kasperl): This clearly doesn't work yet. 434 // TODO(kasperl): This clearly doesn't work yet.
434 js.Expression code = js.string("<<unimplemented>>"); 435 js.Expression code = js.string("<<unimplemented>>");
435 return new StaticMethod(element, 436 return new StaticMethod(element,
436 name, _registry.registerHolder(holder), code); 437 name, _registry.registerHolder(holder), code);
437 } 438 }
438 439
439 void _registerConstants(OutputUnit outputUnit, 440 void _registerConstants(OutputUnit outputUnit,
440 List<ConstantValue> constantValues) { 441 Iterable<ConstantValue> constantValues) {
442 // `constantValues` is null if an outputUnit doesn't contain any constants.
441 if (constantValues == null) return; 443 if (constantValues == null) return;
442 for (ConstantValue constantValue in constantValues) { 444 for (ConstantValue constantValue in constantValues) {
443 _registry.registerConstant(outputUnit, constantValue); 445 _registry.registerConstant(outputUnit, constantValue);
444 assert(!_constants.containsKey(constantValue)); 446 assert(!_constants.containsKey(constantValue));
445 String name = namer.constantName(constantValue); 447 String name = namer.constantName(constantValue);
446 String constantObject = namer.globalObjectForConstant(constantValue); 448 String constantObject = namer.globalObjectForConstant(constantValue);
447 Holder holder = _registry.registerHolder(constantObject); 449 Holder holder = _registry.registerHolder(constantObject);
448 Constant constant = new Constant(name, holder, constantValue); 450 Constant constant = new Constant(name, holder, constantValue);
449 _constants[constantValue] = constant; 451 _constants[constantValue] = constant;
450 }; 452 }
451 } 453 }
452 } 454 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698