예제 #1
0
        private void putProperties(TypeInfo declaringType, Map <String, MemberInfo> members)
        {
            var getters = new HashMap <String, MethodInfo>();
            var setters = new HashMap <String, MethodInfo>();

            foreach (var method in declaringType.Methods.where (p => !p.IsSynthetic && !p.Name.startsWith("<")))
            {
                foreach (var annotation in BytecodeHelper.getAnnotations(annotatedTypeSystem, method))
                {
                    if (BytecodeHelper.isPropertyGet(annotation))
                    {
                        var name = BytecodeHelper.getPropertyGetName(method, annotation);
                        getters[name] = method;
                        break;
                    }
                    if (BytecodeHelper.isPropertySet(annotation))
                    {
                        var name = BytecodeHelper.getPropertySetName(method, annotation);
                        setters[name] = method;
                        break;
                    }
                }
            }
            foreach (var e in getters.entrySet())
            {
                var setter = setters.remove(e.Key);
                var member = MemberInfo.getInfo(e.Value, setter, e.Key);
                members[e.Key] = member;
            }
            foreach (var e in setters.entrySet())
            {
                var member = MemberInfo.getInfo(null, e.Value, e.Key);
                members[e.Key] = member;
            }
        }
예제 #2
0
 public override Iterable <MemberInfo> getOverridenMembers(Library typeSystem)
 {
     if (overridenMembers == null)
     {
         if (!this.IsStatic)
         {
             foreach (var t in this.DeclaringType.getBaseTypes())
             {
                 MethodInfo get = null;
                 MethodInfo set = null;
                 foreach (var m in t.Methods)
                 {
                     var pinfo = m.getUserData(typeof(PropertyMemberInfo));
                     if (pinfo != null)
                     {
                         if (!pinfo.Name.equals(name) || pinfo.IsStatic)
                         {
                             continue;
                         }
                         if (!pinfo.IsPrivate)
                         {
                             if (overridenMembers == null)
                             {
                                 overridenMembers = new HashSet <MemberInfo>();
                             }
                             overridenMembers.add(pinfo);
                         }
                         break;
                     }
                     foreach (var annotation in BytecodeHelper.getAnnotations(typeSystem, m))
                     {
                         if (BytecodeHelper.isPropertyGet(annotation) && name.equals(BytecodeHelper.getPropertyGetName(m, annotation)))
                         {
                             get = m;
                             break;
                         }
                         if (BytecodeHelper.isPropertySet(annotation) && name.equals(BytecodeHelper.getPropertySetName(m, annotation)))
                         {
                             set = m;
                             break;
                         }
                     }
                 }
                 if (get != null || set != null)
                 {
                     if (overridenMembers == null)
                     {
                         overridenMembers = new HashSet <MemberInfo>();
                     }
                     overridenMembers.add(MemberInfo.getInfo(get, set, name));
                 }
             }
         }
         if (overridenMembers == null)
         {
             overridenMembers = Collections.emptySet <MemberInfo>();
         }
     }
     return(overridenMembers);
 }