public override object VisitEventDeclaration(NRefactoryAST.EventDeclaration eventDeclaration, object data)
        {
            DomRegion    region     = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation);
            DomRegion    bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd);
            DefaultClass c          = GetCurrentClass();

            IReturnType type;

            if (eventDeclaration.TypeReference.IsNull)
            {
                DefaultClass del = new DefaultClass(cu, ClassType.Delegate,
                                                    ConvertModifier(eventDeclaration.Modifier),
                                                    region, c);
                del.Modifiers |= ModifierEnum.Synthetic;
                CreateDelegate(del, eventDeclaration.Name + "EventHandler",
                               new NRefactoryAST.TypeReference("System.Void", true),
                               new NRefactoryAST.TemplateDefinition[0],
                               eventDeclaration.Parameters);
                type = del.DefaultReturnType;
            }
            else
            {
                type = CreateReturnType(eventDeclaration.TypeReference);
            }
            DefaultEvent e = new DefaultEvent(eventDeclaration.Name, type, ConvertModifier(eventDeclaration.Modifier), region, bodyRegion, c);

            ConvertAttributes(eventDeclaration, e);
            c.Events.Add(e);

            e.Documentation = GetDocumentation(region.BeginLine, eventDeclaration.Attributes);
            if (eventDeclaration.HasAddRegion)
            {
                var defaultMethod     = new DefaultMethod(e.DeclaringType, "add_" + e.Name);
                var defaultParameters = new List <IParameter>();
                defaultParameters.Add(new DefaultParameter("value", e.ReturnType, DomRegion.Empty));
                defaultMethod.Parameters = defaultParameters;
                defaultMethod.Region     = GetRegion(eventDeclaration.AddRegion.StartLocation, eventDeclaration.AddRegion.EndLocation);
                defaultMethod.BodyRegion = GetRegion(eventDeclaration.AddRegion.Block.StartLocation, eventDeclaration.AddRegion.Block.EndLocation);
                e.AddMethod = defaultMethod;
            }
            if (eventDeclaration.HasRemoveRegion)
            {
                var defaultMethod     = new DefaultMethod(e.DeclaringType, "remove_" + e.Name);
                var defaultParameters = new List <IParameter>();
                defaultParameters.Add(new DefaultParameter("value", e.ReturnType, DomRegion.Empty));
                defaultMethod.Parameters = defaultParameters;
                defaultMethod.Region     = GetRegion(eventDeclaration.RemoveRegion.StartLocation, eventDeclaration.RemoveRegion.EndLocation);
                defaultMethod.BodyRegion = GetRegion(eventDeclaration.RemoveRegion.Block.StartLocation, eventDeclaration.RemoveRegion.Block.EndLocation);
                e.RemoveMethod           = defaultMethod;
            }
            return(null);
        }
Example #2
0
 public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 {
     if (!eventDeclaration.HasAddRegion && !eventDeclaration.HasRaiseRegion && !eventDeclaration.HasRemoveRegion) {
         if (eventDeclaration.TypeReference.IsNull) {
             DelegateDeclaration dd = new DelegateDeclaration(eventDeclaration.Modifier, null);
             dd.Name = eventDeclaration.Name + "EventHandler";
             dd.Parameters = eventDeclaration.Parameters;
             dd.ReturnType = new TypeReference("System.Void");
             dd.Parent = eventDeclaration.Parent;
             eventDeclaration.Parameters = null;
             InsertAfterSibling(eventDeclaration, dd);
             eventDeclaration.TypeReference = new TypeReference(dd.Name);
         }
     }
     return base.VisitEventDeclaration(eventDeclaration, data);
 }
		// The following conversions are implemented:
		//   Public Event EventName(param As String) -> automatic delegate declaration
		//   static variables inside methods become fields
		
		public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
		{
			if (!eventDeclaration.HasAddRegion && !eventDeclaration.HasRaiseRegion && !eventDeclaration.HasRemoveRegion) {
				if (eventDeclaration.TypeReference.IsNull) {
					DelegateDeclaration dd = new DelegateDeclaration(eventDeclaration.Modifier, null);
					dd.Name = eventDeclaration.Name + "EventHandler";
					dd.Parameters = eventDeclaration.Parameters;
					dd.ReturnType = new TypeReference("System.Void");
					dd.Parent = eventDeclaration.Parent;
					eventDeclaration.Parameters = null;
					int index = eventDeclaration.Parent.Children.IndexOf(eventDeclaration);
					// inserting before current position is not allowed in a Transformer
					eventDeclaration.Parent.Children.Insert(index + 1, dd);
					eventDeclaration.TypeReference = new TypeReference(dd.Name);
				}
			}
			return base.VisitEventDeclaration(eventDeclaration, data);
		}
        public override object VisitEventDeclaration(AST.EventDeclaration eventDeclaration, object data)
        {
            DomRegion    region     = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation);
            DomRegion    bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd);
            DefaultClass c          = GetCurrentClass();

            IReturnType type;

            if (eventDeclaration.TypeReference.IsNull)
            {
                DefaultClass del = new DefaultClass(cu, ClassType.Delegate,
                                                    ConvertModifier(eventDeclaration.Modifier),
                                                    region, c);
                del.Modifiers |= ModifierEnum.Synthetic;
                CreateDelegate(del, eventDeclaration.Name + "EventHandler",
                               new AST.TypeReference("System.Void"),
                               new AST.TemplateDefinition[0],
                               eventDeclaration.Parameters);
                type = del.DefaultReturnType;
            }
            else
            {
                type = CreateReturnType(eventDeclaration.TypeReference);
            }
            DefaultEvent e = new DefaultEvent(eventDeclaration.Name, type, ConvertModifier(eventDeclaration.Modifier), region, bodyRegion, c);

            ConvertAttributes(eventDeclaration, e);
            c.Events.Add(e);
            if (e != null)
            {
                e.Documentation = GetDocumentation(region.BeginLine, eventDeclaration.Attributes);
            }
            else
            {
                LoggingService.Warn("NRefactoryASTConvertVisitor: " + eventDeclaration + " has no events!");
            }
            return(null);
        }
            public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
            {
                eventVars.Add(eventDeclaration.Name);

                return base.VisitEventDeclaration(eventDeclaration, data);
            }
Example #6
0
	void StructMemberDecl(
#line  739 "cs.ATG" 
ModifierList m, List<AttributeSection> attributes) {

#line  741 "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  751 "cs.ATG" 
			m.Check(Modifiers.Constants); 
			lexer.NextToken();

#line  752 "cs.ATG" 
			Location startPos = t.Location; 
			Type(
#line  753 "cs.ATG" 
out type);
			Identifier();

#line  753 "cs.ATG" 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const);
			fd.StartLocation = m.GetDeclarationLocation(startPos);
			VariableDeclaration f = new VariableDeclaration(t.val);
			SafeAdd(fd, fd.Fields, f);
			
			Expect(3);
			Expr(
#line  758 "cs.ATG" 
out expr);

#line  758 "cs.ATG" 
			f.Initializer = expr; 
			while (la.kind == 14) {
				lexer.NextToken();
				Identifier();

#line  759 "cs.ATG" 
				f = new VariableDeclaration(t.val);
				SafeAdd(fd, fd.Fields, f);
				
				Expect(3);
				Expr(
#line  762 "cs.ATG" 
out expr);

#line  762 "cs.ATG" 
				f.Initializer = expr; 
			}
			Expect(11);

#line  763 "cs.ATG" 
			fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); 
		} else if (
#line  767 "cs.ATG" 
NotVoidPointer()) {

#line  767 "cs.ATG" 
			m.Check(Modifiers.PropertysEventsMethods); 
			Expect(123);

#line  768 "cs.ATG" 
			Location startPos = t.Location; 
			if (
#line  769 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
				TypeName(
#line  770 "cs.ATG" 
out explicitInterface, false);

#line  771 "cs.ATG" 
				if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
				qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
				 } 
			} else if (StartOf(19)) {
				Identifier();

#line  774 "cs.ATG" 
				qualident = t.val; 
			} else SynErr(162);
			if (la.kind == 23) {
				TypeParameterList(
#line  777 "cs.ATG" 
templates);
			}
			Expect(20);
			if (la.kind == 111) {
				lexer.NextToken();

#line  780 "cs.ATG" 
				isExtensionMethod = true; /* C# 3.0 */ 
			}
			if (StartOf(11)) {
				FormalParameterList(
#line  781 "cs.ATG" 
p);
			}
			Expect(21);

#line  782 "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  800 "cs.ATG" 
templates);
			}
			if (la.kind == 16) {
				Block(
#line  802 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(163);

#line  802 "cs.ATG" 
			compilationUnit.BlockEnd();
			methodDeclaration.Body  = (BlockStatement)stmt;
			
		} else if (la.kind == 69) {

#line  806 "cs.ATG" 
			m.Check(Modifiers.PropertysEventsMethods); 
			lexer.NextToken();

#line  808 "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  818 "cs.ATG" 
out type);

#line  818 "cs.ATG" 
			eventDecl.TypeReference = type; 
			if (
#line  819 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
				TypeName(
#line  820 "cs.ATG" 
out explicitInterface, false);

#line  821 "cs.ATG" 
				qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); 

#line  822 "cs.ATG" 
				eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); 
			} else if (StartOf(19)) {
				Identifier();

#line  824 "cs.ATG" 
				qualident = t.val; 
			} else SynErr(164);

#line  826 "cs.ATG" 
			eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; 
			if (la.kind == 3) {
				lexer.NextToken();
				Expr(
#line  827 "cs.ATG" 
out expr);

#line  827 "cs.ATG" 
				eventDecl.Initializer = expr; 
			}
			if (la.kind == 16) {
				lexer.NextToken();

#line  828 "cs.ATG" 
				eventDecl.BodyStart = t.Location; 
				EventAccessorDecls(
#line  829 "cs.ATG" 
out addBlock, out removeBlock);
				Expect(17);

#line  830 "cs.ATG" 
				eventDecl.BodyEnd   = t.EndLocation; 
			}
			if (la.kind == 11) {
				lexer.NextToken();
			}

#line  833 "cs.ATG" 
			compilationUnit.BlockEnd();
			eventDecl.AddRegion = addBlock;
			eventDecl.RemoveRegion = removeBlock;
			
		} else if (
#line  839 "cs.ATG" 
IdentAndLPar()) {

#line  839 "cs.ATG" 
			m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); 
			Identifier();

#line  840 "cs.ATG" 
			string name = t.val; Location startPos = t.Location; 
			Expect(20);
			if (StartOf(11)) {

#line  840 "cs.ATG" 
				m.Check(Modifiers.Constructors); 
				FormalParameterList(
#line  841 "cs.ATG" 
p);
			}
			Expect(21);

#line  843 "cs.ATG" 
			ConstructorInitializer init = null;  
			if (la.kind == 9) {

#line  844 "cs.ATG" 
				m.Check(Modifiers.Constructors); 
				ConstructorInitializer(
#line  845 "cs.ATG" 
out init);
			}

#line  847 "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  852 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(165);

#line  852 "cs.ATG" 
			cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); 
		} else if (la.kind == 70 || la.kind == 80) {

#line  855 "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  860 "cs.ATG" 
				startPos = t.Location; 
			} else {
				lexer.NextToken();

#line  860 "cs.ATG" 
				isImplicit = false; startPos = t.Location; 
			}
			Expect(92);
			Type(
#line  861 "cs.ATG" 
out type);

#line  861 "cs.ATG" 
			TypeReference operatorType = type; 
			Expect(20);
			Type(
#line  862 "cs.ATG" 
out type);
			Identifier();

#line  862 "cs.ATG" 
			string varName = t.val; 
			Expect(21);

#line  863 "cs.ATG" 
			Location endPos = t.Location; 
			if (la.kind == 16) {
				Block(
#line  864 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();

#line  864 "cs.ATG" 
				stmt = null; 
			} else SynErr(166);

#line  867 "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  884 "cs.ATG" 
m, attributes);
		} else if (StartOf(10)) {
			Type(
#line  886 "cs.ATG" 
out type);

#line  886 "cs.ATG" 
			Location startPos = t.Location;  
			if (la.kind == 92) {

#line  888 "cs.ATG" 
				OverloadableOperatorType op;
				m.Check(Modifiers.Operators);
				if (m.isNone) Error("at least one modifier must be set");
				
				lexer.NextToken();
				OverloadableOperator(
#line  892 "cs.ATG" 
out op);

#line  892 "cs.ATG" 
				TypeReference firstType, secondType = null; string secondName = null; 
				Expect(20);
				Type(
#line  893 "cs.ATG" 
out firstType);
				Identifier();

#line  893 "cs.ATG" 
				string firstName = t.val; 
				if (la.kind == 14) {
					lexer.NextToken();
					Type(
#line  894 "cs.ATG" 
out secondType);
					Identifier();

#line  894 "cs.ATG" 
					secondName = t.val; 
				} else if (la.kind == 21) {
				} else SynErr(167);

#line  902 "cs.ATG" 
				Location endPos = t.Location; 
				Expect(21);
				if (la.kind == 16) {
					Block(
#line  903 "cs.ATG" 
out stmt);
				} else if (la.kind == 11) {
					lexer.NextToken();
				} else SynErr(168);

#line  905 "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  922 "cs.ATG" 
IsVarDecl()) {

#line  923 "cs.ATG" 
				m.Check(Modifiers.Fields);
				FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
				fd.StartLocation = m.GetDeclarationLocation(startPos); 
				
				if (
#line  927 "cs.ATG" 
m.Contains(Modifiers.Fixed)) {
					VariableDeclarator(
#line  928 "cs.ATG" 
fd);
					Expect(18);
					Expr(
#line  930 "cs.ATG" 
out expr);

#line  930 "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  934 "cs.ATG" 
fd);
						Expect(18);
						Expr(
#line  936 "cs.ATG" 
out expr);

#line  936 "cs.ATG" 
						if (fd.Fields.Count > 0)
						fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; 
						Expect(19);
					}
				} else if (StartOf(19)) {
					VariableDeclarator(
#line  941 "cs.ATG" 
fd);
					while (la.kind == 14) {
						lexer.NextToken();
						VariableDeclarator(
#line  942 "cs.ATG" 
fd);
					}
				} else SynErr(169);
				Expect(11);

#line  944 "cs.ATG" 
				fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); 
			} else if (la.kind == 111) {

#line  947 "cs.ATG" 
				m.Check(Modifiers.Indexers); 
				lexer.NextToken();
				Expect(18);
				FormalParameterList(
#line  948 "cs.ATG" 
p);
				Expect(19);

#line  948 "cs.ATG" 
				Location endLocation = t.EndLocation; 
				Expect(16);

#line  949 "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  956 "cs.ATG" 
out getRegion, out setRegion);
				Expect(17);

#line  957 "cs.ATG" 
				indexer.BodyEnd    = t.EndLocation;
				indexer.GetRegion = getRegion;
				indexer.SetRegion = setRegion;
				compilationUnit.AddChild(indexer);
				
			} else if (
#line  962 "cs.ATG" 
IsIdentifierToken(la)) {
				if (
#line  963 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
					TypeName(
#line  964 "cs.ATG" 
out explicitInterface, false);

#line  965 "cs.ATG" 
					if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
					qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
					 } 
				} else if (StartOf(19)) {
					Identifier();

#line  968 "cs.ATG" 
					qualident = t.val; 
				} else SynErr(170);

