예제 #1
0
		public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
		{
			Push();
			object result = base.VisitPropertyDeclaration(propertyDeclaration, data);
			Pop();
			return result;
		}
예제 #2
0
		public virtual object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) {
			Debug.Assert((propertyDeclaration != null));
			Debug.Assert((propertyDeclaration.Attributes != null));
			Debug.Assert((propertyDeclaration.Parameters != null));
			Debug.Assert((propertyDeclaration.InterfaceImplementations != null));
			Debug.Assert((propertyDeclaration.TypeReference != null));
			Debug.Assert((propertyDeclaration.GetRegion != null));
			Debug.Assert((propertyDeclaration.SetRegion != null));
			foreach (AttributeSection o in propertyDeclaration.Attributes) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			foreach (ParameterDeclarationExpression o in propertyDeclaration.Parameters) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			foreach (InterfaceImplementation o in propertyDeclaration.InterfaceImplementations) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			propertyDeclaration.TypeReference.AcceptVisitor(this, data);
			propertyDeclaration.GetRegion.AcceptVisitor(this, data);
			return propertyDeclaration.SetRegion.AcceptVisitor(this, data);
		}
		void ConvertInterfaceImplementation(PropertyDeclaration member)
		{
			// members without modifiers are already C# explicit interface implementations, do not convert them
			if (member.Modifier == Modifiers.None)
				return;
			while (member.InterfaceImplementations.Count > 0) {
				InterfaceImplementation impl = member.InterfaceImplementations[0];
				member.InterfaceImplementations.RemoveAt(0);
				if (member.Name != impl.MemberName) {
					PropertyDeclaration newMember = new PropertyDeclaration(Modifiers.None, null, impl.MemberName, null);
					newMember.TypeReference = member.TypeReference;
					if (member.HasGetRegion) {
						newMember.GetRegion = new PropertyGetRegion(new BlockStatement(), null);
						newMember.GetRegion.Block.AddChild(new ReturnStatement(new IdentifierExpression(member.Name)));
					}
					if (member.HasSetRegion) {
						newMember.SetRegion = new PropertySetRegion(new BlockStatement(), null);
						newMember.SetRegion.Block.AddChild(new ExpressionStatement(
							new AssignmentExpression(
								new IdentifierExpression(member.Name),
								AssignmentOperatorType.Assign,
								new IdentifierExpression("value")
							)));
					}
					newMember.Parameters = member.Parameters;
					newMember.InterfaceImplementations.Add(impl);
					InsertAfterSibling(member, newMember);
				}
			}
		}
		public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
		{
			ConvertInterfaceImplementation(propertyDeclaration);
			return base.VisitPropertyDeclaration(propertyDeclaration, data);
		}
예제 #5
0
	void InterfaceMemberDecl() {

#line  1093 "Frames/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  1106 "Frames/cs.ATG" 
out section);

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

#line  1107 "Frames/cs.ATG" 
			mod = Modifiers.New; startLocation = t.Location; 
		}
		if (
#line  1110 "Frames/cs.ATG" 
NotVoidPointer()) {
			Expect(123);

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

#line  1111 "Frames/cs.ATG" 
			name = t.val; 
			if (la.kind == 23) {
				TypeParameterList(
#line  1112 "Frames/cs.ATG" 
templates);
			}
			Expect(20);
			if (StartOf(11)) {
				FormalParameterList(
#line  1113 "Frames/cs.ATG" 
parameters);
			}
			Expect(21);
			while (la.kind == 127) {
				TypeParameterConstraintsClause(
#line  1114 "Frames/cs.ATG" 
templates);
			}
			Expect(11);

#line  1116 "Frames/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
			};
			compilationUnit.AddChild(md);
			
		} else if (StartOf(23)) {
			if (StartOf(10)) {
				Type(
#line  1124 "Frames/cs.ATG" 
out type);

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

#line  1126 "Frames/cs.ATG" 
					name = t.val; Location qualIdentEndLocation = t.EndLocation; 
					if (la.kind == 20 || la.kind == 23) {
						if (la.kind == 23) {
							TypeParameterList(
#line  1130 "Frames/cs.ATG" 
templates);
						}
						Expect(20);
						if (StartOf(11)) {
							FormalParameterList(
#line  1131 "Frames/cs.ATG" 
parameters);
						}
						Expect(21);
						while (la.kind == 127) {
							TypeParameterConstraintsClause(
#line  1133 "Frames/cs.ATG" 
templates);
						}
						Expect(11);

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

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

#line  1146 "Frames/cs.ATG" 
						Location bodyStart = t.Location;
						InterfaceAccessors(
#line  1147 "Frames/cs.ATG" 
out getBlock, out setBlock);
						Expect(17);

#line  1148 "Frames/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  1151 "Frames/cs.ATG" 
parameters);
					Expect(19);

#line  1152 "Frames/cs.ATG" 
					Location bracketEndLocation = t.EndLocation; 

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

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

#line  1158 "Frames/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  1161 "Frames/cs.ATG" 
				if (startLocation.IsEmpty) startLocation = t.Location; 
				Type(
#line  1162 "Frames/cs.ATG" 
out type);
				Identifier();

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

#line  1169 "Frames/cs.ATG" 
				ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; 
			}
		} else SynErr(177);
	}
