public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
		{
			if (nameComparer.Equals(from, variableDeclaration.Name)) {
				variableDeclaration.Name = to;
			}
			return base.VisitVariableDeclaration(variableDeclaration, data);
		}
예제 #2
0
        public override object VisitVariableDeclaration(ICSharpCode.OldNRefactory.Ast.VariableDeclaration variableDeclaration, object data)
        {
            if (variablesToGenerate.Any(v => v.Name == variableDeclaration.Name))
            {
                RemoveCurrentNode();
                if (variableDeclaration.Initializer != null && !variableDeclaration.Initializer.IsNull)
                {
                    //	BlockStatement block = blocks.Peek ();
                    curStatementList.Peek().Add(new ExpressionStatement(new AssignmentExpression(new IdentifierExpression(variableDeclaration.Name), AssignmentOperatorType.Assign, variableDeclaration.Initializer)));
                }

                return(null);
            }

            return(base.VisitVariableDeclaration(variableDeclaration, data));
        }
예제 #3
0
	void LocalVariableDeclarator(
#line  1492 "Frames/cs.ATG" 
out VariableDeclaration var) {

#line  1493 "Frames/cs.ATG" 
		Expression expr = null; 
		Identifier();

#line  1495 "Frames/cs.ATG" 
		var = new VariableDeclaration(t.val); var.StartLocation = t.Location; 
		if (la.kind == 3) {
			lexer.NextToken();
			VariableInitializer(
#line  1496 "Frames/cs.ATG" 
out expr);

#line  1496 "Frames/cs.ATG" 
			var.Initializer = expr; 
		}

#line  1497 "Frames/cs.ATG" 
		var.EndLocation = t.EndLocation; 
	}
예제 #4
0
	void VariableDeclarator(
#line  1301 "Frames/cs.ATG" 
FieldDeclaration parentFieldDeclaration) {

#line  1302 "Frames/cs.ATG" 
		Expression expr = null; 
		Identifier();

#line  1304 "Frames/cs.ATG" 
		VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location; 
		if (la.kind == 3) {
			lexer.NextToken();
			VariableInitializer(
#line  1305 "Frames/cs.ATG" 
out expr);

#line  1305 "Frames/cs.ATG" 
			f.Initializer = expr; 
		}

#line  1306 "Frames/cs.ATG" 
		f.EndLocation = t.EndLocation; SafeAdd(parentFieldDeclaration, parentFieldDeclaration.Fields, f); 
	}
예제 #5
0
	void EnumMemberDecl(
#line  1174 "Frames/cs.ATG" 
out FieldDeclaration f) {

#line  1176 "Frames/cs.ATG" 
		Expression expr = null;
		List<AttributeSection> attributes = new List<AttributeSection>();
		AttributeSection section = null;
		VariableDeclaration varDecl = null;
		
		while (la.kind == 18) {
			AttributeSection(
#line  1182 "Frames/cs.ATG" 
out section);

#line  1182 "Frames/cs.ATG" 
			attributes.Add(section); 
		}
		Identifier();

#line  1183 "Frames/cs.ATG" 
		f = new FieldDeclaration(attributes);
		varDecl         = new VariableDeclaration(t.val);
		f.Fields.Add(varDecl);
		f.StartLocation = t.Location;
		f.EndLocation = t.EndLocation;
		
		if (la.kind == 3) {
			lexer.NextToken();
			Expr(
#line  1189 "Frames/cs.ATG" 
out expr);

#line  1189 "Frames/cs.ATG" 
			varDecl.Initializer = expr; 
		}
	}
예제 #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 VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			this.BeginVisit(variableDeclaration);
			object result = this.TrackedVisitVariableDeclaration(variableDeclaration, data);
			this.EndVisit(variableDeclaration);
			return result;
		}
		public LocalVariableDeclaration(VariableDeclaration declaration) : this(TypeReference.Null)
		{
			Variables.Add(declaration);
		}
예제 #9
0
	void ConstantDeclarator(
#line  1381 "VBNET.ATG" 
List<VariableDeclaration> constantDeclaration) {

#line  1383 "VBNET.ATG" 
		Expression expr = null;
		TypeReference type = null;
		string name = String.Empty;
		Location location;
		
		Identifier();

#line  1388 "VBNET.ATG" 
		name = t.val; location = t.Location; 
		if (la.kind == 50) {
			lexer.NextToken();
			TypeName(
#line  1389 "VBNET.ATG" 
out type);
		}
		Expect(10);
		Expr(
#line  1390 "VBNET.ATG" 
out expr);

#line  1392 "VBNET.ATG" 
		VariableDeclaration f = new VariableDeclaration(name, expr);
		f.TypeReference = type;
		f.StartLocation = location;
		constantDeclaration.Add(f);
		
	}