#line  970 "cs.ATG" 
				Location qualIdentEndLocation = t.EndLocation; 
				if (la.kind == 16 || la.kind == 20 || la.kind == 23) {
					if (la.kind == 20 || la.kind == 23) {

#line  974 "cs.ATG" 
						m.Check(Modifiers.PropertysEventsMethods); 
						if (la.kind == 23) {
							TypeParameterList(
#line  976 "cs.ATG" 
templates);
						}
						Expect(20);
						if (la.kind == 111) {
							lexer.NextToken();

#line  978 "cs.ATG" 
							isExtensionMethod = true; 
						}
						if (StartOf(11)) {
							FormalParameterList(
#line  979 "cs.ATG" 
p);
						}
						Expect(21);

#line  981 "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  996 "cs.ATG" 
templates);
						}
						if (la.kind == 16) {
							Block(
#line  997 "cs.ATG" 
out stmt);
						} else if (la.kind == 11) {
							lexer.NextToken();
						} else SynErr(171);

#line  997 "cs.ATG" 
						methodDeclaration.Body  = (BlockStatement)stmt; 
					} else {
						lexer.NextToken();

#line  1000 "cs.ATG" 
						PropertyDeclaration ParameterDeclarationExpressionl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); 
						if (explicitInterface != null)
						ParameterDeclarationExpressionl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
						      ParameterDeclarationExpressionl.StartLocation = m.GetDeclarationLocation(startPos);
						      ParameterDeclarationExpressionl.EndLocation   = qualIdentEndLocation;
						      ParameterDeclarationExpressionl.BodyStart   = t.Location;
						      PropertyGetRegion getRegion;
						      PropertySetRegion setRegion;
						   
						AccessorDecls(
#line  1009 "cs.ATG" 
out getRegion, out setRegion);
						Expect(17);

#line  1011 "cs.ATG" 
						ParameterDeclarationExpressionl.GetRegion = getRegion;
						ParameterDeclarationExpressionl.SetRegion = setRegion;
						ParameterDeclarationExpressionl.BodyEnd = t.EndLocation;
						compilationUnit.AddChild(ParameterDeclarationExpressionl);
						
					}
				} else if (la.kind == 15) {

#line  1019 "cs.ATG" 
					m.Check(Modifiers.Indexers); 
					lexer.NextToken();
					Expect(111);
					Expect(18);
					FormalParameterList(
#line  1020 "cs.ATG" 
p);
					Expect(19);

#line  1021 "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  1029 "cs.ATG" 
					Location bodyStart = t.Location; 
					AccessorDecls(
#line  1030 "cs.ATG" 
out getRegion, out setRegion);
					Expect(17);

#line  1031 "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);
	}
		public sealed override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) {
			this.BeginVisit(eventDeclaration);
			object result = this.TrackedVisitEventDeclaration(eventDeclaration, data);
			this.EndVisit(eventDeclaration);
			return result;
		}
		public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) {
			throw new global::System.NotImplementedException("EventDeclaration");
		}
Example #9
0
	void StructureMemberDecl(
#line  775 "VBNET.ATG" 
ModifierList m, List<AttributeSection> attributes) {

#line  777 "VBNET.ATG" 
		TypeReference type = null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		Statement stmt = null;
		List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		
		switch (la.kind) {
		case 71: case 90: case 102: case 129: case 141: case 194: {
			NonModuleDeclaration(
#line  784 "VBNET.ATG" 
m, attributes);
			break;
		}
		case 195: {
			lexer.NextToken();

#line  788 "VBNET.ATG" 
			Location startPos = t.Location;
			
			if (StartOf(14)) {

#line  792 "VBNET.ATG" 
				string name = String.Empty;
				MethodDeclaration methodDeclaration; List<string> handlesClause = null;
				List<InterfaceImplementation> implementsClause = null;
				
				Identifier();

#line  798 "VBNET.ATG" 
				name = t.val;
				m.Check(Modifiers.VBMethods);
				
				TypeParameterList(
#line  801 "VBNET.ATG" 
templates);
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  802 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
				if (la.kind == 121 || la.kind == 123) {
					if (la.kind == 123) {
						ImplementsClause(
#line  805 "VBNET.ATG" 
out implementsClause);
					} else {
						HandlesClause(
#line  807 "VBNET.ATG" 
out handlesClause);
					}
				}

#line  810 "VBNET.ATG" 
				Location endLocation = t.EndLocation; 
				if (
#line  813 "VBNET.ATG" 
IsMustOverride(m)) {
					EndOfStmt();

#line  816 "VBNET.ATG" 
					methodDeclaration = new MethodDeclaration {
					Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
					StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
					TypeReference = new TypeReference("System.Void", true),
					Templates = templates,
					HandlesClause = handlesClause,
					InterfaceImplementations = implementsClause
					};
					compilationUnit.AddChild(methodDeclaration);
					
				} else if (la.kind == 1) {
					lexer.NextToken();

#line  829 "VBNET.ATG" 
					methodDeclaration = new MethodDeclaration {
					Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
					StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
					TypeReference = new TypeReference("System.Void", true),
					Templates = templates,
					HandlesClause = handlesClause,
					InterfaceImplementations = implementsClause
					};
					compilationUnit.AddChild(methodDeclaration);
					

#line  840 "VBNET.ATG" 
					if (ParseMethodBodies) { 
					Block(
#line  841 "VBNET.ATG" 
out stmt);
					Expect(100);
					Expect(195);

#line  843 "VBNET.ATG" 
					} else {
					// don't parse method body
					lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
					  }
					

#line  849 "VBNET.ATG" 
					methodDeclaration.Body  = (BlockStatement)stmt; 

#line  850 "VBNET.ATG" 
					methodDeclaration.Body.EndLocation = t.EndLocation; 
					EndOfStmt();
				} else SynErr(238);
			} else if (la.kind == 148) {
				lexer.NextToken();
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  854 "VBNET.ATG" 
p);
					}
					Expect(26);
				}

#line  855 "VBNET.ATG" 
				m.Check(Modifiers.Constructors); 

#line  856 "VBNET.ATG" 
				Location constructorEndLocation = t.EndLocation; 
				Expect(1);

#line  859 "VBNET.ATG" 
				if (ParseMethodBodies) { 
				Block(
#line  860 "VBNET.ATG" 
out stmt);
				Expect(100);
				Expect(195);

#line  862 "VBNET.ATG" 
				} else {
				// don't parse method body
				lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
				  }
				

#line  868 "VBNET.ATG" 
				Location endLocation = t.EndLocation; 
				EndOfStmt();

#line  871 "VBNET.ATG" 
				ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes);
				cd.StartLocation = m.GetDeclarationLocation(startPos);
				cd.EndLocation   = constructorEndLocation;
				cd.Body = (BlockStatement)stmt;
				cd.Body.EndLocation   = endLocation;
				compilationUnit.AddChild(cd);
				
			} else SynErr(239);
			break;
		}
		case 114: {
			lexer.NextToken();

#line  883 "VBNET.ATG" 
			m.Check(Modifiers.VBMethods);
			string name = String.Empty;
			Location startPos = t.Location;
			MethodDeclaration methodDeclaration;List<string> handlesClause = null;
			List<InterfaceImplementation> implementsClause = null;
			AttributeSection returnTypeAttributeSection = null;
			
			Identifier();

#line  890 "VBNET.ATG" 
			name = t.val; 
			TypeParameterList(
#line  891 "VBNET.ATG" 
templates);
			if (la.kind == 25) {
				lexer.NextToken();
				if (StartOf(4)) {
					FormalParameterList(
#line  892 "VBNET.ATG" 
p);
				}
				Expect(26);
			}
			if (la.kind == 50) {
				lexer.NextToken();
				while (la.kind == 28) {
					AttributeSection(
#line  893 "VBNET.ATG" 
out returnTypeAttributeSection);
				}
				TypeName(
#line  893 "VBNET.ATG" 
out type);
			}

#line  895 "VBNET.ATG" 
			if(type == null) {
			type = new TypeReference("System.Object", true);
			}
			
			if (la.kind == 121 || la.kind == 123) {
				if (la.kind == 123) {
					ImplementsClause(
#line  901 "VBNET.ATG" 
out implementsClause);
				} else {
					HandlesClause(
#line  903 "VBNET.ATG" 
out handlesClause);
				}
			}
			if (
#line  908 "VBNET.ATG" 
IsMustOverride(m)) {
				EndOfStmt();

#line  911 "VBNET.ATG" 
				methodDeclaration = new MethodDeclaration {
				Name = name, Modifier = m.Modifier, TypeReference = type,
				Parameters = p, Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation   = t.EndLocation,
				HandlesClause = handlesClause,
				Templates     = templates,
				InterfaceImplementations = implementsClause
				};
				if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					methodDeclaration.Attributes.Add(returnTypeAttributeSection);
				}
				compilationUnit.AddChild(methodDeclaration);
				
			} else if (la.kind == 1) {
				lexer.NextToken();

#line  929 "VBNET.ATG" 
				methodDeclaration = new MethodDeclaration {
				Name = name, Modifier = m.Modifier, TypeReference = type,
				Parameters = p, Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation   = t.EndLocation,
				Templates     = templates,
				HandlesClause = handlesClause,
				InterfaceImplementations = implementsClause
				};
				if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					methodDeclaration.Attributes.Add(returnTypeAttributeSection);
				}
				
				compilationUnit.AddChild(methodDeclaration);
				
				if (ParseMethodBodies) { 
				Block(
#line  946 "VBNET.ATG" 
out stmt);
				Expect(100);
				Expect(114);

#line  948 "VBNET.ATG" 
				} else {
				// don't parse method body
				lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
				}
				methodDeclaration.Body = (BlockStatement)stmt;
				methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
				methodDeclaration.Body.EndLocation   = t.EndLocation;
				
				EndOfStmt();
			} else SynErr(240);
			break;
		}
		case 88: {
			lexer.NextToken();

#line  962 "VBNET.ATG" 
			m.Check(Modifiers.VBExternalMethods);
			Location startPos = t.Location;
			CharsetModifier charsetModifer = CharsetModifier.None;
			string library = String.Empty;
			string alias = null;
			string name = String.Empty;
			
			if (StartOf(15)) {
				Charset(
#line  969 "VBNET.ATG" 
out charsetModifer);
			}
			if (la.kind == 195) {
				lexer.NextToken();
				Identifier();

#line  972 "VBNET.ATG" 
				name = t.val; 
				Expect(135);
				Expect(3);

#line  973 "VBNET.ATG" 
				library = t.literalValue as string; 
				if (la.kind == 46) {
					lexer.NextToken();
					Expect(3);

#line  974 "VBNET.ATG" 
					alias = t.literalValue as string; 
				}
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  975 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
				EndOfStmt();

#line  978 "VBNET.ATG" 
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer);
				declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
				declareDeclaration.EndLocation   = t.EndLocation;
				compilationUnit.AddChild(declareDeclaration);
				
			} else if (la.kind == 114) {
				lexer.NextToken();
				Identifier();

#line  985 "VBNET.ATG" 
				name = t.val; 
				Expect(135);
				Expect(3);

#line  986 "VBNET.ATG" 
				library = t.literalValue as string; 
				if (la.kind == 46) {
					lexer.NextToken();
					Expect(3);

#line  987 "VBNET.ATG" 
					alias = t.literalValue as string; 
				}
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  988 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
				if (la.kind == 50) {
					lexer.NextToken();
					TypeName(
#line  989 "VBNET.ATG" 
out type);
				}
				EndOfStmt();

#line  992 "VBNET.ATG" 
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
				declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
				declareDeclaration.EndLocation   = t.EndLocation;
				compilationUnit.AddChild(declareDeclaration);
				
			} else SynErr(241);
			break;
		}
		case 106: {
			lexer.NextToken();

#line  1002 "VBNET.ATG" 
			m.Check(Modifiers.VBEvents);
			Location startPos = t.Location;
			EventDeclaration eventDeclaration;
			string name = String.Empty;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

#line  1008 "VBNET.ATG" 
			name= t.val; 
			if (la.kind == 50) {
				lexer.NextToken();
				TypeName(
#line  1010 "VBNET.ATG" 
out type);
			} else if (StartOf(16)) {
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  1012 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
			} else SynErr(242);
			if (la.kind == 123) {
				ImplementsClause(
#line  1014 "VBNET.ATG" 
out implementsClause);
			}

#line  1016 "VBNET.ATG" 
			eventDeclaration = new EventDeclaration {
			Name = name, TypeReference = type, Modifier = m.Modifier, 
			Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause,
			StartLocation = m.GetDeclarationLocation(startPos),
			EndLocation = t.EndLocation
			};
			compilationUnit.AddChild(eventDeclaration);
			
			EndOfStmt();
			break;
		}
		case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: {

#line  1026 "VBNET.ATG" 
			Location startPos = t.Location; 

#line  1028 "VBNET.ATG" 
			m.Check(Modifiers.Fields);
			FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
			fd.StartLocation = m.GetDeclarationLocation(startPos); 
			
			IdentifierForFieldDeclaration();

#line  1032 "VBNET.ATG" 
			string name = t.val; 
			VariableDeclaratorPartAfterIdentifier(
#line  1033 "VBNET.ATG" 
variableDeclarators, name);
			while (la.kind == 12) {
				lexer.NextToken();
				VariableDeclarator(
#line  1034 "VBNET.ATG" 
variableDeclarators);
			}
			EndOfStmt();

#line  1037 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			fd.Fields = variableDeclarators;
			compilationUnit.AddChild(fd);
			
			break;
		}
		case 75: {

#line  1042 "VBNET.ATG" 
			m.Check(Modifiers.Fields); 
			lexer.NextToken();

#line  1043 "VBNET.ATG" 
			m.Add(Modifiers.Const, t.Location);  

#line  1045 "VBNET.ATG" 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
			fd.StartLocation = m.GetDeclarationLocation(t.Location);
			List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>();
			
			ConstantDeclarator(
#line  1049 "VBNET.ATG" 
constantDeclarators);
			while (la.kind == 12) {
				lexer.NextToken();
				ConstantDeclarator(
#line  1050 "VBNET.ATG" 
constantDeclarators);
			}

#line  1052 "VBNET.ATG" 
			fd.Fields = constantDeclarators;
			fd.EndLocation = t.Location;
			
			EndOfStmt();

#line  1057 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			compilationUnit.AddChild(fd);
			
			break;
		}
		case 171: {
			lexer.NextToken();

#line  1063 "VBNET.ATG" 
			m.Check(Modifiers.VBProperties);
			Location startPos = t.Location;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

#line  1067 "VBNET.ATG" 
			string propertyName = t.val; 
			if (la.kind == 25) {
				lexer.NextToken();
				if (StartOf(4)) {
					FormalParameterList(
#line  1068 "VBNET.ATG" 
p);
				}
				Expect(26);
			}
			if (la.kind == 50) {
				lexer.NextToken();
				TypeName(
#line  1069 "VBNET.ATG" 
out type);
			}

#line  1071 "VBNET.ATG" 
			if(type == null) {
			type = new TypeReference("System.Object", true);
			}
			
			if (la.kind == 123) {
				ImplementsClause(
#line  1075 "VBNET.ATG" 
out implementsClause);
			}
			EndOfStmt();
			if (
#line  1079 "VBNET.ATG" 
IsMustOverride(m)) {

#line  1081 "VBNET.ATG" 
				PropertyDeclaration ParameterDeclarationExpressionl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				ParameterDeclarationExpressionl.StartLocation = m.GetDeclarationLocation(startPos);
				ParameterDeclarationExpressionl.EndLocation   = t.Location;
				ParameterDeclarationExpressionl.TypeReference = type;
				ParameterDeclarationExpressionl.InterfaceImplementations = implementsClause;
				ParameterDeclarationExpressionl.Parameters = p;
				compilationUnit.AddChild(ParameterDeclarationExpressionl);
				
			} else if (StartOf(17)) {

#line  1091 "VBNET.ATG" 
				PropertyDeclaration ParameterDeclarationExpressionl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				ParameterDeclarationExpressionl.StartLocation = m.GetDeclarationLocation(startPos);
				ParameterDeclarationExpressionl.EndLocation   = t.Location;
				ParameterDeclarationExpressionl.BodyStart   = t.Location;
				ParameterDeclarationExpressionl.TypeReference = type;
				ParameterDeclarationExpressionl.InterfaceImplementations = implementsClause;
				ParameterDeclarationExpressionl.Parameters = p;
				PropertyGetRegion getRegion;
				PropertySetRegion setRegion;
				
				AccessorDecls(
#line  1101 "VBNET.ATG" 
out getRegion, out setRegion);
				Expect(100);
				Expect(171);
				EndOfStmt();

#line  1105 "VBNET.ATG" 
				ParameterDeclarationExpressionl.GetRegion = getRegion;
				ParameterDeclarationExpressionl.SetRegion = setRegion;
				ParameterDeclarationExpressionl.BodyEnd = t.EndLocation;
				compilationUnit.AddChild(ParameterDeclarationExpressionl);
				
			} else SynErr(243);
			break;
		}
		case 85: {
			lexer.NextToken();

#line  1112 "VBNET.ATG" 
			Location startPos = t.Location; 
			Expect(106);

#line  1114 "VBNET.ATG" 
			m.Check(Modifiers.VBCustomEvents);
			EventAddRemoveRegion eventAccessorDeclaration;
			EventAddRegion addHandlerAccessorDeclaration = null;
			EventRemoveRegion removeHandlerAccessorDeclaration = null;
			EventRaiseRegion raiseEventAccessorDeclaration = null;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

#line  1121 "VBNET.ATG" 
			string customEventName = t.val; 
			Expect(50);
			TypeName(
#line  1122 "VBNET.ATG" 
out type);
			if (la.kind == 123) {
				ImplementsClause(
#line  1123 "VBNET.ATG" 
out implementsClause);
			}
			EndOfStmt();
			while (StartOf(18)) {
				EventAccessorDeclaration(
#line  1126 "VBNET.ATG" 
out eventAccessorDeclaration);

#line  1128 "VBNET.ATG" 
				if(eventAccessorDeclaration is EventAddRegion)
				{
					addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
				}
				else if(eventAccessorDeclaration is EventRemoveRegion)
				{
					removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
				}
				else if(eventAccessorDeclaration is EventRaiseRegion)
				{
					raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
				}
				
			}
			Expect(100);
			Expect(106);
			EndOfStmt();

#line  1144 "VBNET.ATG" 
			if(addHandlerAccessorDeclaration == null)
			{
				Error("Need to provide AddHandler accessor.");
			}
			
			if(removeHandlerAccessorDeclaration == null)
			{
				Error("Need to provide RemoveHandler accessor.");
			}
			
			if(raiseEventAccessorDeclaration == null)
			{
				Error("Need to provide RaiseEvent accessor.");
			}
			
			EventDeclaration decl = new EventDeclaration {
				TypeReference = type, Name = customEventName, Modifier = m.Modifier,
				Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation = t.EndLocation,
				AddRegion = addHandlerAccessorDeclaration,
				RemoveRegion = removeHandlerAccessorDeclaration,
				RaiseRegion = raiseEventAccessorDeclaration
			};
			compilationUnit.AddChild(decl);
			
			break;
		}
		case 147: case 158: case 217: {

#line  1170 "VBNET.ATG" 
			ConversionType opConversionType = ConversionType.None; 
			if (la.kind == 147 || la.kind == 217) {
				if (la.kind == 217) {
					lexer.NextToken();

#line  1171 "VBNET.ATG" 
					opConversionType = ConversionType.Implicit; 
				} else {
					lexer.NextToken();

#line  1172 "VBNET.ATG" 
					opConversionType = ConversionType.Explicit;
				}
			}
			Expect(158);

#line  1175 "VBNET.ATG" 
			m.Check(Modifiers.VBOperators);
			Location startPos = t.Location;
			TypeReference returnType = NullTypeReference.Instance;
			TypeReference operandType = NullTypeReference.Instance;
			string operandName;
			OverloadableOperatorType operatorType;
			AttributeSection section;
			List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
			List<AttributeSection> returnTypeAttributes = new List<AttributeSection>();
			
			OverloadableOperator(
#line  1185 "VBNET.ATG" 
out operatorType);
			Expect(25);
			if (la.kind == 59) {
				lexer.NextToken();
			}
			Identifier();

#line  1186 "VBNET.ATG" 
			operandName = t.val; 
			if (la.kind == 50) {
				lexer.NextToken();
				TypeName(
#line  1187 "VBNET.ATG" 
out operandType);
			}

#line  1188 "VBNET.ATG" 
			parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); 
			while (la.kind == 12) {
				lexer.NextToken();
				if (la.kind == 59) {
					lexer.NextToken();
				}
				Identifier();

#line  1192 "VBNET.ATG" 
				operandName = t.val; 
				if (la.kind == 50) {
					lexer.NextToken();
					TypeName(
#line  1193 "VBNET.ATG" 
out operandType);
				}

#line  1194 "VBNET.ATG" 
				parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); 
			}
			Expect(26);