예제 #6
0
	void StructMemberDecl(
#line  753 "Frames/cs.ATG" 
ModifierList m, List<AttributeSection> attributes) {

#line  755 "Frames/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  765 "Frames/cs.ATG" 
			m.Check(Modifiers.Constants); 
			lexer.NextToken();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#line  826 "Frames/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  836 "Frames/cs.ATG" 
out type);

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

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

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

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

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

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

#line  846 "Frames/cs.ATG" 
				eventDecl.BodyStart = t.Location; 
				EventAccessorDecls(
#line  847 "Frames/cs.ATG" 
out addBlock, out removeBlock);
				Expect(17);

#line  848 "Frames/cs.ATG" 
				eventDecl.BodyEnd   = t.EndLocation; 
			}

#line  850 "Frames/cs.ATG" 
			compilationUnit.BlockEnd();
			eventDecl.AddRegion = addBlock;
			eventDecl.RemoveRegion = removeBlock;
			
			while (la.kind == 14) {
				lexer.NextToken();
				Identifier();

#line  854 "Frames/cs.ATG" 
				EventDeclaration additionalEventDeclaration = new EventDeclaration {
				    Modifier = eventDecl.Modifier, 
				    Attributes = eventDecl.Attributes,
				    StartLocation = eventDecl.StartLocation,
				    TypeReference = eventDecl.TypeReference,
				    Name = t.val
				};
				compilationUnit.AddChild (additionalEventDeclaration);
				
			}
			if (la.kind == 11) {
				lexer.NextToken();
			}
		} else if (
#line  868 "Frames/cs.ATG" 
IdentAndLPar()) {

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

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

#line  869 "Frames/cs.ATG" 
				m.Check(Modifiers.Constructors); 
				FormalParameterList(
#line  870 "Frames/cs.ATG" 
p);
			}
			Expect(21);

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

#line  873 "Frames/cs.ATG" 
				m.Check(Modifiers.Constructors); 
				ConstructorInitializer(
#line  874 "Frames/cs.ATG" 
out init);
			}

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

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

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

#line  889 "Frames/cs.ATG" 
				isImplicit = false; startPos = t.Location; 
			}
			Expect(92);
			Type(
#line  890 "Frames/cs.ATG" 
out type);

#line  890 "Frames/cs.ATG" 
			TypeReference operatorType = type; 
			Expect(20);
			Type(
#line  891 "Frames/cs.ATG" 
out type);
			Identifier();

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

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

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

