Esempio n. 1
0
        public override AstNode Visit(PropertyDefinition node)
        {
            // Add the parent static flag.
            if (currentContainer.IsStatic())
            {
                MemberFlags oldInstance = node.GetFlags() & MemberFlags.InstanceMask;
                if (oldInstance == MemberFlags.Static || oldInstance == MemberFlags.Instanced)
                {
                    MemberFlags flags = node.GetFlags() & ~MemberFlags.InstanceMask;
                    node.SetFlags(flags | MemberFlags.Static);
                }
                else
                {
                    Error(node, "static class member cannot {0}.", oldInstance.ToString().ToLower());
                }
            }

            // Add the parent unsafe flag.
            if (IsUnsafe)
            {
                MemberFlags flags = node.GetFlags() & ~MemberFlags.SecurityMask;
                node.SetFlags(flags | MemberFlags.Unsafe);
            }

            // Link the accessors.
            AstNode acc = node.GetAccessors();

            while (acc != null)
            {
                PropertyAccessor pacc = (PropertyAccessor)acc;
                if (pacc.IsGetAccessor())
                {
                    if (node.GetAccessor != null)
                    {
                        Error(node, "a property only can have one get accessor.");
                    }
                    node.GetAccessor = (GetAccessorDefinition)pacc;
                }
                else
                {
                    if (node.SetAccessor != null)
                    {
                        Error(node, "a property only can have one set accessor.");
                    }
                    node.SetAccessor = (SetAccessorDefinition)pacc;
                }

                acc = acc.GetNext();
            }

            return(node);
        }