OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js; | 5 part of dart2js; |
6 | 6 |
7 /** | 7 /** |
8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
9 * compiled. | 9 * compiled. |
10 */ | 10 */ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // TODO(johnniwinther): Split this class into interface and implementation. | 51 // TODO(johnniwinther): Split this class into interface and implementation. |
52 // TODO(johnniwinther): Move this implementation to the JS backend. | 52 // TODO(johnniwinther): Move this implementation to the JS backend. |
53 class CodegenRegistry extends Registry { | 53 class CodegenRegistry extends Registry { |
54 final Compiler compiler; | 54 final Compiler compiler; |
55 final TreeElements treeElements; | 55 final TreeElements treeElements; |
56 | 56 |
57 CodegenRegistry(this.compiler, this.treeElements); | 57 CodegenRegistry(this.compiler, this.treeElements); |
58 | 58 |
59 bool get isForResolution => false; | 59 bool get isForResolution => false; |
60 | 60 |
| 61 Element get currentElement => treeElements.currentElement; |
| 62 |
61 // TODO(johnniwinther): Remove this getter when [Registry] creates a | 63 // TODO(johnniwinther): Remove this getter when [Registry] creates a |
62 // dependency node. | 64 // dependency node. |
63 Setlet<Element> get otherDependencies => treeElements.otherDependencies; | 65 Setlet<Element> get otherDependencies => treeElements.otherDependencies; |
64 | 66 |
65 CodegenEnqueuer get world => compiler.enqueuer.codegen; | 67 CodegenEnqueuer get world => compiler.enqueuer.codegen; |
66 js_backend.JavaScriptBackend get backend => compiler.backend; | 68 js_backend.JavaScriptBackend get backend => compiler.backend; |
67 | 69 |
68 void registerDependency(Element element) { | 70 void registerDependency(Element element) { |
69 treeElements.registerDependency(element); | 71 treeElements.registerDependency(element); |
70 } | 72 } |
71 | 73 |
72 void registerInstantiatedClass(ClassElement element) { | 74 void registerInstantiatedClass(ClassElement element) { |
73 world.registerInstantiatedClass(element, this); | 75 world.registerInstantiatedClass(element, this); |
74 } | 76 } |
75 | 77 |
76 void registerInstantiatedType(InterfaceType type) { | 78 void registerInstantiatedType(InterfaceType type) { |
77 world.registerInstantiatedType(type, this); | 79 world.registerInstantiatedType(type, this); |
78 } | 80 } |
79 | 81 |
80 void registerStaticUse(Element element) { | 82 void registerStaticUse(Element element) { |
81 world.registerStaticUse(element); | 83 world.registerStaticUse(element); |
82 } | 84 } |
83 | 85 |
84 void registerDynamicInvocation(Selector selector) { | 86 void registerDynamicInvocation(Selector selector) { |
85 world.registerDynamicInvocation(selector); | 87 world.registerDynamicInvocation(currentElement, selector); |
86 } | 88 } |
87 | 89 |
88 void registerDynamicSetter(Selector selector) { | 90 void registerDynamicSetter(Selector selector) { |
89 world.registerDynamicSetter(selector); | 91 world.registerDynamicSetter(currentElement, selector); |
90 } | 92 } |
91 | 93 |
92 void registerDynamicGetter(Selector selector) { | 94 void registerDynamicGetter(Selector selector) { |
93 world.registerDynamicGetter(selector); | 95 world.registerDynamicGetter(currentElement, selector); |
94 } | 96 } |
95 | 97 |
96 void registerGetterForSuperMethod(Element element) { | 98 void registerGetterForSuperMethod(Element element) { |
97 world.registerGetterForSuperMethod(element); | 99 world.registerGetterForSuperMethod(element); |
98 } | 100 } |
99 | 101 |
100 void registerFieldGetter(Element element) { | 102 void registerFieldGetter(Element element) { |
101 world.registerFieldGetter(element); | 103 world.registerFieldGetter(element); |
102 } | 104 } |
103 | 105 |
(...skipping 18 matching lines...) Expand all Loading... |
122 | 124 |
123 void registerGenericClosure(FunctionElement element) { | 125 void registerGenericClosure(FunctionElement element) { |
124 backend.registerGenericClosure(element, world, this); | 126 backend.registerGenericClosure(element, world, this); |
125 } | 127 } |
126 | 128 |
127 void registerGetOfStaticFunction(FunctionElement element) { | 129 void registerGetOfStaticFunction(FunctionElement element) { |
128 world.registerGetOfStaticFunction(element); | 130 world.registerGetOfStaticFunction(element); |
129 } | 131 } |
130 | 132 |
131 void registerSelectorUse(Selector selector) { | 133 void registerSelectorUse(Selector selector) { |
132 world.registerSelectorUse(selector); | 134 world.registerSelectorUse(currentElement, selector); |
133 } | 135 } |
134 | 136 |
135 void registerFactoryWithTypeArguments() { | 137 void registerFactoryWithTypeArguments() { |
136 world.registerFactoryWithTypeArguments(this); | 138 world.registerFactoryWithTypeArguments(this); |
137 } | 139 } |
138 | 140 |
139 void registerConstSymbol(String name) { | 141 void registerConstSymbol(String name) { |
140 backend.registerConstSymbol(name, this); | 142 backend.registerConstSymbol(name, this); |
141 } | 143 } |
142 | 144 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 305 |
304 /** | 306 /** |
305 * Call this to register that the [:runtimeType:] property has been accessed. | 307 * Call this to register that the [:runtimeType:] property has been accessed. |
306 */ | 308 */ |
307 void registerRuntimeType(Enqueuer enqueuer, Registry registry) {} | 309 void registerRuntimeType(Enqueuer enqueuer, Registry registry) {} |
308 | 310 |
309 /** | 311 /** |
310 * Call this method to enable [noSuchMethod] handling in the | 312 * Call this method to enable [noSuchMethod] handling in the |
311 * backend. | 313 * backend. |
312 */ | 314 */ |
313 void enableNoSuchMethod(Enqueuer enqueuer) { | 315 void enableNoSuchMethod(Element context, Enqueuer enqueuer) { |
314 enqueuer.registerInvocation(compiler.noSuchMethodSelector); | 316 enqueuer.registerInvocation(null, compiler.noSuchMethodSelector); |
315 } | 317 } |
316 | 318 |
317 /// Call this method to enable support for isolates. | 319 /// Call this method to enable support for isolates. |
318 void enableIsolateSupport(Enqueuer enqueuer) {} | 320 void enableIsolateSupport(Enqueuer enqueuer) {} |
319 | 321 |
320 void registerRequiredType(DartType type, Element enclosingElement) {} | 322 void registerRequiredType(DartType type, Element enclosingElement) {} |
321 void registerClassUsingVariableExpression(ClassElement cls) {} | 323 void registerClassUsingVariableExpression(ClassElement cls) {} |
322 | 324 |
323 void registerConstSymbol(String name, Registry registry) {} | 325 void registerConstSymbol(String name, Registry registry) {} |
324 void registerNewSymbol(Registry registry) {} | 326 void registerNewSymbol(Registry registry) {} |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 if(stopAfterTypeInference) return; | 1395 if(stopAfterTypeInference) return; |
1394 | 1396 |
1395 log('Compiling...'); | 1397 log('Compiling...'); |
1396 phase = PHASE_COMPILING; | 1398 phase = PHASE_COMPILING; |
1397 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. | 1399 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. |
1398 if (hasIsolateSupport) { | 1400 if (hasIsolateSupport) { |
1399 backend.enableIsolateSupport(enqueuer.codegen); | 1401 backend.enableIsolateSupport(enqueuer.codegen); |
1400 enqueuer.codegen.registerGetOfStaticFunction(main); | 1402 enqueuer.codegen.registerGetOfStaticFunction(main); |
1401 } | 1403 } |
1402 if (enabledNoSuchMethod) { | 1404 if (enabledNoSuchMethod) { |
1403 backend.enableNoSuchMethod(enqueuer.codegen); | 1405 backend.enableNoSuchMethod(null, enqueuer.codegen); |
1404 } | 1406 } |
1405 if (compileAll) { | 1407 if (compileAll) { |
1406 libraryLoader.libraries.forEach((LibraryElement library) { | 1408 libraryLoader.libraries.forEach((LibraryElement library) { |
1407 fullyEnqueueLibrary(library, enqueuer.codegen); | 1409 fullyEnqueueLibrary(library, enqueuer.codegen); |
1408 }); | 1410 }); |
1409 } | 1411 } |
1410 processQueue(enqueuer.codegen, main); | 1412 processQueue(enqueuer.codegen, main); |
1411 enqueuer.codegen.logSummary(log); | 1413 enqueuer.codegen.logSummary(log); |
1412 | 1414 |
1413 if (compilationFailed) return; | 1415 if (compilationFailed) return; |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 static NullSink outputProvider(String name, String extension) { | 2025 static NullSink outputProvider(String name, String extension) { |
2024 return new NullSink('$name.$extension'); | 2026 return new NullSink('$name.$extension'); |
2025 } | 2027 } |
2026 } | 2028 } |
2027 | 2029 |
2028 /// Information about suppressed warnings and hints for a given library. | 2030 /// Information about suppressed warnings and hints for a given library. |
2029 class SuppressionInfo { | 2031 class SuppressionInfo { |
2030 int warnings = 0; | 2032 int warnings = 0; |
2031 int hints = 0; | 2033 int hints = 0; |
2032 } | 2034 } |
OLD | NEW |