#line  1197 "VBNET.ATG" 
			Location endPos = t.EndLocation; 
			if (la.kind == 50) {
				lexer.NextToken();
				while (la.kind == 28) {
					AttributeSection(
#line  1198 "VBNET.ATG" 
out section);

#line  1198 "VBNET.ATG" 
					returnTypeAttributes.Add(section); 
				}
				TypeName(
#line  1198 "VBNET.ATG" 
out returnType);

#line  1198 "VBNET.ATG" 
				endPos = t.EndLocation; 
			}
			Expect(1);
			Block(
#line  1200 "VBNET.ATG" 
out stmt);
			Expect(100);
			Expect(158);
			EndOfStmt();

#line  1202 "VBNET.ATG" 
			OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
			Modifier = m.Modifier,
			Attributes = attributes,
			Parameters = parameters,
			TypeReference = returnType,
			OverloadableOperator = operatorType,
			ConversionType = opConversionType,
			ReturnTypeAttributes = returnTypeAttributes,
			Body = (BlockStatement)stmt,
			StartLocation = m.GetDeclarationLocation(startPos),
			EndLocation = endPos
			};
			operatorDeclaration.Body.StartLocation = startPos;
			operatorDeclaration.Body.EndLocation = t.Location;
			compilationUnit.AddChild(operatorDeclaration);
			
			break;
		}
		default: SynErr(244); break;
		}
	}
 public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 {
     if (this.CheckNode(eventDeclaration)) {
         return null;
     }
     return base.VisitEventDeclaration(eventDeclaration, data);
 }
Example #11
0
	void StructMemberDecl(
#line  753 "cs.ATG" 
ModifierList m, List<AttributeSection> attributes) {

#line  755 "cs.ATG" 
		string qualident = null;
		TypeReference type;
		Expression expr;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		BlockStatement stmt = null;
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		TypeReference explicitInterface = null;
		bool isExtensionMethod = false;
		
		if (la.kind == 60) {

#line  765 "cs.ATG" 
			m.Check(Modifiers.Constants); 
			lexer.NextToken();

#line  766 "cs.ATG" 
			Location startPos = t.Location; 
			Type(
#line  767 "cs.ATG" 
out type);
			Identifier();

#line  767 "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  774 "cs.ATG" 
out expr);

#line  774 "cs.ATG" 
			f.Initializer = expr; 
			while (la.kind == 14) {
				lexer.NextToken();
				Identifier();

#line  775 "cs.ATG" 
				f = new VariableDeclaration(t.val);
				f.StartLocation = t.Location;
				f.TypeReference = type;
				SafeAdd(fd, fd.Fields, f);
				
				Expect(3);
				Expr(
#line  780 "cs.ATG" 
out expr);

#line  780 "cs.ATG" 
				f.EndLocation = t.EndLocation; f.Initializer = expr; 
			}
			Expect(11);

#line  781 "cs.ATG" 
			fd.EndLocation = t.EndLocation; AddChild(fd); 
		} else if (
#line  785 "cs.ATG" 
NotVoidPointer()) {

#line  785 "cs.ATG" 
			m.Check(Modifiers.PropertysEventsMethods); 
			Expect(123);

#line  786 "cs.ATG" 
			Location startPos = t.Location; 
			if (
#line  787 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
				TypeName(
#line  788 "cs.ATG" 
out explicitInterface, false);

#line  789 "cs.ATG" 
				if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
				qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
				 } 
			} else if (StartOf(18)) {
				Identifier();

#line  792 "cs.ATG" 
				qualident = t.val; 
			} else SynErr(162);
			if (la.kind == 23) {
				TypeParameterList(
#line  795 "cs.ATG" 
templates);
			}
			Expect(20);
			if (la.kind == 111) {
				lexer.NextToken();

#line  798 "cs.ATG" 
				isExtensionMethod = true; /* C# 3.0 */ 
			}
			if (StartOf(11)) {
				FormalParameterList(
#line  799 "cs.ATG" 
p);
			}
			Expect(21);

#line  800 "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));
			AddChild(methodDeclaration);
			BlockStart(methodDeclaration);
			
			while (la.kind == 127) {
				TypeParameterConstraintsClause(
#line  818 "cs.ATG" 
templates);
			}
			if (la.kind == 16) {
				Block(
#line  820 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(163);

#line  820 "cs.ATG" 
			BlockEnd();
			methodDeclaration.Body  = (BlockStatement)stmt;
			
		} else if (la.kind == 69) {

#line  824 "cs.ATG" 
			m.Check(Modifiers.PropertysEventsMethods); 
			lexer.NextToken();

#line  826 "cs.ATG" 
			EventDeclaration eventDecl = new EventDeclaration {
			Modifier = m.Modifier, 
			Attributes = attributes,
			StartLocation = t.Location
			};
			AddChild(eventDecl);
			BlockStart(eventDecl);
			EventAddRegion addBlock = null;
			EventRemoveRegion removeBlock = null;
			
			Type(
#line  836 "cs.ATG" 
out type);

#line  836 "cs.ATG" 
			eventDecl.TypeReference = type; 
			if (
#line  837 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
				TypeName(
#line  838 "cs.ATG" 
out explicitInterface, false);

#line  839 "cs.ATG" 
				qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); 

#line  840 "cs.ATG" 
				eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); 
			} else if (StartOf(18)) {
				Identifier();

#line  842 "cs.ATG" 
				qualident = t.val; 
				if (la.kind == 3) {
					lexer.NextToken();
					Expr(
#line  843 "cs.ATG" 
out expr);

#line  843 "cs.ATG" 
					eventDecl.Initializer = expr; 
				}
				while (la.kind == 14) {
					lexer.NextToken();

#line  847 "cs.ATG" 
					eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; BlockEnd(); 

#line  849 "cs.ATG" 
					eventDecl = new EventDeclaration {
					  Modifier = eventDecl.Modifier,
					  Attributes = eventDecl.Attributes,
					  StartLocation = eventDecl.StartLocation,
					  TypeReference = eventDecl.TypeReference.Clone()
					};
					AddChild(eventDecl);
					BlockStart(eventDecl);
					
					Identifier();

#line  858 "cs.ATG" 
					qualident = t.val; 
					if (la.kind == 3) {
						lexer.NextToken();
						Expr(
#line  859 "cs.ATG" 
out expr);

#line  859 "cs.ATG" 
						eventDecl.Initializer = expr; 
					}
				}
			} else SynErr(164);

#line  862 "cs.ATG" 
			eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; 
			if (la.kind == 16) {
				lexer.NextToken();

#line  863 "cs.ATG" 
				eventDecl.BodyStart = t.Location; 
				EventAccessorDecls(
#line  864 "cs.ATG" 
out addBlock, out removeBlock);
				Expect(17);

#line  865 "cs.ATG" 
				eventDecl.BodyEnd   = t.EndLocation; 
			}
			if (la.kind == 11) {
				lexer.NextToken();
			}

#line  868 "cs.ATG" 
			BlockEnd();
			eventDecl.AddRegion = addBlock;
			eventDecl.RemoveRegion = removeBlock;
			
		} else if (
#line  874 "cs.ATG" 
IdentAndLPar()) {

#line  874 "cs.ATG" 
			m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); 
			Identifier();

#line  875 "cs.ATG" 
			string name = t.val; Location startPos = t.Location; 
			Expect(20);
			if (StartOf(11)) {

#line  875 "cs.ATG" 
				m.Check(Modifiers.Constructors); 
				FormalParameterList(
#line  876 "cs.ATG" 
p);
			}
			Expect(21);

#line  878 "cs.ATG" 
			ConstructorInitializer init = null;  
			if (la.kind == 9) {

#line  879 "cs.ATG" 
				m.Check(Modifiers.Constructors); 
				ConstructorInitializer(
#line  880 "cs.ATG" 
out init);
			}

#line  882 "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  887 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(165);

#line  887 "cs.ATG" 
			cd.Body = (BlockStatement)stmt; AddChild(cd); 
		} else if (la.kind == 70 || la.kind == 80) {

#line  890 "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  895 "cs.ATG" 
				startPos = t.Location; 
			} else {
				lexer.NextToken();

#line  895 "cs.ATG" 
				isImplicit = false; startPos = t.Location; 
			}
			Expect(92);
			Type(
#line  896 "cs.ATG" 
out type);

#line  896 "cs.ATG" 
			TypeReference operatorType = type; 
			Expect(20);
			Type(
#line  897 "cs.ATG" 
out type);
			Identifier();

#line  897 "cs.ATG" 
			string varName = t.val; 
			Expect(21);