예제 #10
0
	void VariableDeclaratorPartAfterIdentifier(
#line  1406 "VBNET.ATG" 
List<VariableDeclaration> fieldDeclaration, string name) {

#line  1408 "VBNET.ATG" 
		Expression expr = null;
		TypeReference type = null;
		ArrayList rank = null;
		List<Expression> dimension = null;
		Location startLocation = t.Location;
		
		if (
#line  1414 "VBNET.ATG" 
IsSize() && !IsDims()) {
			ArrayInitializationModifier(
#line  1414 "VBNET.ATG" 
out dimension);
		}
		if (
#line  1415 "VBNET.ATG" 
IsDims()) {
			ArrayNameModifier(
#line  1415 "VBNET.ATG" 
out rank);
		}
		if (
#line  1417 "VBNET.ATG" 
IsObjectCreation()) {
			Expect(50);
			ObjectCreateExpression(
#line  1417 "VBNET.ATG" 
out expr);

#line  1419 "VBNET.ATG" 
			if (expr is ObjectCreateExpression) {
			type = ((ObjectCreateExpression)expr).CreateType.Clone();
			} else {
				type = ((ArrayCreateExpression)expr).CreateType.Clone();
			}
			
		} else if (StartOf(23)) {
			if (la.kind == 50) {
				lexer.NextToken();
				TypeName(
#line  1426 "VBNET.ATG" 
out type);

#line  1428 "VBNET.ATG" 
				if (type != null) {
				for (int i = fieldDeclaration.Count - 1; i >= 0; i--) {
					VariableDeclaration vd = fieldDeclaration[i];
					if (vd.TypeReference.Type.Length > 0) break;
					TypeReference newType = type.Clone();
					newType.RankSpecifier = vd.TypeReference.RankSpecifier;
					vd.TypeReference = newType;
				}
				}
				 
			}

#line  1440 "VBNET.ATG" 
			if (type == null && (dimension != null || rank != null)) {
			type = new TypeReference("");
			}
			if (dimension != null) {
				if(type.RankSpecifier != null) {
					Error("array rank only allowed one time");
				} else {
					if (rank == null) {
						type.RankSpecifier = new int[] { dimension.Count - 1 };
					} else {
						rank.Insert(0, dimension.Count - 1);
						type.RankSpecifier = (int[])rank.ToArray(typeof(int));
					}
					expr = new ArrayCreateExpression(type.Clone(), dimension);
				}
			} else if (rank != null) {
				if(type.RankSpecifier != null) {
					Error("array rank only allowed one time");
				} else {
					type.RankSpecifier = (int[])rank.ToArray(typeof(int));
				}
			}
			
			if (la.kind == 10) {
				lexer.NextToken();
				VariableInitializer(
#line  1463 "VBNET.ATG" 
out expr);
			}
		} else SynErr(250);

#line  1466 "VBNET.ATG" 
		VariableDeclaration varDecl = new VariableDeclaration(name, expr, type);
		varDecl.StartLocation = startLocation;
		varDecl.EndLocation = t.Location;
		fieldDeclaration.Add(varDecl);
		
	}
예제 #11
0
	void EnumMemberDecl(
#line  743 "VBNET.ATG" 
out FieldDeclaration f) {

#line  745 "VBNET.ATG" 
		Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
		AttributeSection section = null;
		VariableDeclaration varDecl = null;
		
		while (la.kind == 28) {
			AttributeSection(
#line  749 "VBNET.ATG" 
out section);

#line  749 "VBNET.ATG" 
			attributes.Add(section); 
		}
		Identifier();

#line  752 "VBNET.ATG" 
		f = new FieldDeclaration(attributes);
		varDecl = new VariableDeclaration(t.val);
		f.Fields.Add(varDecl);
		f.StartLocation = varDecl.StartLocation = t.Location;
		
		if (la.kind == 10) {
			lexer.NextToken();
			Expr(
#line  757 "VBNET.ATG" 
out expr);

#line  757 "VBNET.ATG" 
			varDecl.Initializer = expr; 
		}
		EndOfStmt();
	}
		public virtual object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			Debug.Assert((variableDeclaration != null));
			Debug.Assert((variableDeclaration.Initializer != null));
			Debug.Assert((variableDeclaration.TypeReference != null));
			Debug.Assert((variableDeclaration.FixedArrayInitialization != null));
			nodeStack.Push(variableDeclaration.Initializer);
			variableDeclaration.Initializer.AcceptVisitor(this, data);
			variableDeclaration.Initializer = ((Expression)(nodeStack.Pop()));
			nodeStack.Push(variableDeclaration.TypeReference);
			variableDeclaration.TypeReference.AcceptVisitor(this, data);
			variableDeclaration.TypeReference = ((TypeReference)(nodeStack.Pop()));
			nodeStack.Push(variableDeclaration.FixedArrayInitialization);
			variableDeclaration.FixedArrayInitialization.AcceptVisitor(this, data);
			variableDeclaration.FixedArrayInitialization = ((Expression)(nodeStack.Pop()));
			return null;
		}
예제 #13
0
		public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
		{
			// process local variables only
			if (fields.Contains(variableDeclaration)) {
				return null;
			}
			curBlock.Add(variableDeclaration.Name);
			return base.VisitVariableDeclaration(variableDeclaration, data);
		}
		public virtual object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			throw new global::System.NotImplementedException("VariableDeclaration");
		}
		public virtual object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			return base.VisitVariableDeclaration(variableDeclaration, data);
		}
예제 #16
0
		public virtual object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			Debug.Assert((variableDeclaration != null));
			Debug.Assert((variableDeclaration.Initializer != null));
			Debug.Assert((variableDeclaration.TypeReference != null));
			Debug.Assert((variableDeclaration.FixedArrayInitialization != null));
			variableDeclaration.Initializer.AcceptVisitor(this, data);
			variableDeclaration.TypeReference.AcceptVisitor(this, data);
			return variableDeclaration.FixedArrayInitialization.AcceptVisitor(this, data);
		}
예제 #17
0
		public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
		{
			return null;
		}