| 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 Universe { | 5 class Universe { |
| 6 Map<Element, String> generatedCode; | 6 Map<Element, String> generatedCode; |
| 7 Map<Element, String> generatedBailoutCode; | 7 Map<Element, String> generatedBailoutCode; |
| 8 final Set<ClassElement> instantiatedClasses; | 8 final Set<ClassElement> instantiatedClasses; |
| 9 final Set<SourceString> instantiatedClassInstanceFields; | 9 final Set<SourceString> instantiatedClassInstanceFields; |
| 10 final Set<FunctionElement> staticFunctionsNeedingGetter; | 10 final Set<FunctionElement> staticFunctionsNeedingGetter; |
| 11 final Map<SourceString, Set<Selector>> invokedNames; | 11 final Map<SourceString, Set<Selector>> invokedNames; |
| 12 final Map<SourceString, Set<Selector>> invokedGetters; | 12 final Map<SourceString, Set<Selector>> invokedGetters; |
| 13 final Map<SourceString, Set<Selector>> invokedSetters; | 13 final Map<SourceString, Set<Selector>> invokedSetters; |
| 14 final Map<SourceString, Set<Selector>> fieldGetters; | |
| 15 final Map<SourceString, Set<Selector>> fieldSetters; | |
| 16 // TODO(ngeoffray): This should be a Set<Type>. | 14 // TODO(ngeoffray): This should be a Set<Type>. |
| 17 final Set<Element> isChecks; | 15 final Set<Element> isChecks; |
| 18 final RuntimeTypeInformation rti; | 16 final RuntimeTypeInformation rti; |
| 19 | 17 |
| 20 Universe() : generatedCode = new Map<Element, String>(), | 18 Universe() : generatedCode = new Map<Element, String>(), |
| 21 generatedBailoutCode = new Map<Element, String>(), | 19 generatedBailoutCode = new Map<Element, String>(), |
| 22 instantiatedClasses = new Set<ClassElement>(), | 20 instantiatedClasses = new Set<ClassElement>(), |
| 23 instantiatedClassInstanceFields = new Set<SourceString>(), | 21 instantiatedClassInstanceFields = new Set<SourceString>(), |
| 24 staticFunctionsNeedingGetter = new Set<FunctionElement>(), | 22 staticFunctionsNeedingGetter = new Set<FunctionElement>(), |
| 25 invokedNames = new Map<SourceString, Set<Selector>>(), | 23 invokedNames = new Map<SourceString, Set<Selector>>(), |
| 26 invokedGetters = new Map<SourceString, Set<Selector>>(), | 24 invokedGetters = new Map<SourceString, Set<Selector>>(), |
| 27 invokedSetters = new Map<SourceString, Set<Selector>>(), | 25 invokedSetters = new Map<SourceString, Set<Selector>>(), |
| 28 fieldGetters = new Map<SourceString, Set<Selector>>(), | |
| 29 fieldSetters = new Map<SourceString, Set<Selector>>(), | |
| 30 isChecks = new Set<Element>(), | 26 isChecks = new Set<Element>(), |
| 31 rti = new RuntimeTypeInformation(); | 27 rti = new RuntimeTypeInformation(); |
| 32 | 28 |
| 33 void addGeneratedCode(WorkItem work, String code) { | 29 void addGeneratedCode(WorkItem work, String code) { |
| 34 generatedCode[work.element] = code; | 30 generatedCode[work.element] = code; |
| 35 } | 31 } |
| 36 | 32 |
| 37 void addBailoutCode(WorkItem work, String code) { | 33 void addBailoutCode(WorkItem work, String code) { |
| 38 generatedBailoutCode[work.element] = code; | 34 generatedBailoutCode[work.element] = code; |
| 39 } | 35 } |
| 40 | 36 |
| 41 bool hasMatchingSelector(Set<Selector> selectors, | 37 bool hasMatchingSelector(Set<Selector> selectors, |
| 42 Element member, | 38 Element member, |
| 43 Compiler compiler) { | 39 Compiler compiler) { |
| 44 if (selectors === null) return false; | 40 if (selectors === null) return false; |
| 45 for (Selector selector in selectors) { | 41 for (Selector selector in selectors) { |
| 46 if (selector.applies(member, compiler)) return true; | 42 if (selector.applies(member, compiler)) return true; |
| 47 } | 43 } |
| 48 return false; | 44 return false; |
| 49 } | 45 } |
| 50 | 46 |
| 51 bool hasInvocation(Element member, Compiler compiler) { | 47 bool hasInvocation(Element member, Compiler compiler) { |
| 52 return hasMatchingSelector(invokedNames[member.name], member, compiler); | 48 return hasMatchingSelector(invokedNames[member.name], member, compiler); |
| 53 } | 49 } |
| 54 | 50 |
| 55 bool hasInvokedGetter(Element member, Compiler compiler) { | 51 bool hasGetter(Element member, Compiler compiler) { |
| 56 return hasMatchingSelector(invokedGetters[member.name], member, compiler); | 52 return hasMatchingSelector(invokedGetters[member.name], member, compiler); |
| 57 } | 53 } |
| 58 | 54 |
| 59 bool hasInvokedSetter(Element member, Compiler compiler) { | 55 bool hasSetter(Element member, Compiler compiler) { |
| 60 return hasMatchingSelector(invokedSetters[member.name], member, compiler); | 56 return hasMatchingSelector(invokedSetters[member.name], member, compiler); |
| 61 } | 57 } |
| 62 | |
| 63 bool hasFieldGetter(Element member, Compiler compiler) { | |
| 64 return hasMatchingSelector(fieldGetters[member.name], member, compiler); | |
| 65 } | |
| 66 | |
| 67 bool hasFieldSetter(Element member, Compiler compiler) { | |
| 68 return hasMatchingSelector(fieldSetters[member.name], member, compiler); | |
| 69 } | |
| 70 } | 58 } |
| 71 | 59 |
| 72 class SelectorKind { | 60 class SelectorKind { |
| 73 final String name; | 61 final String name; |
| 74 const SelectorKind(this.name); | 62 const SelectorKind(this.name); |
| 75 | 63 |
| 76 static final SelectorKind GETTER = const SelectorKind('getter'); | 64 static final SelectorKind GETTER = const SelectorKind('getter'); |
| 77 static final SelectorKind SETTER = const SelectorKind('setter'); | 65 static final SelectorKind SETTER = const SelectorKind('setter'); |
| 78 static final SelectorKind INVOCATION = const SelectorKind('invocation'); | 66 static final SelectorKind INVOCATION = const SelectorKind('invocation'); |
| 79 static final SelectorKind OPERATOR = const SelectorKind('operator'); | 67 static final SelectorKind OPERATOR = const SelectorKind('operator'); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 333 |
| 346 return false; | 334 return false; |
| 347 } | 335 } |
| 348 | 336 |
| 349 bool operator ==(other) { | 337 bool operator ==(other) { |
| 350 if (other is !TypedSelector) return false; | 338 if (other is !TypedSelector) return false; |
| 351 if (other.receiverType !== receiverType) return false; | 339 if (other.receiverType !== receiverType) return false; |
| 352 return super == other; | 340 return super == other; |
| 353 } | 341 } |
| 354 } | 342 } |
| OLD | NEW |