- int i;
- if (container.MemberCache.member_hash.TryGetValue (filter.Name, out applicable)) {
- for (i = 0; i < applicable.Count; ++i) {
- var entry = applicable [i];
-
- // Is the member of the correct type
- if ((entry.Kind & filter.Kind & MemberKind.MaskType) == 0)
- continue;
-
- //
- // When using overloadable overrides filter ignore members which
- // are not base members. Including properties because overrides can
- // implement get or set only and we are looking for complete base member
- //
- const MemberKind overloadable = MemberKind.Indexer | MemberKind.Method | MemberKind.Property;
- if ((restrictions & BindingRestriction.NoOverrides) != 0 && (entry.Kind & overloadable) != 0) {
- if ((entry.Modifiers & Modifiers.OVERRIDE) != 0)
- continue;
-
- if ((entry.Modifiers & Modifiers.OVERRIDE_UNCHECKED) != 0) {
- bool is_override = true;
- var ms = entry as MethodSpec;
- if (ms != null) {
- is_override = IsRealMethodOverride (ms);
- } else {
- var ps = (PropertySpec) entry;
- if (ps.HasGet)
- is_override = IsRealMethodOverride (ps.Get);
- if (is_override && ps.HasSet)
- is_override = IsRealMethodOverride (ps.Set);
- }
-
- if (is_override) {
- entry.Modifiers = (entry.Modifiers & ~Modifiers.OVERRIDE_UNCHECKED) | Modifiers.OVERRIDE;
- continue;
- }
- }
- }
-
- if ((restrictions & BindingRestriction.InstanceOnly) != 0 && entry.IsStatic)
- continue;
-
- // Apply the filter to it.
- if (!filter.Equals (entry))
- continue;
-
- // Try not to allocate a new list until it's necessary
- if (found == null) {
- if (i == match_counter) {
- ++match_counter;
- continue;
- }
-
- found = new List<MemberSpec> (System.Math.Max (4, match_counter + 1));
- for (int ii = 0; ii < match_counter; ++ii)
- found.Add (applicable [ii]);
- }
-
- found.Add (entry);
- }
-
- // Deal with allocation-less optimization
- if ((restrictions & (BindingRestriction.DeclaredOnly | BindingRestriction.StopOnFirstMatch)) != 0) {
- if (found != null)
- return found;
-
- if (i == match_counter)
- return applicable;
-
- if (match_counter > 0) {
- found = new List<MemberSpec> (match_counter);
- for (int ii = 0; ii < match_counter; ++ii)
- found.Add (applicable[ii]);
-
- return found;
- }
-
- if ((restrictions & BindingRestriction.DeclaredOnly) != 0)
- return null;
- } else if (found == null) {
- if (i == match_counter) {
- found = new List<MemberSpec> (applicable);
- } else if (match_counter > 0) {
- found = new List<MemberSpec> (System.Math.Max (4, match_counter));
- for (int ii = 0; ii < match_counter; ++ii)
- found.Add (applicable[ii]);
- }
- }
- }