#line  896 "Frames/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
			};
			compilationUnit.AddChild(operatorDeclaration);
			
		} else if (StartOf(22)) {
			TypeDecl(
#line  914 "Frames/cs.ATG" 
m, attributes);
		} else if (StartOf(10)) {
			Type(
#line  916 "Frames/cs.ATG" 
out type);

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

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

#line  922 "Frames/cs.ATG" 
				TypeReference firstType, secondType = null; string secondName = null; 
				Expect(20);
				Type(
#line  923 "Frames/cs.ATG" 
out firstType);
				Identifier();

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

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

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

#line  935 "Frames/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));
				if (secondType != null) {
					SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName));
				}
				compilationUnit.AddChild(operatorDeclaration);
				
			} else if (
#line  957 "Frames/cs.ATG" 
IsVarDecl()) {

#line  958 "Frames/cs.ATG" 
				m.Check(Modifiers.Fields);
				FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
				fd.StartLocation = m.GetDeclarationLocation(startPos); 
				
				if (
#line  962 "Frames/cs.ATG" 
m.Contains(Modifiers.Fixed)) {
					VariableDeclarator(
#line  963 "Frames/cs.ATG" 
fd);
					Expect(18);
					Expr(
#line  965 "Frames/cs.ATG" 
out expr);

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

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

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

#line  982 "Frames/cs.ATG" 
				m.Check(Modifiers.Indexers); 
				lexer.NextToken();
				Expect(18);
				FormalParameterList(
#line  983 "Frames/cs.ATG" 
p);
				Expect(19);

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

#line  984 "Frames/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  991 "Frames/cs.ATG" 
out getRegion, out setRegion);
				Expect(17);

#line  992 "Frames/cs.ATG" 
				indexer.BodyEnd    = t.EndLocation;
				indexer.GetRegion = getRegion;
				indexer.SetRegion = setRegion;
				compilationUnit.AddChild(indexer);
				
			} else if (
#line  997 "Frames/cs.ATG" 
IsIdentifierToken(la)) {
				if (
#line  998 "Frames/cs.ATG" 
IsExplicitInterfaceImplementation()) {
					TypeName(
#line  999 "Frames/cs.ATG" 
out explicitInterface, false);

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

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

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

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

#line  1013 "Frames/cs.ATG" 
							isExtensionMethod = true; 
						}
						if (StartOf(11)) {
							FormalParameterList(
#line  1014 "Frames/cs.ATG" 
p);
						}
						Expect(21);

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

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

#line  1035 "Frames/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  1044 "Frames/cs.ATG" 
out getRegion, out setRegion);
						Expect(17);

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

#line  1054 "Frames/cs.ATG" 
					m.Check(Modifiers.Indexers); 
					lexer.NextToken();
					Expect(111);
					Expect(18);
					FormalParameterList(
#line  1055 "Frames/cs.ATG" 
p);
					Expect(19);

#line  1056 "Frames/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  1064 "Frames/cs.ATG" 
					Location bodyStart = t.Location; 
					AccessorDecls(
#line  1065 "Frames/cs.ATG" 
out getRegion, out setRegion);
					Expect(17);

#line  1066 "Frames/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 VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) {
			this.BeginVisit(propertyDeclaration);
			object result = this.TrackedVisitPropertyDeclaration(propertyDeclaration, data);
			this.EndVisit(propertyDeclaration);
			return result;
		}
		public virtual object TrackedVisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) {
			return base.VisitPropertyDeclaration(propertyDeclaration, data);
		}
		public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
		{
			if (!IsClassType(ClassType.Interface) && (propertyDeclaration.Modifier & Modifiers.Visibility) == 0)
				propertyDeclaration.Modifier |= Modifiers.Public;
			
			if (propertyDeclaration.HasSetRegion) {
				string from = "Value";
				if (propertyDeclaration.SetRegion.Parameters.Count > 0) {
					ParameterDeclarationExpression p = propertyDeclaration.SetRegion.Parameters[0];
					from = p.ParameterName;
					p.ParameterName = "Value";
				}
				propertyDeclaration.SetRegion.AcceptVisitor(new RenameIdentifierVisitor(from, "value", StringComparer.InvariantCultureIgnoreCase), null);
			}
			
			return base.VisitPropertyDeclaration(propertyDeclaration, data);
		}
예제 #10
0
		public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
		{
			if (!IsClassType(ClassType.Interface) && (propertyDeclaration.Modifier & Modifiers.Visibility) == 0)
				propertyDeclaration.Modifier |= Modifiers.Private;
			base.VisitPropertyDeclaration(propertyDeclaration, data);
			
			ToVBNetRenameConflictingVariablesVisitor.RenameConflicting(propertyDeclaration);
			
			if (!IsClassType(ClassType.Interface) && (propertyDeclaration.Modifier & Modifiers.Abstract) == 0) {
				if (propertyDeclaration.HasGetRegion && propertyDeclaration.HasSetRegion) {
					if (propertyDeclaration.GetRegion.Block.IsNull && propertyDeclaration.SetRegion.Block.IsNull) {
						// automatically implemented property
						string fieldName = "m_" + propertyDeclaration.Name;
						Modifiers fieldModifier = propertyDeclaration.Modifier & ~(Modifiers.Visibility) | Modifiers.Private;
						FieldDeclaration newField = new FieldDeclaration(null, propertyDeclaration.TypeReference, fieldModifier);
						newField.Fields.Add(new VariableDeclaration(fieldName));
						InsertAfterSibling(propertyDeclaration, newField);
						
						propertyDeclaration.GetRegion.Block = new BlockStatement();
						propertyDeclaration.GetRegion.Block.Return(ExpressionBuilder.Identifier(fieldName));
						propertyDeclaration.SetRegion.Block = new BlockStatement();
						propertyDeclaration.SetRegion.Block.Assign(ExpressionBuilder.Identifier(fieldName), ExpressionBuilder.Identifier("Value"));
						
					}
				}
			}
			
			return null;
		}
