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 library dart2js.enqueue; | 5 library dart2js.enqueue; |
6 | 6 |
7 import 'dart:collection' show | 7 import 'dart:collection' show |
8 Queue; | 8 Queue; |
9 | 9 |
| 10 import 'common/names.dart' show |
| 11 Identifiers; |
10 import 'common/work.dart' show | 12 import 'common/work.dart' show |
11 ItemCompilationContext, | 13 ItemCompilationContext, |
12 WorkItem; | 14 WorkItem; |
13 import 'common/tasks.dart' show | 15 import 'common/tasks.dart' show |
14 CompilerTask, | 16 CompilerTask, |
15 DeferredAction, | 17 DeferredAction, |
16 DeferredTask; | 18 DeferredTask; |
17 import 'common/registry.dart' show | 19 import 'common/registry.dart' show |
18 Registry; | 20 Registry; |
19 import 'common/codegen.dart' show | 21 import 'common/codegen.dart' show |
(...skipping 15 matching lines...) Expand all Loading... |
35 ClassElement, | 37 ClassElement, |
36 ConstructorElement, | 38 ConstructorElement, |
37 Element, | 39 Element, |
38 Elements, | 40 Elements, |
39 FunctionElement, | 41 FunctionElement, |
40 LibraryElement, | 42 LibraryElement, |
41 LocalFunctionElement, | 43 LocalFunctionElement, |
42 Member, | 44 Member, |
43 MemberElement, | 45 MemberElement, |
44 MethodElement, | 46 MethodElement, |
| 47 Name, |
45 TypedElement, | 48 TypedElement, |
46 TypedefElement; | 49 TypedefElement; |
47 import 'js/js.dart' as js; | 50 import 'js/js.dart' as js; |
48 import 'native/native.dart' as native; | 51 import 'native/native.dart' as native; |
49 import 'resolution/members.dart' show | 52 import 'resolution/members.dart' show |
50 ResolverVisitor; | 53 ResolverVisitor; |
51 import 'tree/tree.dart' show | 54 import 'tree/tree.dart' show |
52 Send; | 55 Send; |
53 import 'universe/universe.dart'; | 56 import 'universe/universe.dart'; |
54 import 'util/util.dart' show | 57 import 'util/util.dart' show |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } else { | 242 } else { |
240 // All field initializers must be resolved as they could | 243 // All field initializers must be resolved as they could |
241 // have an observable side-effect (and cannot be tree-shaken | 244 // have an observable side-effect (and cannot be tree-shaken |
242 // away). | 245 // away). |
243 addToWorkList(member); | 246 addToWorkList(member); |
244 return; | 247 return; |
245 } | 248 } |
246 } else if (member.isFunction) { | 249 } else if (member.isFunction) { |
247 FunctionElement function = member; | 250 FunctionElement function = member; |
248 function.computeType(compiler); | 251 function.computeType(compiler); |
249 if (function.name == Compiler.NO_SUCH_METHOD) { | 252 if (function.name == Identifiers.noSuchMethod_) { |
250 registerNoSuchMethod(function); | 253 registerNoSuchMethod(function); |
251 } | 254 } |
252 if (function.name == Compiler.CALL_OPERATOR_NAME && | 255 if (function.name == Identifiers.call && |
253 !cls.typeVariables.isEmpty) { | 256 !cls.typeVariables.isEmpty) { |
254 registerCallMethodWithFreeTypeVariables( | 257 registerCallMethodWithFreeTypeVariables( |
255 function, compiler.globalDependencies); | 258 function, compiler.globalDependencies); |
256 } | 259 } |
257 // If there is a property access with the same name as a method we | 260 // If there is a property access with the same name as a method we |
258 // need to emit the method. | 261 // need to emit the method. |
259 if (universe.hasInvokedGetter(function, compiler.world)) { | 262 if (universe.hasInvokedGetter(function, compiler.world)) { |
260 registerClosurizedMember(function, compiler.globalDependencies); | 263 registerClosurizedMember(function, compiler.globalDependencies); |
261 addToWorkList(function); | 264 addToWorkList(function); |
262 return; | 265 return; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 registerStaticUse(element.declaration); | 407 registerStaticUse(element.declaration); |
405 } else if (element.isInstanceMember) { | 408 } else if (element.isInstanceMember) { |
406 // We need to enqueue all members matching this one in subclasses, as | 409 // We need to enqueue all members matching this one in subclasses, as |
407 // well. | 410 // well. |
408 // TODO(herhut): Use TypedSelector.subtype for enqueueing | 411 // TODO(herhut): Use TypedSelector.subtype for enqueueing |
409 UniverseSelector selector = new UniverseSelector( | 412 UniverseSelector selector = new UniverseSelector( |
410 new Selector.fromElement(element), null); | 413 new Selector.fromElement(element), null); |
411 registerSelectorUse(selector); | 414 registerSelectorUse(selector); |
412 if (element.isField) { | 415 if (element.isField) { |
413 UniverseSelector selector = new UniverseSelector( | 416 UniverseSelector selector = new UniverseSelector( |
414 new Selector.setter(element.name, element.library), null); | 417 new Selector.setter(new Name( |
| 418 element.name, element.library, isSetter: true)), null); |
415 registerInvokedSetter(selector); | 419 registerInvokedSetter(selector); |
416 } | 420 } |
417 } | 421 } |
418 } | 422 } |
419 } | 423 } |
420 | 424 |
421 /// Enqeue the member [element] if it is required for reflection. | 425 /// Enqeue the member [element] if it is required for reflection. |
422 /// | 426 /// |
423 /// [enclosingWasIncluded] provides a hint whether the enclosing element was | 427 /// [enclosingWasIncluded] provides a hint whether the enclosing element was |
424 /// needed for reflection. | 428 /// needed for reflection. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 } else if (uri == 'dart:async') { | 817 } else if (uri == 'dart:async') { |
814 if (element.name == '_createTimer' || | 818 if (element.name == '_createTimer' || |
815 element.name == '_createPeriodicTimer') { | 819 element.name == '_createPeriodicTimer') { |
816 // The [:Timer:] class uses the event queue of the isolate | 820 // The [:Timer:] class uses the event queue of the isolate |
817 // library, so we make sure that event queue is generated. | 821 // library, so we make sure that event queue is generated. |
818 enableIsolateSupport(); | 822 enableIsolateSupport(); |
819 } | 823 } |
820 } | 824 } |
821 } | 825 } |
822 | 826 |
823 if (element.isGetter && element.name == Compiler.RUNTIME_TYPE) { | 827 if (element.isGetter && element.name == Identifiers.runtimeType_) { |
824 // Enable runtime type support if we discover a getter called runtimeType. | 828 // Enable runtime type support if we discover a getter called runtimeType. |
825 // We have to enable runtime type before hitting the codegen, so | 829 // We have to enable runtime type before hitting the codegen, so |
826 // that constructors know whether they need to generate code for | 830 // that constructors know whether they need to generate code for |
827 // runtime type. | 831 // runtime type. |
828 compiler.enabledRuntimeType = true; | 832 compiler.enabledRuntimeType = true; |
829 // TODO(ahe): Record precise dependency here. | 833 // TODO(ahe): Record precise dependency here. |
830 compiler.backend.registerRuntimeType(this, compiler.globalDependencies); | 834 compiler.backend.registerRuntimeType(this, compiler.globalDependencies); |
831 } else if (element == compiler.functionApplyMethod) { | 835 } else if (element == compiler.functionApplyMethod) { |
832 compiler.enabledFunctionApply = true; | 836 compiler.enabledFunctionApply = true; |
833 } | 837 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 void processWorkItem(void f(WorkItem work), WorkItem work) { | 1012 void processWorkItem(void f(WorkItem work), WorkItem work) { |
1009 f(work); | 1013 f(work); |
1010 } | 1014 } |
1011 } | 1015 } |
1012 | 1016 |
1013 void removeFromSet(Map<String, Set<Element>> map, Element element) { | 1017 void removeFromSet(Map<String, Set<Element>> map, Element element) { |
1014 Set<Element> set = map[element.name]; | 1018 Set<Element> set = map[element.name]; |
1015 if (set == null) return; | 1019 if (set == null) return; |
1016 set.remove(element); | 1020 set.remove(element); |
1017 } | 1021 } |
OLD | NEW |