stringList GetMethodModifiers(MetaDataMethod m) { stringList mods = new stringList(); switch (m.Flags & (int)(MethodAttributes.MemberAccessMask)) { case (int)MethodAttributes.Private: mods.Add("private"); break; case (int)MethodAttributes.FamORAssem: mods.Add("protected"); mods.Add("internal"); break; case (int)MethodAttributes.Assem: mods.Add("internal"); break; case (int)MethodAttributes.Family: mods.Add("protected"); break; case (int)MethodAttributes.Public: mods.Add("public"); break; } if ((m.Flags & (int)MethodAttributes.Final) != 0) { mods.Add("sealed"); } if ((m.Flags & (int)MethodAttributes.Virtual) != 0) { mods.Add("virtual"); } if ((m.Flags & (int)MethodAttributes.Static) != 0) { mods.Add("static"); } if ((m.Flags & (int)MethodAttributes.Abstract) != 0) { mods.Add("abstract"); } return(mods); }
public static MetaDataCustomAttribute MethodFindAttribute(MetaDataMethod method, MetaDataTypeDefinition type) { if (method.CustomAttributes != null) { foreach (MetaDataCustomAttribute attribute in method.CustomAttributes) { if (attribute.TypeDefOrRef == type) { return(attribute); } } } return(null); }
Method GetMethod(Method m, MetaDataMethod x, string path) { m.Modifiers = GetMethodModifiers(x); m.Type = GetType(x.Signature.ReturnType, path); for (int i = 0; i < x.Parameters.Length; i++) { Formal f; MetaDataParam p = x.Parameters[i]; if (i == x.Parameters.Length - 1 && m.Name == "set_Item") { f = m.AddFormal(new InputElement("value"), msg); m.signature.formals.Remove(f); } else { f = m.AddFormal(new InputElement(String.Format("arg{0}", i + 1)), msg); } f.Type = GetType(x.Signature.Parameters[i].Type, path); if ((p.Flags & ((int)MetaDataParam.ParamAttributes.Out)) != 0) { f.modifier = new InputElement("out"); } else if (f.Type is ManagedPointerType) { f.modifier = new InputElement("ref"); } if (f.Type is ManagedPointerType) { f.Type = ((ManagedPointerType)f.Type).elementType; } else if (p.CustomAttributes != null) { foreach (MetaDataCustomAttribute a in p.CustomAttributes) { MetaDataMethod t = a.Type as MetaDataMethod; if (t != null && t.Parent != null && t.Parent.Name == "ParamArrayAttribute") { f.IsParams = true; break; } } } } return(m); }
Method GetMethod(ClassType t, string name, MetaDataMethod x, string path) { return(GetMethod(t.AddMethod(new InputElement(name), msg), x, path)); }