예제 #11
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);
	}
예제 #12
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 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(17)) {

#line  1091 "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  1101 "VBNET.ATG" 
out getRegion, out setRegion);
				Expect(100);
				Expect(171);
				EndOfStmt();

#line  1105 "VBNET.ATG" 
				pDecl.GetRegion = getRegion;
				pDecl.SetRegion = setRegion;
				pDecl.BodyEnd = t.EndLocation;
				compilationUnit.AddChild(pDecl);
				
			} 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 virtual object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) {
			Debug.Assert((propertyDeclaration != null));
			Debug.Assert((propertyDeclaration.Attributes != null));
			Debug.Assert((propertyDeclaration.Parameters != null));
			Debug.Assert((propertyDeclaration.InterfaceImplementations != null));
			Debug.Assert((propertyDeclaration.TypeReference != null));
			Debug.Assert((propertyDeclaration.GetRegion != null));
			Debug.Assert((propertyDeclaration.SetRegion != null));
			for (int i = 0; i < propertyDeclaration.Attributes.Count; i++) {
				AttributeSection o = propertyDeclaration.Attributes[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (AttributeSection)nodeStack.Pop();
				if (o == null)
					propertyDeclaration.Attributes.RemoveAt(i--);
				else
					propertyDeclaration.Attributes[i] = o;
			}
			for (int i = 0; i < propertyDeclaration.Parameters.Count; i++) {
				ParameterDeclarationExpression o = propertyDeclaration.Parameters[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (ParameterDeclarationExpression)nodeStack.Pop();
				if (o == null)
					propertyDeclaration.Parameters.RemoveAt(i--);
				else
					propertyDeclaration.Parameters[i] = o;
			}
			for (int i = 0; i < propertyDeclaration.InterfaceImplementations.Count; i++) {
				InterfaceImplementation o = propertyDeclaration.InterfaceImplementations[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (InterfaceImplementation)nodeStack.Pop();
				if (o == null)
					propertyDeclaration.InterfaceImplementations.RemoveAt(i--);
				else
					propertyDeclaration.InterfaceImplementations[i] = o;
			}
			nodeStack.Push(propertyDeclaration.TypeReference);
			propertyDeclaration.TypeReference.AcceptVisitor(this, data);
			propertyDeclaration.TypeReference = ((TypeReference)(nodeStack.Pop()));
			nodeStack.Push(propertyDeclaration.GetRegion);
			propertyDeclaration.GetRegion.AcceptVisitor(this, data);
			propertyDeclaration.GetRegion = ((PropertyGetRegion)(nodeStack.Pop()));
			nodeStack.Push(propertyDeclaration.SetRegion);
			propertyDeclaration.SetRegion.AcceptVisitor(this, data);
			propertyDeclaration.SetRegion = ((PropertySetRegion)(nodeStack.Pop()));
			return null;
		}
		public virtual object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) {
			throw new global::System.NotImplementedException("PropertyDeclaration");
		}
예제 #15
0
		// RG
		public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
		{
			CodeMemberProperty memberProperty = new CodeMemberProperty();
			memberProperty.Name = propertyDeclaration.Name;
			memberProperty.Attributes = ConvMemberAttributes(propertyDeclaration.Modifier);
			memberProperty.HasGet = propertyDeclaration.HasGetRegion;
			memberProperty.HasSet = propertyDeclaration.HasSetRegion;
			memberProperty.Type = ConvType(propertyDeclaration.TypeReference);

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

			// Add Method Parameters
			foreach (ParameterDeclarationExpression parameter in propertyDeclaration.Parameters)
			{
				memberProperty.Parameters.Add((CodeParameterDeclarationExpression)VisitParameterDeclarationExpression(parameter, data));
			}

			if (memberProperty.HasGet)
			{
				codeStack.Push(memberProperty.GetStatements);
				propertyDeclaration.GetRegion.Block.AcceptChildren(this, data);
				codeStack.Pop();
			}

			if (memberProperty.HasSet)
			{
				codeStack.Push(memberProperty.SetStatements);
				propertyDeclaration.SetRegion.Block.AcceptChildren(this, data);
				codeStack.Pop();
			}

			return null;
		}