コード例 #1
0
        public virtual object VisitDelegateDeclaration(DelegateNode delegateDeclaration, object data)
        {
            stackMap.Push(delegateDeclaration);
            delegateDeclaration.Attributes.AcceptVisitor(this, data);

            delegateDeclaration.Type.AcceptVisitor(this, data);

            delegateDeclaration.Params.AcceptVisitor(this, data);

            if (delegateDeclaration.Generic != null)
            {
                delegateDeclaration.Generic.AcceptVisitor(this, data);
            }

            stackMap.Pop();
            return(null);
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: mintberry/stackrecaller
		private void ParseDelegate()										
		{
			DelegateNode node = new DelegateNode(curtok);

			if (curAttributes.Count > 0)
			{
				node.Attributes = curAttributes;
				curAttributes = new NodeCollection<AttributeNode>();
			}

			uint delegateMask = ~(uint)Modifier.DelegateMods;
			if (((uint)curmods & delegateMask) != (uint)Modifier.Empty)
				ReportError("Delegate contains illegal modifiers");

			node.Modifiers = curmods;
			curmods = Modifier.Empty;

            if ((node.Modifiers & Modifier.Unsafe) != Modifier.Empty)
            {
                //unsafe modifier -> unsafe type.
                isUnsafe++;
                node.IsUnsafeDeclared = true;
            }
                //the delegate is declared in an unsafe type ?
                node.IsUnsafe = isUnsafe > 0;
 
			Advance(); // advance over delegate token
			node.Type = ParseType();
            node.Name = (IdentifierExpression)ParseIdentifierOrKeyword(false, false, false, true);

            ParsePossibleTypeParameterNode(true, true, false);
            ApplyTypeParameters(node);

            CheckTypeUnicityAndAdd(node);


			node.Params = ParseParamList();

            ParsePossibleTypeParameterConstraintNode(node);
            ApplyTypeParameterConstraints(node);

            ClassNode cl = typeStack.Count == 0 ? null : typeStack.Peek();

            if (cl == null)
            {
                namespaceStack.Peek().Delegates.Add(node);
            }
            else
            {
                cl.Delegates.Add(node);
            }

            if ((node.Modifiers & Modifier.Unsafe) != Modifier.Empty)
            {
                //unsafe modifier -> unsafe type.
                isUnsafe--;
            }

			AssertAndAdvance(TokenID.Semi);

            if (node.IsGeneric)
            {
                this.nameTable.AddIdentifier(new DelegateName(node.Name.Identifier,
                    ToVisibilityRestriction(node.Modifiers),
                    node.Generic.TypeParameters.ConvertAll<string>(delegate(TypeParameterNode input) { return input.Identifier.Identifier; }).ToArray(),
                    this.currentContext));
            }
            else
            {
                this.nameTable.AddIdentifier(new DelegateName(node.Name.Identifier,
                    ToVisibilityRestriction(node.Modifiers),
                    this.currentContext));
            }
        }
コード例 #3
0
        public virtual object VisitDelegateDeclaration(DelegateNode delegateDeclaration, object data)
        {
            stackMap.Push(delegateDeclaration);
            delegateDeclaration.Attributes.AcceptVisitor(this, data);

            delegateDeclaration.Type.AcceptVisitor(this, data);

            delegateDeclaration.Params.AcceptVisitor(this, data);

            if (delegateDeclaration.Generic != null)
            {
                delegateDeclaration.Generic.AcceptVisitor(this, data);
            }

            stackMap.Pop();
            return null;
        }