public virtual object VisitConstructorDeclaration(ConstructorNode constructorDeclaration, object data) { stackMap.Push(constructorDeclaration); constructorDeclaration.Attributes.AcceptVisitor(this, data); constructorDeclaration.Params.AcceptVisitor(this, data); if (constructorDeclaration.ThisBaseArgs != null) { constructorDeclaration.ThisBaseArgs.AcceptVisitor(this, data); } constructorDeclaration.StatementBlock.AcceptVisitor(this, data); stackMap.Pop(); return(null); }
private void ParseCtor(TypeNode type) { ConstructorNode node = new ConstructorNode(curtok); if (curAttributes.Count > 0) { node.Attributes = curAttributes; curAttributes = new NodeCollection<AttributeNode>(); } if ((curmods & Modifier.Static) != Modifier.Empty) { node.IsStaticConstructor = true; curmods = curmods & ~Modifier.Static; } uint mask = ~(uint)Modifier.ConstructorMods; if (((uint)curmods & mask) != (uint)Modifier.Empty) ReportError("constructor declaration contains illegal modifiers"); ClassNode cl = typeStack.Peek(); cl.Constructors.Add(node); //node.Attributes.Add(curAttributes); //curAttributes.Clear(); node.Modifiers = curmods; curmods = Modifier.Empty; if ((node.Modifiers & Modifier.Unsafe) != Modifier.Empty) { //unsafe modifier -> unsafe type. isUnsafe++; node.IsUnsafeDeclared = true; } //the constructor is declared in an unsafe type ? node.IsUnsafe = isUnsafe > 0; if (node.IsStaticConstructor) { CheckStaticClass(cl, node.Modifiers | Modifier.Static, true); } else { CheckStaticClass(cl, node.Modifiers, true); } node.Type = type; QualifiedIdentifierExpression nameCtor = new QualifiedIdentifierExpression(node.RelatedToken); nameCtor.Expressions.Add(typeStack.Peek().Name); node.Names.Add( nameCtor ); // starts at LParen node.Params = ParseParamList(); if (curtok.ID == TokenID.Colon) { Advance(); if (curtok.ID == TokenID.Base) { Advance(); node.HasBase = true; node.ThisBaseArgs = ParseArgs(); } else if (curtok.ID == TokenID.This) { Advance(); node.HasThis = true; node.ThisBaseArgs = ParseArgs(); } else { RecoverFromError("constructor requires this or base calls after colon", TokenID.Base); } } ParseBlock(node.StatementBlock); if ((node.Modifiers & Modifier.Unsafe) != Modifier.Empty) { //unsafe modifier -> unsafe type. isUnsafe--; } }
public virtual object VisitConstructorDeclaration(ConstructorNode constructorDeclaration, object data) { stackMap.Push(constructorDeclaration); constructorDeclaration.Attributes.AcceptVisitor(this, data); constructorDeclaration.Params.AcceptVisitor(this, data); if (constructorDeclaration.ThisBaseArgs != null) { constructorDeclaration.ThisBaseArgs.AcceptVisitor(this, data); } constructorDeclaration.StatementBlock.AcceptVisitor(this, data); stackMap.Pop(); return null; }