#line  898 "cs.ATG" 
			Location endPos = t.Location; 
			if (la.kind == 16) {
				Block(
#line  899 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();

#line  899 "cs.ATG" 
				stmt = null; 
			} else SynErr(166);

#line  902 "cs.ATG" 
			List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
			parameters.Add(new ParameterDeclarationExpression(type, varName));
			OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
				Name = (isImplicit ? "op_Implicit" : "op_Explicit"),
				Modifier = m.Modifier,
				Attributes = attributes, 
				Parameters = parameters, 
				TypeReference = operatorType,
				ConversionType = isImplicit ? ConversionType.Implicit : ConversionType.Explicit,
				Body = (BlockStatement)stmt,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation = endPos
			};
			AddChild(operatorDeclaration);
			
		} else if (StartOf(21)) {
			TypeDecl(
#line  920 "cs.ATG" 
m, attributes);
		} else if (StartOf(10)) {
			Type(
#line  922 "cs.ATG" 
out type);

#line  922 "cs.ATG" 
			Location startPos = t.Location;  
			if (la.kind == 92) {

#line  924 "cs.ATG" 
				OverloadableOperatorType op;
				m.Check(Modifiers.Operators);
				if (m.isNone) Error("at least one modifier must be set");
				
				lexer.NextToken();
				OverloadableOperator(
#line  928 "cs.ATG" 
out op);

#line  928 "cs.ATG" 
				TypeReference firstType, secondType = null; string secondName = null; 
				Expect(20);

#line  929 "cs.ATG" 
				Location firstStart = la.Location, secondStart = Location.Empty, secondEnd = Location.Empty; 
				Type(
#line  929 "cs.ATG" 
out firstType);
				Identifier();

#line  929 "cs.ATG" 
				string firstName = t.val; Location firstEnd = t.EndLocation; 
				if (la.kind == 14) {
					lexer.NextToken();

#line  930 "cs.ATG" 
					secondStart = la.Location; 
					Type(
#line  930 "cs.ATG" 
out secondType);
					Identifier();

#line  930 "cs.ATG" 
					secondName = t.val; secondEnd = t.EndLocation; 
				} else if (la.kind == 21) {
				} else SynErr(167);

#line  938 "cs.ATG" 
				Location endPos = t.Location; 
				Expect(21);
				if (la.kind == 16) {
					Block(
#line  939 "cs.ATG" 
out stmt);
				} else if (la.kind == 11) {
					lexer.NextToken();
				} else SynErr(168);

#line  941 "cs.ATG" 
				if (op == OverloadableOperatorType.Add && secondType == null)
				op = OverloadableOperatorType.UnaryPlus;
				if (op == OverloadableOperatorType.Subtract && secondType == null)
					op = OverloadableOperatorType.UnaryMinus;
				OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
					Modifier = m.Modifier,
					Attributes = attributes,
					TypeReference = type,
					OverloadableOperator = op,
					Name = GetReflectionNameForOperator(op),
					Body = (BlockStatement)stmt,
					StartLocation = m.GetDeclarationLocation(startPos),
					EndLocation = endPos
				};
				SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName) { StartLocation = firstStart, EndLocation = firstEnd });
				if (secondType != null) {
					SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName) { StartLocation = secondStart, EndLocation = secondEnd });
				}
				AddChild(operatorDeclaration);
				
			} else if (
#line  963 "cs.ATG" 
IsVarDecl()) {

#line  964 "cs.ATG" 
				m.Check(Modifiers.Fields);
				FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
				fd.StartLocation = m.GetDeclarationLocation(startPos); 
				
				if (
#line  968 "cs.ATG" 
m.Contains(Modifiers.Fixed)) {
					VariableDeclarator(
#line  969 "cs.ATG" 
fd);
					Expect(18);
					Expr(
#line  971 "cs.ATG" 
out expr);

#line  971 "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  975 "cs.ATG" 
fd);
						Expect(18);
						Expr(
#line  977 "cs.ATG" 
out expr);

#line  977 "cs.ATG" 
						if (fd.Fields.Count > 0)
						fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; 
						Expect(19);
					}
				} else if (StartOf(18)) {
					VariableDeclarator(
#line  982 "cs.ATG" 
fd);
					while (la.kind == 14) {
						lexer.NextToken();
						VariableDeclarator(
#line  983 "cs.ATG" 
fd);
					}
				} else SynErr(169);
				Expect(11);

#line  985 "cs.ATG" 
				fd.EndLocation = t.EndLocation; AddChild(fd); 
			} else if (la.kind == 111) {

#line  988 "cs.ATG" 
				m.Check(Modifiers.Indexers); 
				lexer.NextToken();
				Expect(18);
				FormalParameterList(
#line  989 "cs.ATG" 
p);
				Expect(19);

#line  989 "cs.ATG" 
				Location endLocation = t.EndLocation; 
				Expect(16);

#line  990 "cs.ATG" 
				PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p);
				indexer.StartLocation = startPos;
				indexer.EndLocation   = endLocation;
				indexer.BodyStart     = t.Location;
				indexer.TypeReference = type;
				PropertyGetRegion getRegion;
				PropertySetRegion setRegion;
				
				AccessorDecls(
#line  998 "cs.ATG" 
out getRegion, out setRegion);
				Expect(17);

#line  999 "cs.ATG" 
				indexer.BodyEnd    = t.EndLocation;
				indexer.GetRegion = getRegion;
				indexer.SetRegion = setRegion;
				AddChild(indexer);
				
			} else if (
#line  1004 "cs.ATG" 
IsIdentifierToken(la)) {
				if (
#line  1005 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
					TypeName(
#line  1006 "cs.ATG" 
out explicitInterface, false);

#line  1007 "cs.ATG" 
					if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
					qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
					 } 
				} else if (StartOf(18)) {
					Identifier();

#line  1010 "cs.ATG" 
					qualident = t.val; 
				} else SynErr(170);

#line  1012 "cs.ATG" 
				Location qualIdentEndLocation = t.EndLocation; 
				if (la.kind == 16 || la.kind == 20 || la.kind == 23) {
					if (la.kind == 20 || la.kind == 23) {

#line  1016 "cs.ATG" 
						m.Check(Modifiers.PropertysEventsMethods); 
						if (la.kind == 23) {
							TypeParameterList(
#line  1018 "cs.ATG" 
templates);
						}
						Expect(20);
						if (la.kind == 111) {
							lexer.NextToken();

#line  1020 "cs.ATG" 
							isExtensionMethod = true; 
						}
						if (StartOf(11)) {
							FormalParameterList(
#line  1021 "cs.ATG" 
p);
						}
						Expect(21);

#line  1023 "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;
						AddChild(methodDeclaration);
						                                      
						while (la.kind == 127) {
							TypeParameterConstraintsClause(
#line  1038 "cs.ATG" 
templates);
						}
						if (la.kind == 16) {
							Block(
#line  1039 "cs.ATG" 
out stmt);
						} else if (la.kind == 11) {
							lexer.NextToken();
						} else SynErr(171);

#line  1039 "cs.ATG" 
						methodDeclaration.Body  = (BlockStatement)stmt; 
					} else {
						lexer.NextToken();

#line  1042 "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  1051 "cs.ATG" 
out getRegion, out setRegion);
						Expect(17);

#line  1053 "cs.ATG" 
						pDecl.GetRegion = getRegion;
						pDecl.SetRegion = setRegion;
						pDecl.BodyEnd = t.EndLocation;
						AddChild(pDecl);
						
					}
				} else if (la.kind == 15) {

#line  1061 "cs.ATG" 
					m.Check(Modifiers.Indexers); 
					lexer.NextToken();
					Expect(111);
					Expect(18);
					FormalParameterList(
#line  1062 "cs.ATG" 
p);
					Expect(19);

#line  1063 "cs.ATG" 
					PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p);
					indexer.StartLocation = m.GetDeclarationLocation(startPos);
					indexer.EndLocation   = t.EndLocation;
					indexer.TypeReference = type;
					if (explicitInterface != null)
					SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this"));
					      PropertyGetRegion getRegion;
					      PropertySetRegion setRegion;
					    
					Expect(16);

#line  1072 "cs.ATG" 
					Location bodyStart = t.Location; 
					AccessorDecls(
#line  1073 "cs.ATG" 
out getRegion, out setRegion);
					Expect(17);

#line  1074 "cs.ATG" 
					indexer.BodyStart = bodyStart;
					indexer.BodyEnd   = t.EndLocation;
					indexer.GetRegion = getRegion;
					indexer.SetRegion = setRegion;
					AddChild(indexer);
					
				} else SynErr(172);
			} else SynErr(173);
		} else SynErr(174);
	}
Example #12
0
	void InterfaceMemberDecl() {

#line  1072 "cs.ATG" 
		TypeReference type;
		
		AttributeSection section;
		Modifiers mod = Modifiers.None;
		List<AttributeSection> attributes = new List<AttributeSection>();
		List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
		string name;
		PropertyGetRegion getBlock;
		PropertySetRegion setBlock;
		Location startLocation = new Location(-1, -1);
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		
		while (la.kind == 18) {
			AttributeSection(
#line  1085 "cs.ATG" 
out section);

#line  1085 "cs.ATG" 
			attributes.Add(section); 
		}
		if (la.kind == 89) {
			lexer.NextToken();

#line  1086 "cs.ATG" 
			mod = Modifiers.New; startLocation = t.Location; 
		}
		if (
#line  1089 "cs.ATG" 
NotVoidPointer()) {
			Expect(123);

#line  1089 "cs.ATG" 
			if (startLocation.IsEmpty) startLocation = t.Location; 
			Identifier();

#line  1090 "cs.ATG" 
			name = t.val; 
			if (la.kind == 23) {
				TypeParameterList(
#line  1091 "cs.ATG" 
templates);
			}
			Expect(20);
			if (StartOf(11)) {
				FormalParameterList(
#line  1092 "cs.ATG" 
parameters);
			}
			Expect(21);
			while (la.kind == 127) {
				TypeParameterConstraintsClause(
#line  1093 "cs.ATG" 
templates);
			}
			Expect(11);

#line  1095 "cs.ATG" 
            MethodDeclaration md = new MethodDeclaration();
            md.EndLocation = t.EndLocation;
            md.StartLocation = startLocation;
            md.Templates = templates;
            md.Attributes = attributes;
            md.Parameters = parameters;
            md.TypeReference = new TypeReference("System.Void", true);
            md.Modifier = mod;
            md.Name = name;

			compilationUnit.AddChild(md);
			
		} else if (StartOf(23)) {
			if (StartOf(10)) {
				Type(
#line  1103 "cs.ATG" 
out type);

#line  1103 "cs.ATG" 
				if (startLocation.IsEmpty) startLocation = t.Location; 
				if (StartOf(19)) {
					Identifier();

#line  1105 "cs.ATG" 
					name = t.val; Location qualIdentEndLocation = t.EndLocation; 
					if (la.kind == 20 || la.kind == 23) {
						if (la.kind == 23) {
							TypeParameterList(
#line  1109 "cs.ATG" 
templates);
						}
						Expect(20);
						if (StartOf(11)) {
							FormalParameterList(
#line  1110 "cs.ATG" 
parameters);
						}
						Expect(21);
						while (la.kind == 127) {
							TypeParameterConstraintsClause(
#line  1112 "cs.ATG" 
templates);
						}
						Expect(11);

#line  1113 "cs.ATG" 
                        MethodDeclaration md = new MethodDeclaration();
                        md.EndLocation = t.EndLocation;
                        md.StartLocation = startLocation;
                        md.Templates = templates;
                        md.Attributes = attributes;
                        md.Parameters = parameters;
                        md.TypeReference = type;
                        md.Modifier = mod;
                        md.Name = name;

						compilationUnit.AddChild(md);
						
					} else if (la.kind == 16) {

#line  1122 "cs.ATG" 
						PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes);
						compilationUnit.AddChild(pd); 
						lexer.NextToken();

#line  1125 "cs.ATG" 
						Location bodyStart = t.Location;
						InterfaceAccessors(
#line  1126 "cs.ATG" 
out getBlock, out setBlock);
						Expect(17);

#line  1127 "cs.ATG" 
						pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; 
					} else SynErr(175);
				} else if (la.kind == 111) {
					lexer.NextToken();
					Expect(18);
					FormalParameterList(
#line  1130 "cs.ATG" 
parameters);
					Expect(19);

#line  1131 "cs.ATG" 
					Location bracketEndLocation = t.EndLocation; 

#line  1132 "cs.ATG" 
					IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes);
					compilationUnit.AddChild(id); 
					Expect(16);

#line  1134 "cs.ATG" 
					Location bodyStart = t.Location;
					InterfaceAccessors(
#line  1135 "cs.ATG" 
out getBlock, out setBlock);
					Expect(17);

#line  1137 "cs.ATG" 
					id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation;  id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;
				} else SynErr(176);
			} else {
				lexer.NextToken();

#line  1140 "cs.ATG" 
				if (startLocation.IsEmpty) startLocation = t.Location; 
				Type(
#line  1141 "cs.ATG" 
out type);
				Identifier();

#line  1142 "cs.ATG" 
                EventDeclaration ed = new EventDeclaration();
                ed.Attributes = attributes;
                ed.Modifier = mod;
                ed.Name = t.val;
                ed.TypeReference = type;
				compilationUnit.AddChild(ed);
				
				Expect(11);

#line  1148 "cs.ATG" 
				ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; 
			}
		} else SynErr(177);
	}
Example #13
0
 public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 {
     Debug.Assert((eventDeclaration != null));
     Debug.Assert((eventDeclaration.Attributes != null));
     Debug.Assert((eventDeclaration.Parameters != null));
     Debug.Assert((eventDeclaration.InterfaceImplementations != null));
     Debug.Assert((eventDeclaration.TypeReference != null));
     Debug.Assert((eventDeclaration.AddRegion != null));
     Debug.Assert((eventDeclaration.RemoveRegion != null));
     Debug.Assert((eventDeclaration.RaiseRegion != null));
     Debug.Assert((eventDeclaration.Initializer != null));
     foreach (AttributeSection o in eventDeclaration.Attributes) {
         Debug.Assert(o != null);
         o.AcceptVisitor(this, data);
     }
     foreach (ParameterDeclarationExpression o in eventDeclaration.Parameters) {
         Debug.Assert(o != null);
         o.AcceptVisitor(this, data);
     }
     foreach (InterfaceImplementation o in eventDeclaration.InterfaceImplementations) {
         Debug.Assert(o != null);
         o.AcceptVisitor(this, data);
     }
     eventDeclaration.TypeReference.AcceptVisitor(this, data);
     eventDeclaration.AddRegion.AcceptVisitor(this, data);
     eventDeclaration.RemoveRegion.AcceptVisitor(this, data);
     eventDeclaration.RaiseRegion.AcceptVisitor(this, data);
     return eventDeclaration.Initializer.AcceptVisitor(this, data);
 }
 public object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 {
     throw new NotImplementedException ();
 }
		public object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
		{
			B.Event m = new B.Event(GetLexicalInfo(eventDeclaration));
			m.Name = eventDeclaration.Name;
			m.Modifiers = ConvertModifier(eventDeclaration, B.TypeMemberModifiers.Private);
			ConvertAttributes(eventDeclaration.Attributes, m.Attributes);
			if (currentType != null) currentType.Members.Add(m);
			m.EndSourceLocation = GetLocation(eventDeclaration.EndLocation);
			m.Type = ConvertTypeReference(eventDeclaration.TypeReference);
			if (eventDeclaration.InterfaceImplementations.Count > 0) {
				AddError(eventDeclaration, "Explicit interface implementation is not supported for events.");
			}
			if (eventDeclaration.Parameters.Count > 0) {
				AddError(eventDeclaration, "Events with parameters are not supported.");
			}
			if (eventDeclaration.HasAddRegion) {
				m.Add = new B.Method(GetLexicalInfo(eventDeclaration.AddRegion));
				ConvertAttributes(eventDeclaration.AddRegion.Attributes, m.Add.Attributes);
				m.Modifiers = ConvertModifier(eventDeclaration.AddRegion, m.Visibility);
				m.Add.Body = ConvertMethodBlock(eventDeclaration.AddRegion.Block);
			}
			if (eventDeclaration.HasRemoveRegion) {
				m.Remove = new B.Method(GetLexicalInfo(eventDeclaration.RemoveRegion));
				ConvertAttributes(eventDeclaration.RemoveRegion.Attributes, m.Remove.Attributes);
				m.Modifiers = ConvertModifier(eventDeclaration.RemoveRegion, m.Visibility);
				m.Remove.Body = ConvertMethodBlock(eventDeclaration.RemoveRegion.Block);
			}
			if (eventDeclaration.HasRaiseRegion) {
				m.Raise = new B.Method(GetLexicalInfo(eventDeclaration.RaiseRegion));
				ConvertAttributes(eventDeclaration.RaiseRegion.Attributes, m.Raise.Attributes);
				m.Modifiers = ConvertModifier(eventDeclaration.RaiseRegion, m.Visibility);
				m.Raise.Body = ConvertMethodBlock(eventDeclaration.RaiseRegion.Block);
			}
			return m;
		}
 public virtual bool VisitEventDeclaration(EventDeclaration eventDeclaration, object d)
 {
     if ((eventDeclaration == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.Attributes == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.Parameters == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.InterfaceImplementations == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.TypeReference == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.AddRegion == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.RemoveRegion == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.RaiseRegion == null)) {
         return SetFailure();
     }
     if ((eventDeclaration.Initializer == null)) {
         return SetFailure();
     }
     if(eventDeclaration.GetType() != d.GetType()) {return SetFailure();}
     var data = (EventDeclaration)d;
     if (!IsMatch(eventDeclaration, data)) {
         return SetFailure();
     }
     if (eventDeclaration.Attributes.Count == data.Attributes.Count) {
     for (int i=0; i<eventDeclaration.Attributes.Count;i++) {
         AttributeSection o = eventDeclaration.Attributes[i];
         if(o == null){return SetFailure();}
         if((bool)o.AcceptVisitor(this, data.Attributes[i]) == false) return SetFailure();
     }			}			else { return SetFailure(); }
     if (eventDeclaration.Parameters.Count == data.Parameters.Count) {
     for (int i=0; i<eventDeclaration.Parameters.Count;i++) {
         ParameterDeclarationExpression o = eventDeclaration.Parameters[i];
         if(o == null){return SetFailure();}
         if((bool)o.AcceptVisitor(this, data.Parameters[i]) == false) return SetFailure();
     }			}			else { return SetFailure(); }
     if (eventDeclaration.InterfaceImplementations.Count == data.InterfaceImplementations.Count) {
     for (int i=0; i<eventDeclaration.InterfaceImplementations.Count;i++) {
         InterfaceImplementation o = eventDeclaration.InterfaceImplementations[i];
         if(o == null){return SetFailure();}
         if((bool)o.AcceptVisitor(this, data.InterfaceImplementations[i]) == false) return SetFailure();
     }			}			else { return SetFailure(); }
     eventDeclaration.TypeReference.AcceptVisitor(this, data.TypeReference);
     eventDeclaration.AddRegion.AcceptVisitor(this, data.AddRegion);
     eventDeclaration.RemoveRegion.AcceptVisitor(this, data.RemoveRegion);
     eventDeclaration.RaiseRegion.AcceptVisitor(this, data.RaiseRegion);
     return eventDeclaration.Initializer.AcceptVisitor(this, data.Initializer);
 }
