| 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 class EnqueueTask extends CompilerTask { | 5 class EnqueueTask extends CompilerTask { |
| 6 final Enqueuer codegen; | 6 final Enqueuer codegen; |
| 7 final Enqueuer resolution; | 7 final Enqueuer resolution; |
| 8 | 8 |
| 9 String get name() => 'Enqueue'; | 9 String get name() => 'Enqueue'; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 : instanceMembersByName = new Map<String, Link<Element>>(), | 30 : instanceMembersByName = new Map<String, Link<Element>>(), |
| 31 seenClasses = new Set<ClassElement>(), | 31 seenClasses = new Set<ClassElement>(), |
| 32 universe = new Universe(), | 32 universe = new Universe(), |
| 33 queue = new Queue<WorkItem>(); | 33 queue = new Queue<WorkItem>(); |
| 34 | 34 |
| 35 void addToWorkList(Element element, [TreeElements elements]) { | 35 void addToWorkList(Element element, [TreeElements elements]) { |
| 36 if (queueIsClosed) { | 36 if (queueIsClosed) { |
| 37 compiler.internalErrorOnElement(element, "Work list is closed."); | 37 compiler.internalErrorOnElement(element, "Work list is closed."); |
| 38 } | 38 } |
| 39 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) { | 39 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) { |
| 40 compiler.registerInstantiatedClass(element.enclosingElement); | 40 registerInstantiatedClass(element.enclosingElement); |
| 41 } | 41 } |
| 42 queue.add(new WorkItem(element, elements)); | 42 queue.add(new WorkItem(element, elements)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void registerInstantiatedClass(ClassElement cls) { | 45 void registerInstantiatedClass(ClassElement cls) { |
| 46 universe.instantiatedClasses.add(cls); | 46 universe.instantiatedClasses.add(cls); |
| 47 onRegisterInstantiatedClass(cls); | 47 onRegisterInstantiatedClass(cls); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool checkNoEnqueuedInvokedInstanceMethods() { | 50 bool checkNoEnqueuedInvokedInstanceMethods() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 70 // Make sure that the closure understands a call with the given | 70 // Make sure that the closure understands a call with the given |
| 71 // selector. For a method-invocation of the form o.foo(a: 499), we | 71 // selector. For a method-invocation of the form o.foo(a: 499), we |
| 72 // need to make sure that closures can handle the optional argument if | 72 // need to make sure that closures can handle the optional argument if |
| 73 // there exists a field or getter 'foo'. | 73 // there exists a field or getter 'foo'. |
| 74 var names = universe.instantiatedClassInstanceFields; | 74 var names = universe.instantiatedClassInstanceFields; |
| 75 // TODO(ahe): Might be enough to use invokedGetters. | 75 // TODO(ahe): Might be enough to use invokedGetters. |
| 76 for (SourceString name in names) { | 76 for (SourceString name in names) { |
| 77 Set<Selector> invokedSelectors = universe.invokedNames[name]; | 77 Set<Selector> invokedSelectors = universe.invokedNames[name]; |
| 78 if (invokedSelectors != null) { | 78 if (invokedSelectors != null) { |
| 79 for (Selector selector in invokedSelectors) { | 79 for (Selector selector in invokedSelectors) { |
| 80 compiler.registerDynamicInvocation(Namer.CLOSURE_INVOCATION_NAME, | 80 registerDynamicInvocation(Namer.CLOSURE_INVOCATION_NAME, selector); |
| 81 selector); | |
| 82 } | 81 } |
| 83 } | 82 } |
| 84 } | 83 } |
| 85 }); | 84 }); |
| 86 } | 85 } |
| 87 | 86 |
| 88 void processInstantiatedClassMember(Element member) { | 87 void processInstantiatedClassMember(Element member) { |
| 89 if (universe.generatedCode.containsKey(member)) return; | 88 if (universe.generatedCode.containsKey(member)) return; |
| 90 | 89 |
| 91 if (!member.isInstanceMember()) return; | 90 if (!member.isInstanceMember()) return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 107 } | 106 } |
| 108 if (universe.hasInvocation(member, compiler)) { | 107 if (universe.hasInvocation(member, compiler)) { |
| 109 return addToWorkList(member); | 108 return addToWorkList(member); |
| 110 } | 109 } |
| 111 // If there is a property access with the same name as a method we | 110 // If there is a property access with the same name as a method we |
| 112 // need to emit the method. | 111 // need to emit the method. |
| 113 if (universe.hasGetter(member, compiler)) { | 112 if (universe.hasGetter(member, compiler)) { |
| 114 // We will emit a closure, so make sure the closure class is | 113 // We will emit a closure, so make sure the closure class is |
| 115 // generated. | 114 // generated. |
| 116 compiler.closureClass.ensureResolved(compiler); | 115 compiler.closureClass.ensureResolved(compiler); |
| 117 compiler.registerInstantiatedClass(compiler.closureClass); | 116 registerInstantiatedClass(compiler.closureClass); |
| 118 return addToWorkList(member); | 117 return addToWorkList(member); |
| 119 } | 118 } |
| 120 } else if (member.kind == ElementKind.GETTER) { | 119 } else if (member.kind == ElementKind.GETTER) { |
| 121 if (universe.hasGetter(member, compiler)) { | 120 if (universe.hasGetter(member, compiler)) { |
| 122 return addToWorkList(member); | 121 return addToWorkList(member); |
| 123 } | 122 } |
| 124 // We don't know what selectors the returned closure accepts. If | 123 // We don't know what selectors the returned closure accepts. If |
| 125 // the set contains any selector we have to assume that it matches. | 124 // the set contains any selector we have to assume that it matches. |
| 126 if (universe.hasInvocation(member, compiler)) { | 125 if (universe.hasInvocation(member, compiler)) { |
| 127 return addToWorkList(member); | 126 return addToWorkList(member); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 189 |
| 191 void handleUnseenSelector(SourceString methodName, Selector selector) { | 190 void handleUnseenSelector(SourceString methodName, Selector selector) { |
| 192 processInstanceMembers(methodName, (Element member) { | 191 processInstanceMembers(methodName, (Element member) { |
| 193 if (selector.applies(member, compiler)) { | 192 if (selector.applies(member, compiler)) { |
| 194 addToWorkList(member); | 193 addToWorkList(member); |
| 195 return true; | 194 return true; |
| 196 } | 195 } |
| 197 return false; | 196 return false; |
| 198 }); | 197 }); |
| 199 } | 198 } |
| 199 |
| 200 void registerStaticUse(Element element) { |
| 201 addToWorkList(element); |
| 202 } |
| 203 |
| 204 void registerGetOfStaticFunction(FunctionElement element) { |
| 205 registerStaticUse(element); |
| 206 universe.staticFunctionsNeedingGetter.add(element); |
| 207 } |
| 208 |
| 209 void registerDynamicInvocation(SourceString methodName, Selector selector) { |
| 210 assert(selector !== null); |
| 211 registerInvocation(methodName, selector); |
| 212 } |
| 213 |
| 214 void registerDynamicInvocationOf(Element element) { |
| 215 addToWorkList(element); |
| 216 } |
| 217 |
| 218 void registerDynamicGetter(SourceString methodName, Selector selector) { |
| 219 registerGetter(methodName, selector); |
| 220 } |
| 221 |
| 222 void registerDynamicSetter(SourceString methodName, Selector selector) { |
| 223 registerSetter(methodName, selector); |
| 224 } |
| 225 |
| 226 // TODO(ngeoffray): This should get a type. |
| 227 void registerIsCheck(Element element) { |
| 228 universe.isChecks.add(element); |
| 229 } |
| 200 } | 230 } |
| OLD | NEW |