OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fletchc.fletch_codegen_registry; | 5 library fletchc.fletch_codegen_registry; |
6 | 6 |
7 import 'package:compiler/src/dart2jslib.dart' show | 7 import 'package:compiler/src/compiler.dart' show |
8 CodegenRegistry, | 8 GlobalDependencyRegistry; |
9 | |
10 import 'package:compiler/src/common/codegen.dart' show | |
11 CodegenRegistry; | |
12 | |
13 import 'package:compiler/src/common/registry.dart' show | |
9 Registry; | 14 Registry; |
10 | 15 |
11 import 'package:compiler/src/constants/values.dart' show | 16 import 'package:compiler/src/universe/selector.dart' show |
12 ConstantValue; | 17 Selector; |
13 | 18 |
14 import 'package:compiler/src/universe/universe.dart' show | 19 import 'package:compiler/src/universe/use.dart' show |
15 Selector, | 20 DynamicUse, |
16 UniverseSelector; | 21 StaticUse; |
17 | 22 |
18 import 'package:compiler/src/elements/elements.dart' show | 23 import 'package:compiler/src/elements/elements.dart' show |
19 ClassElement, | 24 ClassElement, |
20 Element, | 25 Element, |
21 FunctionElement, | 26 FunctionElement, |
22 LocalElement; | 27 LocalElement; |
23 | 28 |
24 import 'package:compiler/src/resolution/resolution.dart' show | |
25 TreeElements; | |
26 | |
27 import 'package:compiler/src/dart_types.dart' show | 29 import 'package:compiler/src/dart_types.dart' show |
28 DartType, | 30 DartType, |
29 InterfaceType; | 31 InterfaceType; |
30 | 32 |
31 import 'package:compiler/src/util/util.dart' show | |
32 Setlet; | |
33 | |
34 import 'fletch_backend.dart' show | |
35 FletchBackend; | |
36 | |
37 import 'fletch_compiler_implementation.dart' show | 33 import 'fletch_compiler_implementation.dart' show |
38 FletchCompilerImplementation; | 34 FletchCompilerImplementation; |
39 | 35 |
40 import 'fletch_enqueuer.dart' show | 36 import 'fletch_enqueuer.dart' show |
41 FletchEnqueuer; | 37 FletchEnqueuer; |
42 | 38 |
43 /// Represents ways a function can used as a closure. See also [Closurization] | 39 /// Represents ways a function can used as a closure. See also [Closurization] |
44 /// in [./dynamic_call_enqueuer.dart]. | 40 /// in [./dynamic_call_enqueuer.dart]. |
45 enum ClosureKind { | 41 enum ClosureKind { |
46 // Notes: | 42 // Notes: |
(...skipping 30 matching lines...) Expand all Loading... | |
77 superTearOff, | 73 superTearOff, |
78 } | 74 } |
79 | 75 |
80 get _notImplemented => throw "not implemented"; | 76 get _notImplemented => throw "not implemented"; |
81 | 77 |
82 abstract class FletchRegistry { | 78 abstract class FletchRegistry { |
83 final FletchEnqueuer world; | 79 final FletchEnqueuer world; |
84 | 80 |
85 factory FletchRegistry( | 81 factory FletchRegistry( |
86 FletchCompilerImplementation compiler, | 82 FletchCompilerImplementation compiler, |
87 TreeElements treeElements) = FletchRegistryImplementation; | 83 GlobalDependencyRegistry globalRegistry) = FletchRegistryImplementation; |
88 | 84 |
89 FletchRegistry.internal(this.world); | 85 FletchRegistry.internal(this.world); |
90 | 86 |
91 Registry get asRegistry; | 87 Registry get asRegistry; |
92 | 88 |
93 void registerStaticInvocation(Element element) { | 89 void registerStaticUse(StaticUse staticUse) { |
94 // TODO(ahe): Call a different method. | 90 // TODO(ahe): Call a different method. |
95 world.registerStaticUse(element); | 91 world.registerStaticUse(staticUse); |
96 } | 92 } |
97 | 93 |
98 void registerInstantiatedClass(ClassElement element) { | 94 void registerInstantiatedClass(ClassElement element) { |
99 world.registerInstantiatedType(element.rawType, this.asRegistry); | 95 world.registerInstantiatedType(element.rawType); |
100 } | 96 } |
101 | 97 |
102 void registerDynamicSetter(UniverseSelector selector) { | 98 void registerDynamicUse(DynamicUse use) { |
103 world.registerDynamicSetter(selector); | 99 world.registerDynamicUse(use); |
104 } | |
105 | |
106 void registerDynamicGetter(UniverseSelector selector) { | |
107 world.registerDynamicGetter(selector); | |
108 } | |
109 | |
110 void registerDynamicInvocation(UniverseSelector selector) { | |
111 world.registerDynamicInvocation(selector); | |
112 } | 100 } |
113 | 101 |
114 void registerInstantiatedType(InterfaceType type) { | 102 void registerInstantiatedType(InterfaceType type) { |
115 world.registerInstantiatedType(type, this.asRegistry); | 103 world.registerInstantiatedType(type); |
116 } | 104 } |
117 | 105 |
118 void registerIsCheck(DartType type) { | 106 void registerIsCheck(DartType type) { |
119 world.registerIsCheck(type); | 107 world.registerIsCheck(type); |
120 } | 108 } |
121 | 109 |
122 void registerLocalInvoke(LocalElement element, Selector selector) { | 110 void registerLocalInvoke(LocalElement element, Selector selector) { |
123 world.recordElementUsage(element, selector); | 111 world.recordElementUsage(element, selector); |
124 } | 112 } |
125 | 113 |
(...skipping 13 matching lines...) Expand all Loading... | |
139 | 127 |
140 case ClosureKind.localFunction: | 128 case ClosureKind.localFunction: |
141 assert(function.memberContext != function); | 129 assert(function.memberContext != function); |
142 } | 130 } |
143 world.dynamicCallEnqueuer.enqueueClosure(function, kind); | 131 world.dynamicCallEnqueuer.enqueueClosure(function, kind); |
144 } | 132 } |
145 } | 133 } |
146 | 134 |
147 @proxy | 135 @proxy |
148 class FletchRegistryImplementation extends FletchRegistry | 136 class FletchRegistryImplementation extends FletchRegistry |
149 implements CodegenRegistry { | 137 implements GlobalDependencyRegistry { |
150 final TreeElements treeElements; | 138 final GlobalDependencyRegistry globalRegistry; |
ahe
2015/11/17 16:44:09
I don't understand this change.
sigurdm
2015/11/19 14:33:47
This is no longer needed.
Fixed.
| |
151 | 139 |
152 FletchRegistryImplementation( | 140 FletchRegistryImplementation( |
153 FletchCompilerImplementation compiler, | 141 FletchCompilerImplementation compiler, |
154 this.treeElements) | 142 this.globalRegistry) |
155 : super.internal(compiler.enqueuer.codegen); | 143 : super.internal(compiler.enqueuer.codegen); |
156 | 144 |
157 Registry get asRegistry => this; | 145 Registry get asRegistry => this; |
158 | 146 |
159 noSuchMethod(invocation) => super.noSuchMethod(invocation); | 147 noSuchMethod(invocation) => super.noSuchMethod(invocation); |
160 | 148 |
161 // TODO(ahe): Remove this method, called by [Enqueuer], not [FletchEnqueuer]. | 149 // TODO(ahe): Remove this method, called by [Enqueuer], not [FletchEnqueuer]. |
162 void registerDependency(Element element) { | 150 void registerDependency(Element element) { |
163 treeElements.registerDependency(element); | 151 globalRegistry.registerDependency(element); |
164 } | 152 } |
165 } | 153 } |
OLD | NEW |