Example #17
0
		public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
		{
			if (!this.copyAllMembers)
				this.RemoveCurrentNode();
			return base.VisitEventDeclaration(eventDeclaration, data);
		}
Example #18
0
	void StructureMemberDecl(
#line  737 "VBNET.ATG" 
ModifierList m, List<AttributeSection> attributes) {

#line  739 "VBNET.ATG" 
		TypeReference type = null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		Statement stmt = null;
		List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		
		switch (la.kind) {
		case 67: case 80: case 90: case 112: case 121: case 166: {
			NonModuleDeclaration(
#line  746 "VBNET.ATG" 
m, attributes);
			break;
		}
		case 167: {
			lexer.NextToken();

#line  750 "VBNET.ATG" 
			Location startPos = t.Location;
			
			if (StartOf(13)) {

#line  754 "VBNET.ATG" 
				string name = String.Empty;
				MethodDeclaration methodDeclaration; List<string> handlesClause = null;
				List<InterfaceImplementation> implementsClause = null;
				
				Identifier();

#line  760 "VBNET.ATG" 
				name = t.val;
				m.Check(Modifiers.VBMethods);
				
				TypeParameterList(
#line  763 "VBNET.ATG" 
templates);
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  764 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
				if (la.kind == 105 || la.kind == 107) {
					if (la.kind == 107) {
						ImplementsClause(
#line  767 "VBNET.ATG" 
out implementsClause);
					} else {
						HandlesClause(
#line  769 "VBNET.ATG" 
out handlesClause);
					}
				}

#line  772 "VBNET.ATG" 
				Location endLocation = t.EndLocation; 
				Expect(1);
				if (
#line  776 "VBNET.ATG" 
IsMustOverride(m)) {

#line  778 "VBNET.ATG" 
					methodDeclaration = new MethodDeclaration {
					Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
					StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
					TypeReference = new TypeReference("", "System.Void"),
					Templates = templates,
					HandlesClause = handlesClause,
					InterfaceImplementations = implementsClause
					};
					compilationUnit.AddChild(methodDeclaration);
					
				} else if (StartOf(14)) {

#line  790 "VBNET.ATG" 
					methodDeclaration = new MethodDeclaration {
					Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
					StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
					TypeReference = new TypeReference("", "System.Void"),
					Templates = templates,
					HandlesClause = handlesClause,
					InterfaceImplementations = implementsClause
					};
					compilationUnit.AddChild(methodDeclaration);
					

#line  801 "VBNET.ATG" 
					if (ParseMethodBodies) { 
					Block(
#line  802 "VBNET.ATG" 
out stmt);
					Expect(88);
					Expect(167);

#line  804 "VBNET.ATG" 
					} else {
					// don't parse method body
					lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
					  }
					

#line  810 "VBNET.ATG" 
					methodDeclaration.Body  = (BlockStatement)stmt; 

#line  811 "VBNET.ATG" 
					methodDeclaration.Body.EndLocation = t.EndLocation; 
					Expect(1);
				} else SynErr(222);
			} else if (la.kind == 127) {
				lexer.NextToken();
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  814 "VBNET.ATG" 
p);
					}
					Expect(25);
				}

#line  815 "VBNET.ATG" 
				m.Check(Modifiers.Constructors); 

#line  816 "VBNET.ATG" 
				Location constructorEndLocation = t.EndLocation; 
				Expect(1);

#line  819 "VBNET.ATG" 
				if (ParseMethodBodies) { 
				Block(
#line  820 "VBNET.ATG" 
out stmt);
				Expect(88);
				Expect(167);

#line  822 "VBNET.ATG" 
				} else {
				// don't parse method body
				lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
				  }
				

#line  828 "VBNET.ATG" 
				Location endLocation = t.EndLocation; 
				Expect(1);

#line  830 "VBNET.ATG" 
				ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); 
				cd.StartLocation = m.GetDeclarationLocation(startPos);
				cd.EndLocation   = constructorEndLocation;
				cd.Body = (BlockStatement)stmt;
				cd.Body.EndLocation   = endLocation;
				compilationUnit.AddChild(cd);
				
			} else SynErr(223);
			break;
		}
		case 100: {
			lexer.NextToken();

#line  842 "VBNET.ATG" 
			m.Check(Modifiers.VBMethods);
			string name = String.Empty;
			Location startPos = t.Location;
			MethodDeclaration methodDeclaration;List<string> handlesClause = null;
			List<InterfaceImplementation> implementsClause = null;
			AttributeSection returnTypeAttributeSection = null;
			
			Identifier();

#line  849 "VBNET.ATG" 
			name = t.val; 
			TypeParameterList(
#line  850 "VBNET.ATG" 
templates);
			if (la.kind == 24) {
				lexer.NextToken();
				if (StartOf(4)) {
					FormalParameterList(
#line  851 "VBNET.ATG" 
p);
				}
				Expect(25);
			}
			if (la.kind == 48) {
				lexer.NextToken();
				while (la.kind == 27) {
					AttributeSection(
#line  852 "VBNET.ATG" 
out returnTypeAttributeSection);
				}
				TypeName(
#line  852 "VBNET.ATG" 
out type);
			}

#line  854 "VBNET.ATG" 
			if(type == null) {
			type = new TypeReference("System.Object");
			}
			
			if (la.kind == 105 || la.kind == 107) {
				if (la.kind == 107) {
					ImplementsClause(
#line  860 "VBNET.ATG" 
out implementsClause);
				} else {
					HandlesClause(
#line  862 "VBNET.ATG" 
out handlesClause);
				}
			}
			Expect(1);
			if (
#line  868 "VBNET.ATG" 
IsMustOverride(m)) {

#line  870 "VBNET.ATG" 
				methodDeclaration = new MethodDeclaration {
				Name = name, Modifier = m.Modifier, TypeReference = type,
				Parameters = p, Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation   = t.EndLocation,
				HandlesClause = handlesClause,
				Templates     = templates,
				InterfaceImplementations = implementsClause
				};
				if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					methodDeclaration.Attributes.Add(returnTypeAttributeSection);
				}
				compilationUnit.AddChild(methodDeclaration);
				
			} else if (StartOf(14)) {

#line  887 "VBNET.ATG" 
				methodDeclaration = new MethodDeclaration {
				Name = name, Modifier = m.Modifier, TypeReference = type,
				Parameters = p, Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation   = t.EndLocation,
				Templates     = templates,
				HandlesClause = handlesClause,
				InterfaceImplementations = implementsClause
				};
				if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					methodDeclaration.Attributes.Add(returnTypeAttributeSection);
				}
				
				compilationUnit.AddChild(methodDeclaration);
				
				if (ParseMethodBodies) { 
				Block(
#line  904 "VBNET.ATG" 
out stmt);
				Expect(88);
				Expect(100);

#line  906 "VBNET.ATG" 
				} else {
				// don't parse method body
				lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
				}
				methodDeclaration.Body = (BlockStatement)stmt;
				methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
				methodDeclaration.Body.EndLocation   = t.EndLocation;
				
				Expect(1);
			} else SynErr(224);
			break;
		}
		case 78: {
			lexer.NextToken();

#line  920 "VBNET.ATG" 
			m.Check(Modifiers.VBExternalMethods);
			Location startPos = t.Location;
			CharsetModifier charsetModifer = CharsetModifier.None;
			string library = String.Empty;
			string alias = null;
			string name = String.Empty;
			
			if (StartOf(15)) {
				Charset(
#line  927 "VBNET.ATG" 
out charsetModifer);
			}
			if (la.kind == 167) {
				lexer.NextToken();
				Identifier();

#line  930 "VBNET.ATG" 
				name = t.val; 
				Expect(115);
				Expect(3);

#line  931 "VBNET.ATG" 
				library = t.literalValue as string; 
				if (la.kind == 44) {
					lexer.NextToken();
					Expect(3);

#line  932 "VBNET.ATG" 
					alias = t.literalValue as string; 
				}
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  933 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
				Expect(1);

#line  936 "VBNET.ATG" 
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer);
				declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
				declareDeclaration.EndLocation   = t.EndLocation;
				compilationUnit.AddChild(declareDeclaration);
				
			} else if (la.kind == 100) {
				lexer.NextToken();
				Identifier();

#line  943 "VBNET.ATG" 
				name = t.val; 
				Expect(115);
				Expect(3);

#line  944 "VBNET.ATG" 
				library = t.literalValue as string; 
				if (la.kind == 44) {
					lexer.NextToken();
					Expect(3);

#line  945 "VBNET.ATG" 
					alias = t.literalValue as string; 
				}
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  946 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
				if (la.kind == 48) {
					lexer.NextToken();
					TypeName(
#line  947 "VBNET.ATG" 
out type);
				}
				Expect(1);

#line  950 "VBNET.ATG" 
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
				declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
				declareDeclaration.EndLocation   = t.EndLocation;
				compilationUnit.AddChild(declareDeclaration);
				
			} else SynErr(225);
			break;
		}
		case 93: {
			lexer.NextToken();

#line  960 "VBNET.ATG" 
			m.Check(Modifiers.VBEvents);
			Location startPos = t.Location;
			EventDeclaration eventDeclaration;
			string name = String.Empty;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

#line  966 "VBNET.ATG" 
			name= t.val; 
			if (la.kind == 48) {
				lexer.NextToken();
				TypeName(
#line  968 "VBNET.ATG" 
out type);
			} else if (la.kind == 1 || la.kind == 24 || la.kind == 107) {
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  970 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
			} else SynErr(226);
			if (la.kind == 107) {
				ImplementsClause(
#line  972 "VBNET.ATG" 
out implementsClause);
			}

#line  974 "VBNET.ATG" 
			eventDeclaration = new EventDeclaration {
			Name = name, TypeReference = type, Modifier = m.Modifier, 
			Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause,
			StartLocation = m.GetDeclarationLocation(startPos),
			EndLocation = t.EndLocation
			};
			compilationUnit.AddChild(eventDeclaration);
			
			Expect(1);
			break;
		}
		case 2: case 47: case 49: case 50: case 51: case 70: case 95: case 134: case 144: case 169: case 176: case 177: {

#line  984 "VBNET.ATG" 
			Location startPos = t.Location; 

#line  986 "VBNET.ATG" 
			m.Check(Modifiers.Fields);
			FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
			fd.StartLocation = m.GetDeclarationLocation(startPos); 
			
			IdentifierForFieldDeclaration();

#line  990 "VBNET.ATG" 
			string name = t.val; 
			VariableDeclaratorPartAfterIdentifier(
#line  991 "VBNET.ATG" 
variableDeclarators, name);
			while (la.kind == 12) {
				lexer.NextToken();
				VariableDeclarator(
#line  992 "VBNET.ATG" 
variableDeclarators);
			}
			Expect(1);

#line  995 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			fd.Fields = variableDeclarators;
			compilationUnit.AddChild(fd);
			
			break;
		}
		case 71: {

#line  1000 "VBNET.ATG" 
			m.Check(Modifiers.Fields); 
			lexer.NextToken();

#line  1001 "VBNET.ATG" 
			m.Add(Modifiers.Const, t.Location);  

#line  1003 "VBNET.ATG" 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
			fd.StartLocation = m.GetDeclarationLocation(t.Location);
			List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>();
			
			ConstantDeclarator(
#line  1007 "VBNET.ATG" 
constantDeclarators);
			while (la.kind == 12) {
				lexer.NextToken();
				ConstantDeclarator(
#line  1008 "VBNET.ATG" 
constantDeclarators);
			}

#line  1010 "VBNET.ATG" 
			fd.Fields = constantDeclarators;
			fd.EndLocation = t.Location;
			
			Expect(1);

#line  1015 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			compilationUnit.AddChild(fd);
			
			break;
		}
		case 146: {
			lexer.NextToken();

#line  1021 "VBNET.ATG" 
			m.Check(Modifiers.VBProperties);
			Location startPos = t.Location;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

#line  1025 "VBNET.ATG" 
			string propertyName = t.val; 
			if (la.kind == 24) {
				lexer.NextToken();
				if (StartOf(4)) {
					FormalParameterList(
#line  1026 "VBNET.ATG" 
p);
				}
				Expect(25);
			}
			if (la.kind == 48) {
				lexer.NextToken();
				TypeName(
#line  1027 "VBNET.ATG" 
out type);
			}

#line  1029 "VBNET.ATG" 
			if(type == null) {
			type = new TypeReference("System.Object");
			}
			
			if (la.kind == 107) {
				ImplementsClause(
#line  1033 "VBNET.ATG" 
out implementsClause);
			}
			Expect(1);
			if (
#line  1037 "VBNET.ATG" 
IsMustOverride(m)) {

#line  1039 "VBNET.ATG" 
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				pDecl.StartLocation = m.GetDeclarationLocation(startPos);
				pDecl.EndLocation   = t.Location;
				pDecl.TypeReference = type;
				pDecl.InterfaceImplementations = implementsClause;
				pDecl.Parameters = p;
				compilationUnit.AddChild(pDecl);
				
			} else if (StartOf(16)) {

#line  1049 "VBNET.ATG" 
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				pDecl.StartLocation = m.GetDeclarationLocation(startPos);
				pDecl.EndLocation   = t.Location;
				pDecl.BodyStart   = t.Location;
				pDecl.TypeReference = type;
				pDecl.InterfaceImplementations = implementsClause;
				pDecl.Parameters = p;
				PropertyGetRegion getRegion;
				PropertySetRegion setRegion;
				
				AccessorDecls(
#line  1059 "VBNET.ATG" 
out getRegion, out setRegion);
				Expect(88);
				Expect(146);
				Expect(1);

#line  1063 "VBNET.ATG" 
				pDecl.GetRegion = getRegion;
				pDecl.SetRegion = setRegion;
				pDecl.BodyEnd = t.EndLocation;
				compilationUnit.AddChild(pDecl);
				
			} else SynErr(227);
			break;
		}
		case 205: {
			lexer.NextToken();

#line  1070 "VBNET.ATG" 
			Location startPos = t.Location; 
			Expect(93);

#line  1072 "VBNET.ATG" 
			m.Check(Modifiers.VBCustomEvents);
			EventAddRemoveRegion eventAccessorDeclaration;
			EventAddRegion addHandlerAccessorDeclaration = null;
			EventRemoveRegion removeHandlerAccessorDeclaration = null;
			EventRaiseRegion raiseEventAccessorDeclaration = null;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

#line  1079 "VBNET.ATG" 
			string customEventName = t.val; 
			Expect(48);
			TypeName(
#line  1080 "VBNET.ATG" 
out type);
			if (la.kind == 107) {
				ImplementsClause(
#line  1081 "VBNET.ATG" 
out implementsClause);
			}
			Expect(1);
			while (StartOf(17)) {
				EventAccessorDeclaration(
#line  1084 "VBNET.ATG" 
out eventAccessorDeclaration);

#line  1086 "VBNET.ATG" 
				if(eventAccessorDeclaration is EventAddRegion)
				{
					addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
				}
				else if(eventAccessorDeclaration is EventRemoveRegion)
				{
					removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
				}
				else if(eventAccessorDeclaration is EventRaiseRegion)
				{
					raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
				}
				
			}
			Expect(88);
			Expect(93);
			Expect(1);

#line  1102 "VBNET.ATG" 
			if(addHandlerAccessorDeclaration == null)
			{
				Error("Need to provide AddHandler accessor.");
			}
			
			if(removeHandlerAccessorDeclaration == null)
			{
				Error("Need to provide RemoveHandler accessor.");
			}
			
			if(raiseEventAccessorDeclaration == null)
			{
				Error("Need to provide RaiseEvent accessor.");
			}
			
			EventDeclaration decl = new EventDeclaration {
				TypeReference = type, Name = customEventName, Modifier = m.Modifier,
				Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation = t.EndLocation,
				AddRegion = addHandlerAccessorDeclaration,
				RemoveRegion = removeHandlerAccessorDeclaration,
				RaiseRegion = raiseEventAccessorDeclaration
			};
			compilationUnit.AddChild(decl);
			
			break;
		}
		case 188: case 202: case 203: {

#line  1128 "VBNET.ATG" 
			ConversionType opConversionType = ConversionType.None; 
			if (la.kind == 202 || la.kind == 203) {
				if (la.kind == 203) {
					lexer.NextToken();

#line  1129 "VBNET.ATG" 
					opConversionType = ConversionType.Implicit; 
				} else {
					lexer.NextToken();

#line  1130 "VBNET.ATG" 
					opConversionType = ConversionType.Explicit;
				}
			}
			Expect(188);

#line  1133 "VBNET.ATG" 
			m.Check(Modifiers.VBOperators);
			Location startPos = t.Location;
			TypeReference returnType = NullTypeReference.Instance;
			TypeReference operandType = NullTypeReference.Instance;
			string operandName;
			OverloadableOperatorType operatorType;
			AttributeSection section;
			List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
			List<AttributeSection> returnTypeAttributes = new List<AttributeSection>();
			
			OverloadableOperator(
#line  1143 "VBNET.ATG" 
out operatorType);
			Expect(24);
			if (la.kind == 55) {
				lexer.NextToken();
			}
			Identifier();

#line  1144 "VBNET.ATG" 
			operandName = t.val; 
			if (la.kind == 48) {
				lexer.NextToken();
				TypeName(
#line  1145 "VBNET.ATG" 
out operandType);
			}

#line  1146 "VBNET.ATG" 
			parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); 
			while (la.kind == 12) {
				lexer.NextToken();
				if (la.kind == 55) {
					lexer.NextToken();
				}
				Identifier();

#line  1150 "VBNET.ATG" 
				operandName = t.val; 
				if (la.kind == 48) {
					lexer.NextToken();
					TypeName(
#line  1151 "VBNET.ATG" 
out operandType);
				}

#line  1152 "VBNET.ATG" 
				parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); 
			}
			Expect(25);

