OLD | NEW |
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 '../../closure.dart' show ClosureFieldElement; | 7 import '../../closure.dart' show ClosureFieldElement; |
8 import '../../common.dart'; | 8 import '../../common.dart'; |
9 import '../../common/names.dart' show Names, Selectors; | 9 import '../../common/names.dart' show Names, Selectors; |
10 import '../../compiler.dart' show Compiler; | 10 import '../../compiler.dart' show Compiler; |
(...skipping 14 matching lines...) Expand all Loading... |
25 LibraryElement, | 25 LibraryElement, |
26 MethodElement, | 26 MethodElement, |
27 ParameterElement, | 27 ParameterElement, |
28 TypedefElement, | 28 TypedefElement, |
29 VariableElement; | 29 VariableElement; |
30 import '../../js/js.dart' as js; | 30 import '../../js/js.dart' as js; |
31 import '../../js_backend/backend_helpers.dart' show BackendHelpers; | 31 import '../../js_backend/backend_helpers.dart' show BackendHelpers; |
32 import '../../js_backend/js_backend.dart' | 32 import '../../js_backend/js_backend.dart' |
33 show Namer, JavaScriptBackend, JavaScriptConstantCompiler, StringBackedName; | 33 show Namer, JavaScriptBackend, JavaScriptConstantCompiler, StringBackedName; |
34 import '../../universe/selector.dart' show Selector; | 34 import '../../universe/selector.dart' show Selector; |
35 import '../../universe/universe.dart' show CodegenUniverse, SelectorConstraints; | 35 import '../../universe/world_builder.dart' |
| 36 show CodegenWorldBuilder, SelectorConstraints; |
36 import '../js_emitter.dart' | 37 import '../js_emitter.dart' |
37 show | 38 show |
38 ClassStubGenerator, | 39 ClassStubGenerator, |
39 CodeEmitterTask, | 40 CodeEmitterTask, |
40 computeMixinClass, | 41 computeMixinClass, |
41 Emitter, | 42 Emitter, |
42 InterceptorStubGenerator, | 43 InterceptorStubGenerator, |
43 MainCallStubGenerator, | 44 MainCallStubGenerator, |
44 ParameterStubGenerator, | 45 ParameterStubGenerator, |
45 RuntimeTypeGenerator, | 46 RuntimeTypeGenerator, |
(...skipping 26 matching lines...) Expand all Loading... |
72 ProgramBuilder(Compiler compiler, Namer namer, this._task, Emitter emitter, | 73 ProgramBuilder(Compiler compiler, Namer namer, this._task, Emitter emitter, |
73 Set<ClassElement> rtiNeededClasses) | 74 Set<ClassElement> rtiNeededClasses) |
74 : this._compiler = compiler, | 75 : this._compiler = compiler, |
75 this.namer = namer, | 76 this.namer = namer, |
76 this.collector = | 77 this.collector = |
77 new Collector(compiler, namer, rtiNeededClasses, emitter), | 78 new Collector(compiler, namer, rtiNeededClasses, emitter), |
78 this._registry = new Registry(compiler); | 79 this._registry = new Registry(compiler); |
79 | 80 |
80 JavaScriptBackend get backend => _compiler.backend; | 81 JavaScriptBackend get backend => _compiler.backend; |
81 BackendHelpers get helpers => backend.helpers; | 82 BackendHelpers get helpers => backend.helpers; |
82 CodegenUniverse get universe => _compiler.codegenWorld; | 83 CodegenWorldBuilder get universe => _compiler.codegenWorld; |
83 | 84 |
84 /// Mapping from [ClassElement] to constructed [Class]. We need this to | 85 /// Mapping from [ClassElement] to constructed [Class]. We need this to |
85 /// update the superclass in the [Class]. | 86 /// update the superclass in the [Class]. |
86 final Map<ClassElement, Class> _classes = <ClassElement, Class>{}; | 87 final Map<ClassElement, Class> _classes = <ClassElement, Class>{}; |
87 | 88 |
88 /// Mapping from [OutputUnit] to constructed [Fragment]. We need this to | 89 /// Mapping from [OutputUnit] to constructed [Fragment]. We need this to |
89 /// generate the deferredLoadingMap (to know which hunks to load). | 90 /// generate the deferredLoadingMap (to know which hunks to load). |
90 final Map<OutputUnit, Fragment> _outputs = <OutputUnit, Fragment>{}; | 91 final Map<OutputUnit, Fragment> _outputs = <OutputUnit, Fragment>{}; |
91 | 92 |
92 /// Mapping from [ConstantValue] to constructed [Constant]. We need this to | 93 /// Mapping from [ConstantValue] to constructed [Constant]. We need this to |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 _registry.deferredLibrariesMap.map(_buildDeferredFragment); | 162 _registry.deferredLibrariesMap.map(_buildDeferredFragment); |
162 | 163 |
163 List<Fragment> fragments = new List<Fragment>(_registry.librariesMapCount); | 164 List<Fragment> fragments = new List<Fragment>(_registry.librariesMapCount); |
164 fragments[0] = mainFragment; | 165 fragments[0] = mainFragment; |
165 fragments.setAll(1, deferredFragments); | 166 fragments.setAll(1, deferredFragments); |
166 | 167 |
167 _markEagerClasses(); | 168 _markEagerClasses(); |
168 | 169 |
169 List<Holder> holders = _registry.holders.toList(growable: false); | 170 List<Holder> holders = _registry.holders.toList(growable: false); |
170 | 171 |
171 bool needsNativeSupport = _compiler.enqueuer.codegen.nativeEnqueuer | 172 bool needsNativeSupport = |
172 .hasInstantiatedNativeClasses; | 173 _compiler.enqueuer.codegen.nativeEnqueuer.hasInstantiatedNativeClasses; |
173 | 174 |
174 assert(!needsNativeSupport || nativeClasses.isNotEmpty); | 175 assert(!needsNativeSupport || nativeClasses.isNotEmpty); |
175 | 176 |
176 List<js.TokenFinalizer> finalizers = [_task.metadataCollector]; | 177 List<js.TokenFinalizer> finalizers = [_task.metadataCollector]; |
177 if (backend.namer is js.TokenFinalizer) { | 178 if (backend.namer is js.TokenFinalizer) { |
178 var namingFinalizer = backend.namer; | 179 var namingFinalizer = backend.namer; |
179 finalizers.add(namingFinalizer); | 180 finalizers.add(namingFinalizer); |
180 } | 181 } |
181 | 182 |
182 return new Program(fragments, holders, _buildLoadMap(), _symbolsMap, | 183 return new Program(fragments, holders, _buildLoadMap(), _symbolsMap, |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 Constant constant = new Constant(name, holder, constantValue); | 981 Constant constant = new Constant(name, holder, constantValue); |
981 _constants[constantValue] = constant; | 982 _constants[constantValue] = constant; |
982 } | 983 } |
983 } | 984 } |
984 | 985 |
985 Holder _registerStaticStateHolder() { | 986 Holder _registerStaticStateHolder() { |
986 return _registry.registerHolder(namer.staticStateHolder, | 987 return _registry.registerHolder(namer.staticStateHolder, |
987 isStaticStateHolder: true); | 988 isStaticStateHolder: true); |
988 } | 989 } |
989 } | 990 } |
OLD | NEW |