public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
		{
			if (nameComparer.Equals(from, variableDeclaration.Name)) {
				variableDeclaration.Name = to;
			}
			return base.VisitVariableDeclaration(variableDeclaration, data);
		}
		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) {
			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);
		}
		public virtual object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			throw new global::System.NotImplementedException("VariableDeclaration");
		}
		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;
		}
Beispiel #6
0
	void ConstantDeclarator(List<VariableDeclaration> constantDeclaration) {
		Expression expr = null;
		TypeReference type = null;
		string name = String.Empty;
		Location location;

		Identifier();
		name = t.val; location = t.Location;
		if (la.kind == 63) {
			Get();
			TypeName(out type);
		}
		Expect(20);
		Expr(out expr);
		VariableDeclaration f = new VariableDeclaration(name, expr);
			f.TypeReference = type;
			f.StartLocation = location;
			constantDeclaration.Add(f);

	}
Beispiel #7
0
	void VariableDeclaratorPartAfterIdentifier(List<VariableDeclaration> fieldDeclaration, string name) {
		Expression expr = null;
		TypeReference type = null;
		ArrayList rank = null;
		List<Expression> dimension = null;
		Location startLocation = t.Location;

		if (IsSize() && !IsDims()) {
			ArrayInitializationModifier(out dimension);
		}
		if (IsDims()) {
			ArrayNameModifier(out rank);
		}
		if (IsObjectCreation()) {
			Expect(63);
			ObjectCreateExpression(out expr);
			if (expr is ObjectCreateExpression) {
					type = ((ObjectCreateExpression)expr).CreateType.Clone();
				} else {
					type = ((ArrayCreateExpression)expr).CreateType.Clone();
				}

		} else if (StartOf(23)) {
			if (la.kind == 63) {
				Get();
				TypeName(out type);
				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;
					}
				}

			}
			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 == 20) {
				Get();
				Expr(out expr);
			}
		} else SynErr(271);
		VariableDeclaration varDecl = new VariableDeclaration(name, expr, type);
			varDecl.StartLocation = startLocation;
			varDecl.EndLocation = t.Location;
			fieldDeclaration.Add(varDecl);

	}
Beispiel #8
0
	void EnumMemberDecl(out FieldDeclaration f) {
		Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
		AttributeSection section = null;
		VariableDeclaration varDecl = null;

		while (la.kind == 40) {
			AttributeSection(out section);
			attributes.Add(section);
		}
		Identifier();
		f = new FieldDeclaration(attributes);
			varDecl = new VariableDeclaration(t.val);
			f.Fields.Add(varDecl);
			f.StartLocation = varDecl.StartLocation = t.Location;

		if (la.kind == 20) {
			Get();
			Expr(out expr);
			varDecl.Initializer = expr;
		}
		f.EndLocation = varDecl.EndLocation = t.EndLocation;
		EndOfStmt();
	}
		public LocalVariableDeclaration(VariableDeclaration declaration) : this(TypeReference.Null)
		{
			Variables.Add(declaration);
		}
		public sealed override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			this.BeginVisit(variableDeclaration);
			object result = this.TrackedVisitVariableDeclaration(variableDeclaration, data);
			this.EndVisit(variableDeclaration);
			return result;
		}
		public virtual object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) {
			return base.VisitVariableDeclaration(variableDeclaration, data);
		}
		public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
		{
			return null;
		}