#line  1155 "VBNET.ATG" 
			Location endPos = t.EndLocation; 
			if (la.kind == 48) {
				lexer.NextToken();
				while (la.kind == 27) {
					AttributeSection(
#line  1156 "VBNET.ATG" 
out section);

#line  1156 "VBNET.ATG" 
					returnTypeAttributes.Add(section); 
				}
				TypeName(
#line  1156 "VBNET.ATG" 
out returnType);

#line  1156 "VBNET.ATG" 
				endPos = t.EndLocation; 
				Expect(1);
			}
			Block(
#line  1157 "VBNET.ATG" 
out stmt);
			Expect(88);
			Expect(188);
			Expect(1);

#line  1159 "VBNET.ATG" 
			OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
			Modifier = m.Modifier,
			Attributes = attributes,
			Parameters = parameters,
			TypeReference = returnType,
			OverloadableOperator = operatorType,
			ConversionType = opConversionType,
			ReturnTypeAttributes = returnTypeAttributes,
			Body = (BlockStatement)stmt,
			StartLocation = m.GetDeclarationLocation(startPos),
			EndLocation = endPos
			};
			operatorDeclaration.Body.StartLocation = startPos;
			operatorDeclaration.Body.EndLocation = t.Location;
			compilationUnit.AddChild(operatorDeclaration);
			
			break;
		}
		default: SynErr(228); break;
		}
	}
Example #19
0
	void InterfaceMemberDecl() {

#line  596 "VBNET.ATG" 
		TypeReference type =null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		AttributeSection section, returnTypeAttributeSection = null;
		ModifierList mod = new ModifierList();
		List<AttributeSection> attributes = new List<AttributeSection>();
		string name;
		
		if (StartOf(18)) {
			while (la.kind == 27) {
				AttributeSection(
#line  604 "VBNET.ATG" 
out section);

#line  604 "VBNET.ATG" 
				attributes.Add(section); 
			}
			while (StartOf(8)) {
				MemberModifier(
#line  607 "VBNET.ATG" 
mod);
			}
			if (la.kind == 93) {
				lexer.NextToken();

#line  611 "VBNET.ATG" 
				mod.Check(Modifiers.VBInterfaceEvents);
				Location startLocation = t.Location;
				
				Identifier();

#line  614 "VBNET.ATG" 
				name = t.val; 
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  615 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
				if (la.kind == 48) {
					lexer.NextToken();
					TypeName(
#line  616 "VBNET.ATG" 
out type);
				}
				Expect(1);

#line  619 "VBNET.ATG" 
				EventDeclaration ed = new EventDeclaration {
				Name = name, TypeReference = type, Modifier = mod.Modifier,
				Parameters = p, Attributes = attributes,
				StartLocation = startLocation, EndLocation = t.EndLocation
				};
				compilationUnit.AddChild(ed);
				
			} else if (la.kind == 167) {
				lexer.NextToken();

#line  629 "VBNET.ATG" 
				Location startLocation =  t.Location;
				mod.Check(Modifiers.VBInterfaceMethods);
				
				Identifier();

#line  632 "VBNET.ATG" 
				name = t.val; 
				TypeParameterList(
#line  633 "VBNET.ATG" 
templates);
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  634 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
				Expect(1);

#line  637 "VBNET.ATG" 
				MethodDeclaration md = new MethodDeclaration {
				Name = name, 
				Modifier = mod.Modifier, 
				Parameters = p,
				Attributes = attributes,
				TypeReference = new TypeReference("", "System.Void"),
				StartLocation = startLocation,
				EndLocation = t.EndLocation,
				Templates = templates
				};
				compilationUnit.AddChild(md);
				
			} else if (la.kind == 100) {
				lexer.NextToken();

#line  652 "VBNET.ATG" 
				mod.Check(Modifiers.VBInterfaceMethods);
				Location startLocation = t.Location;
				
				Identifier();

#line  655 "VBNET.ATG" 
				name = t.val; 
				TypeParameterList(
#line  656 "VBNET.ATG" 
templates);
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  657 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
				if (la.kind == 48) {
					lexer.NextToken();
					while (la.kind == 27) {
						AttributeSection(
#line  658 "VBNET.ATG" 
out returnTypeAttributeSection);
					}
					TypeName(
#line  658 "VBNET.ATG" 
out type);
				}

#line  660 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object");
				}
				MethodDeclaration md = new MethodDeclaration {
					Name = name, Modifier = mod.Modifier, 
					TypeReference = type, Parameters = p, Attributes = attributes
				};
				if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					md.Attributes.Add(returnTypeAttributeSection);
				}
				md.StartLocation = startLocation;
				md.EndLocation = t.EndLocation;
				md.Templates = templates;
				compilationUnit.AddChild(md);
				
				Expect(1);
			} else if (la.kind == 146) {
				lexer.NextToken();

#line  680 "VBNET.ATG" 
				Location startLocation = t.Location;
				mod.Check(Modifiers.VBInterfaceProperties);
				
				Identifier();

#line  683 "VBNET.ATG" 
				name = t.val;  
				if (la.kind == 24) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  684 "VBNET.ATG" 
p);
					}
					Expect(25);
				}
				if (la.kind == 48) {
					lexer.NextToken();
					TypeName(
#line  685 "VBNET.ATG" 
out type);
				}

#line  687 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object");
				}
				
				Expect(1);

#line  693 "VBNET.ATG" 
				PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
				pd.Parameters = p;
				pd.EndLocation = t.EndLocation;
				pd.StartLocation = startLocation;
				compilationUnit.AddChild(pd);
				
			} else SynErr(229);
		} else if (StartOf(19)) {
			NonModuleDeclaration(
#line  701 "VBNET.ATG" 
mod, attributes);
		} else SynErr(230);
	}
		public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) {
			Debug.Assert((eventDeclaration != null));
			Debug.Assert((eventDeclaration.Attributes != null));
			Debug.Assert((eventDeclaration.Parameters != null));
			Debug.Assert((eventDeclaration.InterfaceImplementations != null));
			Debug.Assert((eventDeclaration.TypeReference != null));
			Debug.Assert((eventDeclaration.AddRegion != null));
			Debug.Assert((eventDeclaration.RemoveRegion != null));
			Debug.Assert((eventDeclaration.RaiseRegion != null));
			Debug.Assert((eventDeclaration.Initializer != null));
			for (int i = 0; i < eventDeclaration.Attributes.Count; i++) {
				AttributeSection o = eventDeclaration.Attributes[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (AttributeSection)nodeStack.Pop();
				if (o == null)
					eventDeclaration.Attributes.RemoveAt(i--);
				else
					eventDeclaration.Attributes[i] = o;
			}
			for (int i = 0; i < eventDeclaration.Parameters.Count; i++) {
				ParameterDeclarationExpression o = eventDeclaration.Parameters[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (ParameterDeclarationExpression)nodeStack.Pop();
				if (o == null)
					eventDeclaration.Parameters.RemoveAt(i--);
				else
					eventDeclaration.Parameters[i] = o;
			}
			for (int i = 0; i < eventDeclaration.InterfaceImplementations.Count; i++) {
				InterfaceImplementation o = eventDeclaration.InterfaceImplementations[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (InterfaceImplementation)nodeStack.Pop();
				if (o == null)
					eventDeclaration.InterfaceImplementations.RemoveAt(i--);
				else
					eventDeclaration.InterfaceImplementations[i] = o;
			}
			nodeStack.Push(eventDeclaration.TypeReference);
			eventDeclaration.TypeReference.AcceptVisitor(this, data);
			eventDeclaration.TypeReference = ((TypeReference)(nodeStack.Pop()));
			nodeStack.Push(eventDeclaration.AddRegion);
			eventDeclaration.AddRegion.AcceptVisitor(this, data);
			eventDeclaration.AddRegion = ((EventAddRegion)(nodeStack.Pop()));
			nodeStack.Push(eventDeclaration.RemoveRegion);
			eventDeclaration.RemoveRegion.AcceptVisitor(this, data);
			eventDeclaration.RemoveRegion = ((EventRemoveRegion)(nodeStack.Pop()));
			nodeStack.Push(eventDeclaration.RaiseRegion);
			eventDeclaration.RaiseRegion.AcceptVisitor(this, data);
			eventDeclaration.RaiseRegion = ((EventRaiseRegion)(nodeStack.Pop()));
			nodeStack.Push(eventDeclaration.Initializer);
			eventDeclaration.Initializer.AcceptVisitor(this, data);
			eventDeclaration.Initializer = ((Expression)(nodeStack.Pop()));
			return null;
		}
Example #21
0
	void InterfaceMemberDecl() {

#line  1101 "cs.ATG" 
		TypeReference type;
		
		AttributeSection section;
		Modifiers mod = Modifiers.None;
		List<AttributeSection> attributes = new List<AttributeSection>();
		List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
		string name;
		PropertyGetRegion getBlock;
		PropertySetRegion setBlock;
		Location startLocation = new Location(-1, -1);
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		
		while (la.kind == 18) {
			AttributeSection(
#line  1114 "cs.ATG" 
out section);

#line  1114 "cs.ATG" 
			attributes.Add(section); 
		}
		if (la.kind == 89) {
			lexer.NextToken();

#line  1115 "cs.ATG" 
			mod = Modifiers.New; startLocation = t.Location; 
		}
		if (
#line  1118 "cs.ATG" 
NotVoidPointer()) {
			Expect(123);

#line  1118 "cs.ATG" 
			if (startLocation.IsEmpty) startLocation = t.Location; 
			Identifier();

#line  1119 "cs.ATG" 
			name = t.val; 
			if (la.kind == 23) {
				TypeParameterList(
#line  1120 "cs.ATG" 
templates);
			}
			Expect(20);
			if (StartOf(11)) {
				FormalParameterList(
#line  1121 "cs.ATG" 
parameters);
			}
			Expect(21);
			while (la.kind == 127) {
				TypeParameterConstraintsClause(
#line  1122 "cs.ATG" 
templates);
			}
			Expect(11);

#line  1124 "cs.ATG" 
			MethodDeclaration md = new MethodDeclaration {
			Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true), 
			Parameters = parameters, Attributes = attributes, Templates = templates,
			StartLocation = startLocation, EndLocation = t.EndLocation
			};
			AddChild(md);
			
		} else if (StartOf(22)) {
			if (StartOf(10)) {
				Type(
#line  1132 "cs.ATG" 
out type);

#line  1132 "cs.ATG" 
				if (startLocation.IsEmpty) startLocation = t.Location; 
				if (StartOf(18)) {
					Identifier();

#line  1134 "cs.ATG" 
					name = t.val; Location qualIdentEndLocation = t.EndLocation; 
					if (la.kind == 20 || la.kind == 23) {
						if (la.kind == 23) {
							TypeParameterList(
#line  1138 "cs.ATG" 
templates);
						}
						Expect(20);
						if (StartOf(11)) {
							FormalParameterList(
#line  1139 "cs.ATG" 
parameters);
						}
						Expect(21);
						while (la.kind == 127) {
							TypeParameterConstraintsClause(
#line  1141 "cs.ATG" 
templates);
						}
						Expect(11);

#line  1142 "cs.ATG" 
						MethodDeclaration md = new MethodDeclaration {
						Name = name, Modifier = mod, TypeReference = type,
						Parameters = parameters, Attributes = attributes, Templates = templates,
						StartLocation = startLocation, EndLocation = t.EndLocation
						};
						AddChild(md);
						
					} else if (la.kind == 16) {

#line  1151 "cs.ATG" 
						PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes);
						AddChild(pd); 
						lexer.NextToken();

#line  1154 "cs.ATG" 
						Location bodyStart = t.Location;
						InterfaceAccessors(
#line  1155 "cs.ATG" 
out getBlock, out setBlock);
						Expect(17);

#line  1156 "cs.ATG" 
						pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; 
					} else SynErr(175);
				} else if (la.kind == 111) {
					lexer.NextToken();
					Expect(18);
					FormalParameterList(
#line  1159 "cs.ATG" 
parameters);
					Expect(19);

#line  1160 "cs.ATG" 
					Location bracketEndLocation = t.EndLocation; 

#line  1161 "cs.ATG" 
					PropertyDeclaration id = new PropertyDeclaration(mod | Modifiers.Default, attributes, "Item", parameters);
					id.TypeReference = type;
					  AddChild(id); 
					Expect(16);

#line  1164 "cs.ATG" 
					Location bodyStart = t.Location;
					InterfaceAccessors(
#line  1165 "cs.ATG" 
out getBlock, out setBlock);
					Expect(17);

#line  1167 "cs.ATG" 
					id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation;  id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;
				} else SynErr(176);
			} else {
				lexer.NextToken();

#line  1170 "cs.ATG" 
				if (startLocation.IsEmpty) startLocation = t.Location; 
				Type(
#line  1171 "cs.ATG" 
out type);
				Identifier();

#line  1172 "cs.ATG" 
				EventDeclaration ed = new EventDeclaration {
				TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes
				};
				AddChild(ed);
				
				Expect(11);

#line  1178 "cs.ATG" 
				ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; 
			}
		} else SynErr(177);
	}
Example #22
0
 public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) {
     throw CreateException(eventDeclaration);
 }
