// TODO: OptionCompareDeclaration, OptionExplicitDeclaration, OptionStrictDeclaration public override object Visit(TypeDeclaration typeDeclaration, object data) { // skip nested types. if (currentTypeDeclaration != null) { return data; } if (typeDeclaration.Type == Types.Enum) { return data; } this.currentTypeDeclaration = typeDeclaration; CodeTypeDeclaration codeTypeDeclaration = new CodeTypeDeclaration(typeDeclaration.Name); codeTypeDeclaration.IsClass = typeDeclaration.Type == Types.Class; codeTypeDeclaration.IsEnum = typeDeclaration.Type == Types.Enum; codeTypeDeclaration.IsInterface = typeDeclaration.Type == Types.Interface; codeTypeDeclaration.IsStruct = typeDeclaration.Type == Types.Structure; if (typeDeclaration.BaseType != null) { codeTypeDeclaration.BaseTypes.Add(new CodeTypeReference(typeDeclaration.BaseType)); } if (typeDeclaration.BaseInterfaces != null) { foreach (object o in typeDeclaration.BaseInterfaces) { codeTypeDeclaration.BaseTypes.Add(new CodeTypeReference(o.ToString())); } } typeDeclarations.Push(codeTypeDeclaration); typeDeclaration.AcceptChildren(this,data); // ((INode)typeDeclaration.Children[0]).(this, data); typeDeclarations.Pop(); ((CodeNamespace)namespaceDeclarations.Peek()).Types.Add(codeTypeDeclaration); this.currentTypeDeclaration = null; return null; }
void InterfaceBody( #line 748 "VBNET.ATG" TypeDeclaration newType) { while (StartOf(8)) { InterfaceMemberDecl(); } Expect(89); Expect(113); #line 750 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); }
void NonModuleDeclaration( #line 554 "VBNET.ATG" Modifiers m, ArrayList attributes) { #line 556 "VBNET.ATG" string name = String.Empty; ArrayList names = null; switch (la.kind) { case 68: { #line 559 "VBNET.ATG" m.Check(Modifier.Classes); lexer.NextToken(); #line 562 "VBNET.ATG" TypeDeclaration newType = new TypeDeclaration(); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments(); newType.Type = Types.Class; newType.Modifier = m.Modifier; newType.Attributes = attributes; Identifier(); #line 570 "VBNET.ATG" newType.Name = t.val; newType.StartLocation = t.EndLocation; EndOfStmt(); if (la.kind == 111) { ClassBaseType( #line 572 "VBNET.ATG" out name); #line 572 "VBNET.ATG" newType.BaseType = name; } while (la.kind == 108) { TypeImplementsClause( #line 573 "VBNET.ATG" out names); #line 573 "VBNET.ATG" newType.BaseInterfaces = names; } ClassBody( #line 574 "VBNET.ATG" newType); #line 576 "VBNET.ATG" compilationUnit.BlockEnd(); break; } case 122: { lexer.NextToken(); #line 580 "VBNET.ATG" m.Check(Modifier.Modules); TypeDeclaration newType = new TypeDeclaration(); newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments(); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.StartLocation = t.Location; newType.Type = Types.Module; newType.Modifier = m.Modifier; newType.Attributes = attributes; Identifier(); #line 590 "VBNET.ATG" newType.Name = t.val; newType.StartLocation = t.EndLocation; Expect(1); ModuleBody( #line 592 "VBNET.ATG" newType); #line 594 "VBNET.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); break; } case 168: { lexer.NextToken(); #line 599 "VBNET.ATG" m.Check(Modifier.Structures); TypeDeclaration newType = new TypeDeclaration(); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments(); newType.StartLocation = t.Location; newType.Type = Types.Structure; newType.Modifier = m.Modifier; newType.Attributes = attributes; ArrayList baseInterfaces = new ArrayList(); Identifier(); #line 610 "VBNET.ATG" newType.Name = t.val; newType.StartLocation = t.EndLocation; Expect(1); while (la.kind == 108) { TypeImplementsClause( #line 611 "VBNET.ATG" out baseInterfaces); } StructureBody( #line 612 "VBNET.ATG" newType); #line 614 "VBNET.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); break; } case 91: { lexer.NextToken(); #line 620 "VBNET.ATG" m.Check(Modifier.Enums); TypeDeclaration newType = new TypeDeclaration(); newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments(); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Type = Types.Enum; newType.Modifier = m.Modifier; newType.Attributes = attributes; Identifier(); #line 631 "VBNET.ATG" newType.Name = t.val; newType.StartLocation = t.EndLocation; if (la.kind == 49) { lexer.NextToken(); PrimitiveTypeName( #line 632 "VBNET.ATG" out name); #line 632 "VBNET.ATG" newType.BaseType = name; } Expect(1); EnumBody( #line 634 "VBNET.ATG" newType); #line 636 "VBNET.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); break; } case 113: { lexer.NextToken(); #line 642 "VBNET.ATG" m.Check(Modifier.Interfaces); TypeDeclaration newType = new TypeDeclaration(); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Specials["before"] = lexer.SpecialTracker.RetreiveComments(); newType.Type = Types.Interface; newType.Modifier = m.Modifier; newType.Attributes = attributes; ArrayList baseInterfaces = new ArrayList(); Identifier(); #line 653 "VBNET.ATG" newType.Name = t.val; newType.StartLocation = t.EndLocation; EndOfStmt(); while (la.kind == 111) { InterfaceBase( #line 654 "VBNET.ATG" out baseInterfaces); #line 654 "VBNET.ATG" newType.BaseInterfaces = baseInterfaces; } InterfaceBody( #line 655 "VBNET.ATG" newType); #line 657 "VBNET.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); break; } case 81: { lexer.NextToken(); #line 663 "VBNET.ATG" m.Check(Modifier.Delegates); DelegateDeclaration delegateDeclr = new DelegateDeclaration(); ArrayList p = null; TypeReference type = null; delegateDeclr.Specials["before"] = lexer.SpecialTracker.RetreiveComments(); delegateDeclr.StartLocation = t.Location; delegateDeclr.Modifier = m.Modifier; delegateDeclr.Attributes = attributes; if (la.kind == 169) { lexer.NextToken(); Identifier(); #line 673 "VBNET.ATG" delegateDeclr.Name = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 674 "VBNET.ATG" out p); } Expect(26); #line 674 "VBNET.ATG" delegateDeclr.Parameters = p; } } else if (la.kind == 101) { lexer.NextToken(); Identifier(); #line 676 "VBNET.ATG" delegateDeclr.Name = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 677 "VBNET.ATG" out p); } Expect(26); #line 677 "VBNET.ATG" delegateDeclr.Parameters = p; } if (la.kind == 49) { lexer.NextToken(); TypeName( #line 678 "VBNET.ATG" out type); #line 678 "VBNET.ATG" delegateDeclr.ReturnType = type; } } else SynErr(197); #line 680 "VBNET.ATG" delegateDeclr.EndLocation = t.EndLocation; Expect(1); #line 683 "VBNET.ATG" compilationUnit.AddChild(delegateDeclr); break; } default: SynErr(198); break; } }
void EnumBody( #line 739 "VBNET.ATG" TypeDeclaration newType) { #line 740 "VBNET.ATG" FieldDeclaration f; while (StartOf(7)) { EnumMemberDecl( #line 742 "VBNET.ATG" out f); #line 742 "VBNET.ATG" compilationUnit.AddChild(f); } Expect(89); Expect(91); #line 744 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); }
void StructureBody( #line 708 "VBNET.ATG" TypeDeclaration newType) { #line 709 "VBNET.ATG" AttributeSection section; while (StartOf(5)) { #line 712 "VBNET.ATG" ArrayList attributes = new ArrayList(); Modifiers m = new Modifiers(this); while (la.kind == 28) { AttributeSection( #line 715 "VBNET.ATG" out section); #line 715 "VBNET.ATG" attributes.Add(section); } while (StartOf(6)) { MemberModifier( #line 716 "VBNET.ATG" m); } StructureMemberDecl( #line 717 "VBNET.ATG" m, attributes); } Expect(89); Expect(168); #line 719 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); }
void ModuleBody( #line 724 "VBNET.ATG" TypeDeclaration newType) { #line 725 "VBNET.ATG" AttributeSection section; while (StartOf(5)) { #line 728 "VBNET.ATG" ArrayList attributes = new ArrayList(); Modifiers m = new Modifiers(this); while (la.kind == 28) { AttributeSection( #line 731 "VBNET.ATG" out section); #line 731 "VBNET.ATG" attributes.Add(section); } while (StartOf(6)) { MemberModifier( #line 732 "VBNET.ATG" m); } ClassMemberDecl( #line 733 "VBNET.ATG" m, attributes); } Expect(89); Expect(122); #line 735 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); }
public object Visit(TypeDeclaration typeDeclaration, object data) { DebugOutput(typeDeclaration); AppendAttributes(typeDeclaration.Attributes); string modifier = GetModifier(typeDeclaration.Modifier); string type = String.Empty; switch (typeDeclaration.Type) { case Types.Class: type = "class "; break; case Types.Enum: type = "enum "; break; case Types.Interface: type = "interface "; break; case Types.Module: case Types.Structure: type = "struct "; break; } AppendIndentation(); sourceText.Append(modifier); sourceText.Append(type); sourceText.Append(typeDeclaration.Name); bool hasBaseType = typeDeclaration.BaseType != null; if (hasBaseType) { sourceText.Append(" : "); sourceText.Append(ConvertTypeString(typeDeclaration.BaseType)); } if (typeDeclaration.BaseInterfaces != null && typeDeclaration.BaseInterfaces.Count > 0) { if (!hasBaseType) { sourceText.Append(" : "); } else { sourceText.Append(", "); } for (int i = 0; i < typeDeclaration.BaseInterfaces.Count; ++i) { if (typeDeclaration.BaseInterfaces[i] is TypeReference) { sourceText.Append((typeDeclaration.BaseInterfaces[i] as TypeReference).Type); } else { sourceText.Append(typeDeclaration.BaseInterfaces[i].ToString()); } if (i + 1 < typeDeclaration.BaseInterfaces.Count) { sourceText.Append(", "); } } } AppendNewLine(); AppendIndentation(); sourceText.Append("{"); AppendNewLine(); ++indentLevel; TypeDeclaration oldType = currentType; currentType = typeDeclaration; typeDeclaration.AcceptChildren(this, data); currentType = oldType; --indentLevel; AppendIndentation(); sourceText.Append("}"); AppendNewLine(); return null; }
public virtual object Visit(TypeDeclaration typeDeclaration, object data) { foreach (AttributeSection a in typeDeclaration.Attributes) { a.AcceptVisitor(this, data); } return typeDeclaration.AcceptChildren(this, data); }