Ejemplo n.º 1
0
        private void AddMember(Class declaring, LanguageItemCollection lang, NCC.IMember member)
        {
            // Do not add property getters and setters, not events adders and removers,
            // nor overloaded operators, nor enum value__, not Nemerle internal methods
            if (member.Name.StartsWith("_N") || member.Name.StartsWith("get_") ||
                member.Name.StartsWith("set_") || member.Name == "value__" ||
                member.Name.StartsWith("op_") || member.Name.StartsWith("add_") ||
                member.Name.StartsWith("remove_"))
            {
                return;
            }

            try
            {
                if (member is NCC.IField)
                {
                    lang.Add(new NemerleBinding.Parser.SharpDevelopTree.Field(declaring, (NCC.IField)member));
                }
                else if (member is NCC.IMethod)
                {
                    lang.Add(new Method(declaring, (NCC.IMethod)member));
                }
                else if (member is NCC.IProperty)
                {
                    NCC.IProperty prop = (NCC.IProperty)member;
                    if (prop.IsIndexer)
                    {
                        lang.Add(new Indexer(declaring, prop));
                    }
                    else
                    {
                        lang.Add(new Property(declaring, prop));
                    }
                }
                else if (member is NCC.IEvent)
                {
                    lang.Add(new Event(declaring, (NCC.IEvent)member));
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        public Indexer(Class declaringType, NCC.IProperty tinfo)
        {
            this.declaringType = declaringType;

            ModifierEnum mod = (ModifierEnum)0;

            if ((tinfo.Attributes & NCC.NemerleAttributes.Private) != 0)
            {
                mod |= ModifierEnum.Private;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Internal) != 0)
            {
                mod |= ModifierEnum.Internal;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Protected) != 0)
            {
                mod |= ModifierEnum.Protected;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Public) != 0)
            {
                mod |= ModifierEnum.Public;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Abstract) != 0)
            {
                mod |= ModifierEnum.Abstract;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Sealed) != 0)
            {
                mod |= ModifierEnum.Sealed;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Static) != 0)
            {
                mod |= ModifierEnum.Static;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Override) != 0)
            {
                mod |= ModifierEnum.Override;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Virtual) != 0)
            {
                mod |= ModifierEnum.Virtual;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.New) != 0)
            {
                mod |= ModifierEnum.New;
            }
            if ((tinfo.Attributes & NCC.NemerleAttributes.Extern) != 0)
            {
                mod |= ModifierEnum.Extern;
            }

            modifiers = mod;

            this.FullyQualifiedName = tinfo.Name;
            returnType  = new ReturnType(tinfo.GetMemType());
            this.region = Class.GetRegion(tinfo.Location);
            if (tinfo is NCC.MemberBuilder)
            {
                this.bodyRegion = Class.GetRegion(((NCC.MemberBuilder)tinfo).BodyLocation);
            }
            else
            {
                this.bodyRegion = Class.GetRegion(tinfo.Location);
            }

            NCC.IMethod getter = tinfo.GetGetter();
            NCC.IMethod setter = tinfo.GetSetter();
            if (getter != null)
            {
                this.Getter = new Method(declaringType, getter);
                if (getter is NCC.MemberBuilder)
                {
                    getterRegion = Class.GetRegion(((NCC.MemberBuilder)getter).BodyLocation);
                }
                else
                {
                    getterRegion = Class.GetRegion(getter.Location);
                }
            }
            if (setter != null)
            {
                this.Setter = new Method(declaringType, setter);
                if (setter is NCC.MemberBuilder)
                {
                    setterRegion = Class.GetRegion(((NCC.MemberBuilder)setter).BodyLocation);
                }
                else
                {
                    setterRegion = Class.GetRegion(setter.Location);
                }
            }

            LoadXml(declaringType);

            // Add parameters
            if (getter != null)
            {
                foreach (Fun_parm pinfo in getter.GetParameters())
                {
                    parameters.Add(new Parameter(this, pinfo, node));
                }
            }
        }