static bool IsMustOverride(ModifierList m) { return(m.Contains(Modifiers.Abstract)); }
void StructMemberDecl( #line 748 "cs.ATG" ModifierList m, List<AttributeSection> attributes) { #line 750 "cs.ATG" string qualident = null; TypeReference type; Expression expr; List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); Statement stmt = null; List<TemplateDefinition> templates = new List<TemplateDefinition>(); TypeReference explicitInterface = null; bool isExtensionMethod = false; if (la.kind == 60) { #line 760 "cs.ATG" m.Check(Modifiers.Constants); lexer.NextToken(); #line 761 "cs.ATG" Location startPos = t.Location; Type( #line 762 "cs.ATG" out type); Identifier(); #line 762 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location; f.TypeReference = type; SafeAdd(fd, fd.Fields, f); Expect(3); Expr( #line 769 "cs.ATG" out expr); #line 769 "cs.ATG" f.Initializer = expr; while (la.kind == 14) { lexer.NextToken(); Identifier(); #line 770 "cs.ATG" f = new VariableDeclaration(t.val); f.StartLocation = t.Location; f.TypeReference = type; SafeAdd(fd, fd.Fields, f); Expect(3); Expr( #line 775 "cs.ATG" out expr); #line 775 "cs.ATG" f.EndLocation = t.EndLocation; f.Initializer = expr; } Expect(11); #line 776 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( #line 780 "cs.ATG" NotVoidPointer()) { #line 780 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); Expect(123); #line 781 "cs.ATG" Location startPos = t.Location; if ( #line 782 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 783 "cs.ATG" out explicitInterface, false); #line 784 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(19)) { Identifier(); #line 787 "cs.ATG" qualident = t.val; } else SynErr(162); if (la.kind == 23) { TypeParameterList( #line 790 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); #line 793 "cs.ATG" isExtensionMethod = true; /* C# 3.0 */ } if (StartOf(11)) { FormalParameterList( #line 794 "cs.ATG" p); } Expect(21); #line 795 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, TypeReference = new TypeReference("System.Void", true), Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, Templates = templates, IsExtensionMethod = isExtensionMethod }; if (explicitInterface != null) SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( #line 813 "cs.ATG" templates); } if (la.kind == 16) { Block( #line 815 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(163); #line 815 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 69) { #line 819 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); lexer.NextToken(); #line 821 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration { Modifier = m.Modifier, Attributes = attributes, StartLocation = t.Location }; compilationUnit.AddChild(eventDecl); compilationUnit.BlockStart(eventDecl); EventAddRegion addBlock = null; EventRemoveRegion removeBlock = null; Type( #line 831 "cs.ATG" out type); #line 831 "cs.ATG" eventDecl.TypeReference = type; if ( #line 832 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 833 "cs.ATG" out explicitInterface, false); #line 834 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); #line 835 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (StartOf(19)) { Identifier(); #line 837 "cs.ATG" qualident = t.val; } else SynErr(164); #line 839 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 3) { lexer.NextToken(); Expr( #line 840 "cs.ATG" out expr); #line 840 "cs.ATG" eventDecl.Initializer = expr; } if (la.kind == 16) { lexer.NextToken(); #line 841 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( #line 842 "cs.ATG" out addBlock, out removeBlock); Expect(17); #line 843 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } #line 846 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( #line 852 "cs.ATG" IdentAndLPar()) { #line 852 "cs.ATG" m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); Identifier(); #line 853 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(11)) { #line 853 "cs.ATG" m.Check(Modifiers.Constructors); FormalParameterList( #line 854 "cs.ATG" p); } Expect(21); #line 856 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { #line 857 "cs.ATG" m.Check(Modifiers.Constructors); ConstructorInitializer( #line 858 "cs.ATG" out init); } #line 860 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 16) { Block( #line 865 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); #line 865 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 70 || la.kind == 80) { #line 868 "cs.ATG" m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; Location startPos = Location.Empty; if (la.kind == 80) { lexer.NextToken(); #line 873 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); #line 873 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(92); Type( #line 874 "cs.ATG" out type); #line 874 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( #line 875 "cs.ATG" out type); Identifier(); #line 875 "cs.ATG" string varName = t.val; Expect(21); #line 876 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( #line 877 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); #line 877 "cs.ATG" stmt = null; } else SynErr(166); #line 880 "cs.ATG" List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, TypeReference = operatorType, ConversionType = isImplicit ? ConversionType.Implicit : ConversionType.Explicit, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; compilationUnit.AddChild(operatorDeclaration); } else if (StartOf(22)) { TypeDecl( #line 897 "cs.ATG" m, attributes); } else if (StartOf(10)) { Type( #line 899 "cs.ATG" out type); #line 899 "cs.ATG" Location startPos = t.Location; if (la.kind == 92) { #line 901 "cs.ATG" OverloadableOperatorType op; m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( #line 905 "cs.ATG" out op); #line 905 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( #line 906 "cs.ATG" out firstType); Identifier(); #line 906 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( #line 907 "cs.ATG" out secondType); Identifier(); #line 907 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(167); #line 915 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( #line 916 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(168); #line 918 "cs.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, TypeReference = type, OverloadableOperator = op, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName)); } compilationUnit.AddChild(operatorDeclaration); } else if ( #line 935 "cs.ATG" IsVarDecl()) { #line 936 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( #line 940 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( #line 941 "cs.ATG" fd); Expect(18); Expr( #line 943 "cs.ATG" out expr); #line 943 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( #line 947 "cs.ATG" fd); Expect(18); Expr( #line 949 "cs.ATG" out expr); #line 949 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); } } else if (StartOf(19)) { VariableDeclarator( #line 954 "cs.ATG" fd); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( #line 955 "cs.ATG" fd); } } else SynErr(169); Expect(11); #line 957 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if (la.kind == 111) { #line 960 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( #line 961 "cs.ATG" p); Expect(19); #line 961 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); #line 962 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; indexer.BodyStart = t.Location; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 969 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 970 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( #line 975 "cs.ATG" IsIdentifierToken(la)) { if ( #line 976 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 977 "cs.ATG" out explicitInterface, false); #line 978 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(19)) { Identifier(); #line 981 "cs.ATG" qualident = t.val; } else SynErr(170); #line 983 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { #line 987 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( #line 989 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); #line 991 "cs.ATG" isExtensionMethod = true; } if (StartOf(11)) { FormalParameterList( #line 992 "cs.ATG" p); } Expect(21); #line 994 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes }; if (explicitInterface != null) methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; methodDeclaration.IsExtensionMethod = isExtensionMethod; methodDeclaration.Templates = templates; compilationUnit.AddChild(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( #line 1009 "cs.ATG" templates); } if (la.kind == 16) { Block( #line 1010 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(171); #line 1010 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); #line 1013 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = qualIdentEndLocation; pDecl.BodyStart = t.Location; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 1022 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 1024 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; compilationUnit.AddChild(pDecl); } } else if (la.kind == 15) { #line 1032 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(111); Expect(18); FormalParameterList( #line 1033 "cs.ATG" p); Expect(19); #line 1034 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; if (explicitInterface != null) SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this")); PropertyGetRegion getRegion; PropertySetRegion setRegion; Expect(16); #line 1042 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( #line 1043 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 1044 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else SynErr(172); } else SynErr(173); } else SynErr(174); }
static bool IsMustOverride(ModifierList m) { return m.Contains(Modifiers.Abstract); }
/// <summary> /// Ist it an Interface? /// </summary> /// <returns></returns> public bool IsInterface() { return(ModifierList.Contains("interface")); }