| 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 universe; | 5 library universe; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../dart2jslib.dart'; | 9 import '../dart2jslib.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 * getter and only registers an invoked getter. | 43 * getter and only registers an invoked getter. |
| 44 */ | 44 */ |
| 45 final Set<Element> fieldGetters; | 45 final Set<Element> fieldGetters; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Fields set. See comment in [fieldGetters]. | 48 * Fields set. See comment in [fieldGetters]. |
| 49 */ | 49 */ |
| 50 final Set<Element> fieldSetters; | 50 final Set<Element> fieldSetters; |
| 51 final Set<DartType> isChecks; | 51 final Set<DartType> isChecks; |
| 52 | 52 |
| 53 /** | |
| 54 * Set of [:call:] methods in instantiated classes that use type variables | |
| 55 * in their signature. | |
| 56 */ | |
| 57 final Set<Element> genericCallMethods; | |
| 58 | |
| 59 /** | |
| 60 * Set of methods in instantiated classes that use type variables in their | |
| 61 * signature and have potentially been closurized. | |
| 62 */ | |
| 63 final Set<Element> closurizedGenericMembers; | |
| 64 | |
| 65 final Set<Element> closurizedMembers; | |
| 66 | |
| 67 bool usingFactoryWithTypeArguments = false; | 53 bool usingFactoryWithTypeArguments = false; |
| 68 | 54 |
| 69 Universe() : instantiatedClasses = new Set<ClassElement>(), | 55 Universe() : instantiatedClasses = new Set<ClassElement>(), |
| 70 instantiatedTypes = new Set<DartType>(), | 56 instantiatedTypes = new Set<DartType>(), |
| 71 staticFunctionsNeedingGetter = new Set<FunctionElement>(), | 57 staticFunctionsNeedingGetter = new Set<FunctionElement>(), |
| 72 invokedNames = new Map<SourceString, Set<Selector>>(), | 58 invokedNames = new Map<SourceString, Set<Selector>>(), |
| 73 invokedGetters = new Map<SourceString, Set<Selector>>(), | 59 invokedGetters = new Map<SourceString, Set<Selector>>(), |
| 74 invokedSetters = new Map<SourceString, Set<Selector>>(), | 60 invokedSetters = new Map<SourceString, Set<Selector>>(), |
| 75 fieldGetters = new Set<Element>(), | 61 fieldGetters = new Set<Element>(), |
| 76 fieldSetters = new Set<Element>(), | 62 fieldSetters = new Set<Element>(), |
| 77 isChecks = new Set<DartType>(), | 63 isChecks = new Set<DartType>(); |
| 78 genericCallMethods = new Set<Element>(), | |
| 79 closurizedGenericMembers = new Set<Element>(), | |
| 80 closurizedMembers = new Set<Element>(); | |
| 81 | 64 |
| 82 bool hasMatchingSelector(Set<Selector> selectors, | 65 bool hasMatchingSelector(Set<Selector> selectors, |
| 83 Element member, | 66 Element member, |
| 84 Compiler compiler) { | 67 Compiler compiler) { |
| 85 if (selectors == null) return false; | 68 if (selectors == null) return false; |
| 86 for (Selector selector in selectors) { | 69 for (Selector selector in selectors) { |
| 87 if (selector.appliesUnnamed(member, compiler)) return true; | 70 if (selector.appliesUnnamed(member, compiler)) return true; |
| 88 } | 71 } |
| 89 return false; | 72 return false; |
| 90 } | 73 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 return hasMatchingSelector(invokedSetters[member.name], member, compiler); | 84 return hasMatchingSelector(invokedSetters[member.name], member, compiler); |
| 102 } | 85 } |
| 103 | 86 |
| 104 bool hasFieldGetter(Element member, Compiler compiler) { | 87 bool hasFieldGetter(Element member, Compiler compiler) { |
| 105 return fieldGetters.contains(member); | 88 return fieldGetters.contains(member); |
| 106 } | 89 } |
| 107 | 90 |
| 108 bool hasFieldSetter(Element member, Compiler compiler) { | 91 bool hasFieldSetter(Element member, Compiler compiler) { |
| 109 return fieldSetters.contains(member); | 92 return fieldSetters.contains(member); |
| 110 } | 93 } |
| 111 | |
| 112 DartType registerIsCheck(DartType type, Compiler compiler) { | |
| 113 type = type.unalias(compiler); | |
| 114 // Even in checked mode, type annotations for return type and argument | |
| 115 // types do not imply type checks, so there should never be a check | |
| 116 // against the type variable of a typedef. | |
| 117 isChecks.add(type); | |
| 118 return type; | |
| 119 } | |
| 120 } | 94 } |
| 121 | 95 |
| 122 class SelectorKind { | 96 class SelectorKind { |
| 123 final String name; | 97 final String name; |
| 124 final int hashCode; | 98 final int hashCode; |
| 125 const SelectorKind(this.name, this.hashCode); | 99 const SelectorKind(this.name, this.hashCode); |
| 126 | 100 |
| 127 static const SelectorKind GETTER = const SelectorKind('getter', 0); | 101 static const SelectorKind GETTER = const SelectorKind('getter', 0); |
| 128 static const SelectorKind SETTER = const SelectorKind('setter', 1); | 102 static const SelectorKind SETTER = const SelectorKind('setter', 1); |
| 129 static const SelectorKind CALL = const SelectorKind('call', 2); | 103 static const SelectorKind CALL = const SelectorKind('call', 2); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // bar() => foo(); // The call to 'foo' is a typed selector. | 507 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 534 // } | 508 // } |
| 535 if (element.getEnclosingClass().isClosure()) { | 509 if (element.getEnclosingClass().isClosure()) { |
| 536 return appliesUntyped(element, compiler); | 510 return appliesUntyped(element, compiler); |
| 537 } | 511 } |
| 538 | 512 |
| 539 if (!mask.canHit(element, this, compiler)) return false; | 513 if (!mask.canHit(element, this, compiler)) return false; |
| 540 return appliesUntyped(element, compiler); | 514 return appliesUntyped(element, compiler); |
| 541 } | 515 } |
| 542 } | 516 } |
| OLD | NEW |