Example #23
0
		public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
		{
			if (!IsClassType(ClassType.Interface) && (eventDeclaration.Modifier & Modifiers.Visibility) == 0)
				eventDeclaration.Modifier |= Modifiers.Private;
			return base.VisitEventDeclaration(eventDeclaration, data);
		}
 public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 {
     UnlockWith(eventDeclaration);
     return base.VisitEventDeclaration(eventDeclaration, data);
 }
Example #25
0
	void InterfaceMemberDecl() {

#line  634 "VBNET.ATG" 
		TypeReference type =null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		AttributeSection section, returnTypeAttributeSection = null;
		ModifierList mod = new ModifierList();
		List<AttributeSection> attributes = new List<AttributeSection>();
		string name;
		
		if (StartOf(19)) {
			while (la.kind == 28) {
				AttributeSection(
#line  642 "VBNET.ATG" 
out section);

#line  642 "VBNET.ATG" 
				attributes.Add(section); 
			}
			while (StartOf(9)) {
				MemberModifier(
#line  645 "VBNET.ATG" 
mod);
			}
			if (la.kind == 106) {
				lexer.NextToken();

#line  649 "VBNET.ATG" 
				mod.Check(Modifiers.VBInterfaceEvents);
				Location startLocation = t.Location;
				
				Identifier();

#line  652 "VBNET.ATG" 
				name = t.val; 
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  653 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
				if (la.kind == 50) {
					lexer.NextToken();
					TypeName(
#line  654 "VBNET.ATG" 
out type);
				}
				EndOfStmt();

#line  657 "VBNET.ATG" 
				EventDeclaration ed = new EventDeclaration {
				Name = name, TypeReference = type, Modifier = mod.Modifier,
				Parameters = p, Attributes = attributes,
				StartLocation = startLocation, EndLocation = t.EndLocation
				};
				compilationUnit.AddChild(ed);
				
			} else if (la.kind == 195) {
				lexer.NextToken();

#line  667 "VBNET.ATG" 
				Location startLocation =  t.Location;
				mod.Check(Modifiers.VBInterfaceMethods);
				
				Identifier();

#line  670 "VBNET.ATG" 
				name = t.val; 
				TypeParameterList(
#line  671 "VBNET.ATG" 
templates);
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  672 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
				EndOfStmt();

#line  675 "VBNET.ATG" 
				MethodDeclaration md = new MethodDeclaration {
				Name = name, 
				Modifier = mod.Modifier, 
				Parameters = p,
				Attributes = attributes,
				TypeReference = new TypeReference("System.Void", true),
				StartLocation = startLocation,
				EndLocation = t.EndLocation,
				Templates = templates
				};
				compilationUnit.AddChild(md);
				
			} else if (la.kind == 114) {
				lexer.NextToken();

#line  690 "VBNET.ATG" 
				mod.Check(Modifiers.VBInterfaceMethods);
				Location startLocation = t.Location;
				
				Identifier();

#line  693 "VBNET.ATG" 
				name = t.val; 
				TypeParameterList(
#line  694 "VBNET.ATG" 
templates);
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  695 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
				if (la.kind == 50) {
					lexer.NextToken();
					while (la.kind == 28) {
						AttributeSection(
#line  696 "VBNET.ATG" 
out returnTypeAttributeSection);
					}
					TypeName(
#line  696 "VBNET.ATG" 
out type);
				}

#line  698 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object", true);
				}
				MethodDeclaration md = new MethodDeclaration {
					Name = name, Modifier = mod.Modifier, 
					TypeReference = type, Parameters = p, Attributes = attributes
				};
				if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					md.Attributes.Add(returnTypeAttributeSection);
				}
				md.StartLocation = startLocation;
				md.EndLocation = t.EndLocation;
				md.Templates = templates;
				compilationUnit.AddChild(md);
				
				EndOfStmt();
			} else if (la.kind == 171) {
				lexer.NextToken();

#line  718 "VBNET.ATG" 
				Location startLocation = t.Location;
				mod.Check(Modifiers.VBInterfaceProperties);
				
				Identifier();

#line  721 "VBNET.ATG" 
				name = t.val;  
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  722 "VBNET.ATG" 
p);
					}
					Expect(26);
				}
				if (la.kind == 50) {
					lexer.NextToken();
					TypeName(
#line  723 "VBNET.ATG" 
out type);
				}

#line  725 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object", true);
				}
				
				EndOfStmt();

#line  731 "VBNET.ATG" 
				PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
				pd.Parameters = p;
				pd.EndLocation = t.EndLocation;
				pd.StartLocation = startLocation;
				compilationUnit.AddChild(pd);
				
			} else SynErr(245);
		} else if (StartOf(20)) {
			NonModuleDeclaration(
#line  739 "VBNET.ATG" 
mod, attributes);
		} else SynErr(246);
	}
Example #26
0
	void StructureMemberDecl(
//#line  807 "VBNET.ATG" 
ModifierList m, List<AttributeSection> attributes) {

//#line  809 "VBNET.ATG" 
		TypeReference type = null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		Statement stmt = null;
		List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		
		switch (la.kind) {
		case 84: case 103: case 115: case 142: case 155: case 209: {
			NonModuleDeclaration(
//#line  816 "VBNET.ATG" 
m, attributes);
			break;
		}
		case 210: {
			lexer.NextToken();

//#line  820 "VBNET.ATG" 
			Location startPos = t.Location;
			
			if (StartOf(4)) {

//#line  824 "VBNET.ATG" 
				string name = String.Empty;
				MethodDeclaration methodDeclaration; List<string> handlesClause = null;
				List<InterfaceImplementation> implementsClause = null;
				
				Identifier();

//#line  830 "VBNET.ATG" 
				name = t.val;
				m.Check(Modifiers.VBMethods);
				
				TypeParameterList(
//#line  833 "VBNET.ATG" 
templates);
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  834 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
				if (la.kind == 134 || la.kind == 136) {
					if (la.kind == 136) {
						ImplementsClause(
//#line  837 "VBNET.ATG" 
out implementsClause);
					} else {
						HandlesClause(
//#line  839 "VBNET.ATG" 
out handlesClause);
					}
				}

//#line  842 "VBNET.ATG" 
				Location endLocation = t.EndLocation; 
				if (
//#line  845 "VBNET.ATG" 
IsMustOverride(m)) {
					EndOfStmt();

//#line  848 "VBNET.ATG" 
					methodDeclaration = new MethodDeclaration {
					Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
					StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
					TypeReference = new TypeReference("System.Void", true),
					Templates = templates,
					HandlesClause = handlesClause,
					InterfaceImplementations = implementsClause
					};
					AddChild(methodDeclaration);
					
				} else if (la.kind == 1) {
					lexer.NextToken();

//#line  861 "VBNET.ATG" 
					methodDeclaration = new MethodDeclaration {
					Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
					StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
					TypeReference = new TypeReference("System.Void", true),
					Templates = templates,
					HandlesClause = handlesClause,
					InterfaceImplementations = implementsClause
					};
					AddChild(methodDeclaration);
					

//#line  872 "VBNET.ATG" 
					if (ParseMethodBodies) { 
					Block(
//#line  873 "VBNET.ATG" 
out stmt);
					Expect(113);
					Expect(210);

//#line  875 "VBNET.ATG" 
					} else {
					// don't parse method body
					lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
					  }
					

//#line  881 "VBNET.ATG" 
					methodDeclaration.Body  = (BlockStatement)stmt; 

//#line  882 "VBNET.ATG" 
					methodDeclaration.Body.EndLocation = t.EndLocation; 
					EndOfStmt();
				} else SynErr(256);
			} else if (la.kind == 162) {
				lexer.NextToken();
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  886 "VBNET.ATG" 
p);
					}
					Expect(38);
				}

//#line  887 "VBNET.ATG" 
				m.Check(Modifiers.Constructors); 

//#line  888 "VBNET.ATG" 
				Location constructorEndLocation = t.EndLocation; 
				Expect(1);

//#line  891 "VBNET.ATG" 
				if (ParseMethodBodies) { 
				Block(
//#line  892 "VBNET.ATG" 
out stmt);
				Expect(113);
				Expect(210);

//#line  894 "VBNET.ATG" 
				} else {
				// don't parse method body
				lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
				  }
				

//#line  900 "VBNET.ATG" 
				Location endLocation = t.EndLocation; 
				EndOfStmt();

//#line  903 "VBNET.ATG" 
				ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes);
				cd.StartLocation = m.GetDeclarationLocation(startPos);
				cd.EndLocation   = constructorEndLocation;
				cd.Body = (BlockStatement)stmt;
				cd.Body.EndLocation   = endLocation;
				AddChild(cd);
				
			} else SynErr(257);
			break;
		}
		case 127: {
			lexer.NextToken();

//#line  915 "VBNET.ATG" 
			m.Check(Modifiers.VBMethods);
			string name = String.Empty;
			Location startPos = t.Location;
			MethodDeclaration methodDeclaration;List<string> handlesClause = null;
			List<InterfaceImplementation> implementsClause = null;
			AttributeSection returnTypeAttributeSection = null;
			
			Identifier();

//#line  922 "VBNET.ATG" 
			name = t.val; 
			TypeParameterList(
//#line  923 "VBNET.ATG" 
templates);
			if (la.kind == 37) {
				lexer.NextToken();
				if (StartOf(6)) {
					FormalParameterList(
//#line  924 "VBNET.ATG" 
p);
				}
				Expect(38);
			}
			if (la.kind == 63) {
				lexer.NextToken();
				while (la.kind == 40) {
					AttributeSection(
//#line  926 "VBNET.ATG" 
out returnTypeAttributeSection);

//#line  928 "VBNET.ATG" 
					if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					attributes.Add(returnTypeAttributeSection);
					}
					
				}
				TypeName(
//#line  934 "VBNET.ATG" 
out type);
			}

//#line  936 "VBNET.ATG" 
			if(type == null) {
			type = new TypeReference("System.Object", true);
			}
			
			if (la.kind == 134 || la.kind == 136) {
				if (la.kind == 136) {
					ImplementsClause(
//#line  942 "VBNET.ATG" 
out implementsClause);
				} else {
					HandlesClause(
//#line  944 "VBNET.ATG" 
out handlesClause);
				}
			}

//#line  947 "VBNET.ATG" 
			Location endLocation = t.EndLocation; 
			if (
//#line  950 "VBNET.ATG" 
IsMustOverride(m)) {
				EndOfStmt();

//#line  953 "VBNET.ATG" 
				methodDeclaration = new MethodDeclaration {
				Name = name, Modifier = m.Modifier, TypeReference = type,
				Parameters = p, Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation   = endLocation,
				HandlesClause = handlesClause,
				Templates     = templates,
				InterfaceImplementations = implementsClause
				};
				
				AddChild(methodDeclaration);
				
			} else if (la.kind == 1) {
				lexer.NextToken();

//#line  968 "VBNET.ATG" 
				methodDeclaration = new MethodDeclaration {
				Name = name, Modifier = m.Modifier, TypeReference = type,
				Parameters = p, Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation   = endLocation,
				Templates     = templates,
				HandlesClause = handlesClause,
				InterfaceImplementations = implementsClause
				};
				
				AddChild(methodDeclaration);
				
				if (ParseMethodBodies) { 
				Block(
//#line  981 "VBNET.ATG" 
out stmt);
				Expect(113);
				Expect(127);

//#line  983 "VBNET.ATG" 
				} else {
				// don't parse method body
				lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
				}
				methodDeclaration.Body = (BlockStatement)stmt;
				methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
				methodDeclaration.Body.EndLocation   = t.EndLocation;
				
				EndOfStmt();
			} else SynErr(258);
			break;
		}
		case 101: {
			lexer.NextToken();

//#line  997 "VBNET.ATG" 
			m.Check(Modifiers.VBExternalMethods);
			Location startPos = t.Location;
			CharsetModifier charsetModifer = CharsetModifier.None;
			string library = String.Empty;
			string alias = null;
			string name = String.Empty;
			
			if (StartOf(15)) {
				Charset(
//#line  1004 "VBNET.ATG" 
out charsetModifer);
			}
			if (la.kind == 210) {
				lexer.NextToken();
				Identifier();

//#line  1007 "VBNET.ATG" 
				name = t.val; 
				Expect(149);
				Expect(3);

//#line  1008 "VBNET.ATG" 
				library = t.literalValue as string; 
				if (la.kind == 59) {
					lexer.NextToken();
					Expect(3);

//#line  1009 "VBNET.ATG" 
					alias = t.literalValue as string; 
				}
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  1010 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
				EndOfStmt();

//#line  1013 "VBNET.ATG" 
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer);
				declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
				declareDeclaration.EndLocation   = t.EndLocation;
				AddChild(declareDeclaration);
				
			} else if (la.kind == 127) {
				lexer.NextToken();
				Identifier();

//#line  1020 "VBNET.ATG" 
				name = t.val; 
				Expect(149);
				Expect(3);

//#line  1021 "VBNET.ATG" 
				library = t.literalValue as string; 
				if (la.kind == 59) {
					lexer.NextToken();
					Expect(3);

//#line  1022 "VBNET.ATG" 
					alias = t.literalValue as string; 
				}
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  1023 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					lexer.NextToken();
					TypeName(
//#line  1024 "VBNET.ATG" 
out type);
				}
				EndOfStmt();

//#line  1027 "VBNET.ATG" 
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
				declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
				declareDeclaration.EndLocation   = t.EndLocation;
				AddChild(declareDeclaration);
				
			} else SynErr(259);
			break;
		}
		case 119: {
			lexer.NextToken();

//#line  1037 "VBNET.ATG" 
			m.Check(Modifiers.VBEvents);
			Location startPos = t.Location;
			EventDeclaration eventDeclaration;
			string name = String.Empty;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

//#line  1043 "VBNET.ATG" 
			name= t.val; 
			if (la.kind == 63) {
				lexer.NextToken();
				TypeName(
//#line  1045 "VBNET.ATG" 
out type);
			} else if (StartOf(16)) {
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  1047 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
			} else SynErr(260);
			if (la.kind == 136) {
				ImplementsClause(
//#line  1049 "VBNET.ATG" 
out implementsClause);
			}

//#line  1051 "VBNET.ATG" 
			eventDeclaration = new EventDeclaration {
			Name = name, TypeReference = type, Modifier = m.Modifier, 
			Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause,
			StartLocation = m.GetDeclarationLocation(startPos),
			EndLocation = t.EndLocation
			};
			AddChild(eventDeclaration);
			
			EndOfStmt();
			break;
		}
		case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {

//#line  1062 "VBNET.ATG" 
			m.Check(Modifiers.Fields);
			FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
			
			IdentifierForFieldDeclaration();

//#line  1065 "VBNET.ATG" 
			string name = t.val; 

//#line  1066 "VBNET.ATG" 
			fd.StartLocation = m.GetDeclarationLocation(t.Location); 
			VariableDeclaratorPartAfterIdentifier(
//#line  1068 "VBNET.ATG" 
variableDeclarators, name);
			while (la.kind == 22) {
				lexer.NextToken();
				VariableDeclarator(
//#line  1069 "VBNET.ATG" 
variableDeclarators);
			}
			EndOfStmt();

//#line  1072 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			fd.Fields = variableDeclarators;
			AddChild(fd);
			
			break;
		}
		case 88: {

//#line  1077 "VBNET.ATG" 
			m.Check(Modifiers.Fields); 
			lexer.NextToken();

//#line  1078 "VBNET.ATG" 
			m.Add(Modifiers.Const, t.Location);  

//#line  1080 "VBNET.ATG" 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
			fd.StartLocation = m.GetDeclarationLocation(t.Location);
			List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>();
			
			ConstantDeclarator(
//#line  1084 "VBNET.ATG" 
constantDeclarators);
			while (la.kind == 22) {
				lexer.NextToken();
				ConstantDeclarator(
//#line  1085 "VBNET.ATG" 
constantDeclarators);
			}

//#line  1087 "VBNET.ATG" 
			fd.Fields = constantDeclarators;
			fd.EndLocation = t.Location;
			
			EndOfStmt();

//#line  1092 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			AddChild(fd);
			
			break;
		}
		case 186: {
			lexer.NextToken();

//#line  1098 "VBNET.ATG" 
			m.Check(Modifiers.VBProperties);
			Location startPos = t.Location;
			List<InterfaceImplementation> implementsClause = null;
			AttributeSection returnTypeAttributeSection = null;
			Expression initializer = null;
			
			Identifier();

//#line  1104 "VBNET.ATG" 
			string propertyName = t.val; 
			if (la.kind == 37) {
				lexer.NextToken();
				if (StartOf(6)) {
					FormalParameterList(
//#line  1105 "VBNET.ATG" 
p);
				}
				Expect(38);
			}
			if (la.kind == 63) {
				lexer.NextToken();
				while (la.kind == 40) {
					AttributeSection(
//#line  1108 "VBNET.ATG" 
out returnTypeAttributeSection);

//#line  1110 "VBNET.ATG" 
					if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					attributes.Add(returnTypeAttributeSection);
					}
					
				}
				if (
//#line  1117 "VBNET.ATG" 
IsNewExpression()) {
					ObjectCreateExpression(
//#line  1117 "VBNET.ATG" 
out initializer);

//#line  1119 "VBNET.ATG" 
					if (initializer is ObjectCreateExpression) {
					type = ((ObjectCreateExpression)initializer).CreateType.Clone();
					} else {
						type = ((ArrayCreateExpression)initializer).CreateType.Clone();
					}
					
				} else if (StartOf(8)) {
					TypeName(
//#line  1126 "VBNET.ATG" 
out type);
				} else SynErr(261);
			}
			if (la.kind == 20) {
				lexer.NextToken();
				Expr(
//#line  1129 "VBNET.ATG" 
out initializer);
			}
			if (la.kind == 136) {
				ImplementsClause(
//#line  1130 "VBNET.ATG" 
out implementsClause);
			}
			EndOfStmt();
			if (
//#line  1134 "VBNET.ATG" 
IsMustOverride(m) || IsAutomaticProperty()) {

//#line  1136 "VBNET.ATG" 
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				pDecl.StartLocation = m.GetDeclarationLocation(startPos);
				pDecl.EndLocation   = t.Location;
				pDecl.TypeReference = type;
				pDecl.InterfaceImplementations = implementsClause;
				pDecl.Parameters = p;
				if (initializer != null)
					pDecl.Initializer = initializer;
				AddChild(pDecl);
				
			} else if (StartOf(17)) {

//#line  1148 "VBNET.ATG" 
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				pDecl.StartLocation = m.GetDeclarationLocation(startPos);
				pDecl.EndLocation   = t.Location;
				pDecl.BodyStart   = t.Location;
				pDecl.TypeReference = type;
				pDecl.InterfaceImplementations = implementsClause;
				pDecl.Parameters = p;
				PropertyGetRegion getRegion;
				PropertySetRegion setRegion;
				
				AccessorDecls(
//#line  1158 "VBNET.ATG" 
out getRegion, out setRegion);
				Expect(113);
				Expect(186);
				EndOfStmt();

//#line  1162 "VBNET.ATG" 
				pDecl.GetRegion = getRegion;
				pDecl.SetRegion = setRegion;
				pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property"
				AddChild(pDecl);
				
			} else SynErr(262);
			break;
		}
		case 98: {
			lexer.NextToken();

//#line  1169 "VBNET.ATG" 
			Location startPos = t.Location; 
			Expect(119);

//#line  1171 "VBNET.ATG" 
			m.Check(Modifiers.VBCustomEvents);
			EventAddRemoveRegion eventAccessorDeclaration;
			EventAddRegion addHandlerAccessorDeclaration = null;
			EventRemoveRegion removeHandlerAccessorDeclaration = null;
			EventRaiseRegion raiseEventAccessorDeclaration = null;
			List<InterfaceImplementation> implementsClause = null;
			
			Identifier();

//#line  1178 "VBNET.ATG" 
			string customEventName = t.val; 
			Expect(63);
			TypeName(
//#line  1179 "VBNET.ATG" 
out type);
			if (la.kind == 136) {
				ImplementsClause(
//#line  1180 "VBNET.ATG" 
out implementsClause);
			}
			EndOfStmt();
			while (StartOf(18)) {
				EventAccessorDeclaration(
//#line  1183 "VBNET.ATG" 
out eventAccessorDeclaration);

//#line  1185 "VBNET.ATG" 
				if(eventAccessorDeclaration is EventAddRegion)
				{
					addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
				}
				else if(eventAccessorDeclaration is EventRemoveRegion)
				{
					removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
				}
				else if(eventAccessorDeclaration is EventRaiseRegion)
				{
					raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
				}
				
			}
			Expect(113);
			Expect(119);
			EndOfStmt();

//#line  1201 "VBNET.ATG" 
			if(addHandlerAccessorDeclaration == null)
			{
				Error("Need to provide AddHandler accessor.");
			}
			
			if(removeHandlerAccessorDeclaration == null)
			{
				Error("Need to provide RemoveHandler accessor.");
			}
			
			if(raiseEventAccessorDeclaration == null)
			{
				Error("Need to provide RaiseEvent accessor.");
			}
			
			EventDeclaration decl = new EventDeclaration {
				TypeReference = type, Name = customEventName, Modifier = m.Modifier,
				Attributes = attributes,
				StartLocation = m.GetDeclarationLocation(startPos),
				EndLocation = t.EndLocation,
				AddRegion = addHandlerAccessorDeclaration,
				RemoveRegion = removeHandlerAccessorDeclaration,
				RaiseRegion = raiseEventAccessorDeclaration
			};
			AddChild(decl);
			
			break;
		}
		case 161: case 172: case 232: {

//#line  1227 "VBNET.ATG" 
			ConversionType opConversionType = ConversionType.None; 
			if (la.kind == 161 || la.kind == 232) {
				if (la.kind == 232) {
					lexer.NextToken();

//#line  1228 "VBNET.ATG" 
					opConversionType = ConversionType.Implicit; 
				} else {
					lexer.NextToken();

//#line  1229 "VBNET.ATG" 
					opConversionType = ConversionType.Explicit;
				}
			}
			Expect(172);

//#line  1232 "VBNET.ATG" 
			m.Check(Modifiers.VBOperators);
			Location startPos = t.Location;
			TypeReference returnType = NullTypeReference.Instance;
			TypeReference operandType = NullTypeReference.Instance;
			OverloadableOperatorType operatorType;
			AttributeSection section;
			ParameterDeclarationExpression param;
			List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
			
			OverloadableOperator(
//#line  1241 "VBNET.ATG" 
out operatorType);
			Expect(37);
			FormalParameter(
//#line  1243 "VBNET.ATG" 
out param);

//#line  1244 "VBNET.ATG" 
			if (param != null) parameters.Add(param); 
			if (la.kind == 22) {
				lexer.NextToken();
				FormalParameter(
//#line  1246 "VBNET.ATG" 
out param);

//#line  1247 "VBNET.ATG" 
				if (param != null) parameters.Add(param); 
			}
			Expect(38);

//#line  1250 "VBNET.ATG" 
			Location endPos = t.EndLocation; 
			if (la.kind == 63) {
				lexer.NextToken();
				while (la.kind == 40) {
					AttributeSection(
//#line  1251 "VBNET.ATG" 
out section);

//#line  1252 "VBNET.ATG" 
					if (section != null) {
					section.AttributeTarget = "return";
					attributes.Add(section);
					} 
				}
				TypeName(
//#line  1256 "VBNET.ATG" 
out returnType);

//#line  1256 "VBNET.ATG" 
				endPos = t.EndLocation; 
			}
			Expect(1);
			Block(
//#line  1258 "VBNET.ATG" 
out stmt);
			Expect(113);
			Expect(172);
			EndOfStmt();

//#line  1260 "VBNET.ATG" 
			OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
			Modifier = m.Modifier,
			Attributes = attributes,
			Parameters = parameters,
			TypeReference = returnType,
			OverloadableOperator = operatorType,
			ConversionType = opConversionType,
			Body = (BlockStatement)stmt,
			StartLocation = m.GetDeclarationLocation(startPos),
			EndLocation = endPos
			};
			operatorDeclaration.Body.StartLocation = startPos;
			operatorDeclaration.Body.EndLocation = t.Location;
			AddChild(operatorDeclaration);
			
			break;
		}
		default: SynErr(263); break;
		}
	}
		public virtual object TrackedVisitEventDeclaration(EventDeclaration eventDeclaration, object data) {
			return base.VisitEventDeclaration(eventDeclaration, data);
		}
Example #28
0
		public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
		{
			return base.VisitEventDeclaration(eventDeclaration, data);
		}
 public override object TrackedVisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 {
     Console.WriteLine("VisitEventDeclaration");
     return null;
 }
		public override object VisitEventDeclaration (EventDeclaration eventDeclaration, object data)
		{
			if (!MemberLocation.IsEmpty && eventDeclaration.StartLocation.Line != MemberLocation.Line)
				return null;
			return base.VisitEventDeclaration (eventDeclaration, data);
		}
Example #31
0
	void InterfaceMemberDecl() {

//#line  665 "VBNET.ATG" 
		TypeReference type =null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		AttributeSection section, returnTypeAttributeSection = null;
		ModifierList mod = new ModifierList();
		List<AttributeSection> attributes = new List<AttributeSection>();
		string name;
		
		if (StartOf(19)) {
			while (la.kind == 40) {
				AttributeSection(
//#line  673 "VBNET.ATG" 
out section);

//#line  673 "VBNET.ATG" 
				attributes.Add(section); 
			}
			while (StartOf(10)) {
				MemberModifier(
//#line  676 "VBNET.ATG" 
mod);
			}
			if (la.kind == 119) {
				lexer.NextToken();

//#line  680 "VBNET.ATG" 
				mod.Check(Modifiers.VBInterfaceEvents);
				Location startLocation = t.Location;
				
				Identifier();

//#line  683 "VBNET.ATG" 
				name = t.val; 
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  684 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					lexer.NextToken();
					TypeName(
//#line  685 "VBNET.ATG" 
out type);
				}
				EndOfStmt();

//#line  688 "VBNET.ATG" 
				EventDeclaration ed = new EventDeclaration {
				Name = name, TypeReference = type, Modifier = mod.Modifier,
				Parameters = p, Attributes = attributes,
				StartLocation = startLocation, EndLocation = t.EndLocation
				};
				AddChild(ed);
				
			} else if (la.kind == 210) {
				lexer.NextToken();

//#line  698 "VBNET.ATG" 
				Location startLocation =  t.Location;
				mod.Check(Modifiers.VBInterfaceMethods);
				
				Identifier();

//#line  701 "VBNET.ATG" 
				name = t.val; 
				TypeParameterList(
//#line  702 "VBNET.ATG" 
templates);
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  703 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
				EndOfStmt();

//#line  706 "VBNET.ATG" 
				MethodDeclaration md = new MethodDeclaration {
				Name = name, 
				Modifier = mod.Modifier, 
				Parameters = p,
				Attributes = attributes,
				TypeReference = new TypeReference("System.Void", true),
				StartLocation = startLocation,
				EndLocation = t.EndLocation,
				Templates = templates
				};
				AddChild(md);
				
			} else if (la.kind == 127) {
				lexer.NextToken();

//#line  721 "VBNET.ATG" 
				mod.Check(Modifiers.VBInterfaceMethods);
				Location startLocation = t.Location;
				
				Identifier();

//#line  724 "VBNET.ATG" 
				name = t.val; 
				TypeParameterList(
//#line  725 "VBNET.ATG" 
templates);
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  726 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					lexer.NextToken();
					while (la.kind == 40) {
						AttributeSection(
//#line  727 "VBNET.ATG" 
out returnTypeAttributeSection);
					}
					TypeName(
//#line  727 "VBNET.ATG" 
out type);
				}

//#line  729 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object", true);
				}
				MethodDeclaration md = new MethodDeclaration {
					Name = name, Modifier = mod.Modifier, 
					TypeReference = type, Parameters = p, Attributes = attributes
				};
				if (returnTypeAttributeSection != null) {
					returnTypeAttributeSection.AttributeTarget = "return";
					md.Attributes.Add(returnTypeAttributeSection);
				}
				md.StartLocation = startLocation;
				md.EndLocation = t.EndLocation;
				md.Templates = templates;
				AddChild(md);
				
				EndOfStmt();
			} else if (la.kind == 186) {
				lexer.NextToken();

//#line  749 "VBNET.ATG" 
				Location startLocation = t.Location;
				mod.Check(Modifiers.VBInterfaceProperties);
				
				Identifier();

//#line  752 "VBNET.ATG" 
				name = t.val;  
				if (la.kind == 37) {
					lexer.NextToken();
					if (StartOf(6)) {
						FormalParameterList(
//#line  753 "VBNET.ATG" 
p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					lexer.NextToken();
					TypeName(
//#line  754 "VBNET.ATG" 
out type);
				}

//#line  756 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object", true);
				}
				
				EndOfStmt();

//#line  762 "VBNET.ATG" 
				PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
				pd.Parameters = p;
				pd.EndLocation = t.EndLocation;
				pd.StartLocation = startLocation;
				AddChild(pd);
				
			} else SynErr(264);
		} else if (StartOf(20)) {
			NonModuleDeclaration(
//#line  770 "VBNET.ATG" 
mod, attributes);
		} else SynErr(265);
	}
Example #32
0
        // RG
        public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
        {
            CodeMemberEvent evt = new CodeMemberEvent();
            evt.Type = ConvType(eventDeclaration.TypeReference);
            evt.Name = eventDeclaration.Name;

            evt.Attributes = ConvMemberAttributes(eventDeclaration.Modifier);

            typeDeclarations.Peek().Members.Add(evt);

            return null;
        }