Пример #1
0
		public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			Debug.Assert((arrayCreateExpression != null));
			Debug.Assert((arrayCreateExpression.CreateType != null));
			Debug.Assert((arrayCreateExpression.Arguments != null));
			Debug.Assert((arrayCreateExpression.ArrayInitializer != null));
			arrayCreateExpression.CreateType.AcceptVisitor(this, data);
			foreach (Expression o in arrayCreateExpression.Arguments) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			return arrayCreateExpression.ArrayInitializer.AcceptVisitor(this, data);
		}
Пример #2
0
		public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			Debug.Assert((arrayCreateExpression != null));
			Debug.Assert((arrayCreateExpression.CreateType != null));
			Debug.Assert((arrayCreateExpression.Arguments != null));
			Debug.Assert((arrayCreateExpression.ArrayInitializer != null));
			nodeStack.Push(arrayCreateExpression.CreateType);
			arrayCreateExpression.CreateType.AcceptVisitor(this, data);
			arrayCreateExpression.CreateType = ((TypeReference)(nodeStack.Pop()));
			for (int i = 0; i < arrayCreateExpression.Arguments.Count; i++) {
				Expression o = arrayCreateExpression.Arguments[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (Expression)nodeStack.Pop();
				if (o == null)
					arrayCreateExpression.Arguments.RemoveAt(i--);
				else
					arrayCreateExpression.Arguments[i] = o;
			}
			nodeStack.Push(arrayCreateExpression.ArrayInitializer);
			arrayCreateExpression.ArrayInitializer.AcceptVisitor(this, data);
			arrayCreateExpression.ArrayInitializer = ((CollectionInitializerExpression)(nodeStack.Pop()));
			return null;
		}
		public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			throw new global::System.NotImplementedException("ArrayCreateExpression");
		}
Пример #4
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            ArrayCreateExpression o = other as ArrayCreateExpression;

            return(o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.AdditionalArraySpecifiers.DoMatch(o.AdditionalArraySpecifiers, match) && this.Initializer.DoMatch(o.Initializer, match));
        }
Пример #5
0
	void ObjectCreateExpression(out Expression oce) {
		TypeReference type = null;
		CollectionInitializerExpression initializer = null;
		List<Expression> arguments = null;
		ArrayList dimensions = null;
		oce = null;
		Location startLocation = la.Location;
		bool canBeNormal; bool canBeReDim;

		Expect(162);
		if (StartOf(9)) {
			NonArrayTypeName(out type, false);
			if (la.kind == 37) {
				Get();
				NormalOrReDimArgumentList(out arguments, out canBeNormal, out canBeReDim);
				Expect(38);
				if (la.kind == 35 || (la.kind == Tokens.OpenParenthesis)) {
					if (la.kind == Tokens.OpenParenthesis) {
						ArrayTypeModifiers(out dimensions);
						CollectionInitializer(out initializer);
					} else {
						CollectionInitializer(out initializer);
					}
				}
				if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression();
			}
		}
		if (initializer == null) {
				oce = new ObjectCreateExpression(type, arguments);
			} else {
				if (dimensions == null) dimensions = new ArrayList();
				dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0));
				type.RankSpecifier = (int[])dimensions.ToArray(typeof(int));
				ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer);
				ace.Arguments = arguments;
				oce = ace;
			}

		if (la.kind == 126 || la.kind == 233) {
			if (la.kind == 233) {
				MemberInitializerExpression memberInitializer = null;
					Expression anonymousMember = null;

				Get();
				CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression();
					memberInitializers.StartLocation = la.Location;

				Expect(35);
				if (la.kind == 26 || la.kind == 147) {
					MemberInitializer(out memberInitializer);
					memberInitializers.CreateExpressions.Add(memberInitializer);
				} else if (StartOf(24)) {
					Expr(out anonymousMember);
					memberInitializers.CreateExpressions.Add(anonymousMember);
				} else SynErr(272);
				while (la.kind == 22) {
					Get();
					if (la.kind == 26 || la.kind == 147) {
						MemberInitializer(out memberInitializer);
						memberInitializers.CreateExpressions.Add(memberInitializer);
					} else if (StartOf(24)) {
						Expr(out anonymousMember);
						memberInitializers.CreateExpressions.Add(anonymousMember);
					} else SynErr(273);
				}
				Expect(36);
				memberInitializers.EndLocation = t.Location;
					if(oce is ObjectCreateExpression)
					{
						((ObjectCreateExpression)oce).ObjectInitializer = memberInitializers;
					}

			} else {
				Get();
				CollectionInitializer(out initializer);
				if(oce is ObjectCreateExpression)
						((ObjectCreateExpression)oce).ObjectInitializer = initializer;

			}
		}
		if (oce != null) {
				oce.StartLocation = startLocation;
				oce.EndLocation = t.EndLocation;
			}

	}
Пример #6
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);

	}
Пример #7
0
		public virtual object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			return base.VisitArrayCreateExpression(arrayCreateExpression, data);
		}
Пример #8
0
		public sealed override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			this.BeginVisit(arrayCreateExpression);
			object result = this.TrackedVisitArrayCreateExpression(arrayCreateExpression, data);
			this.EndVisit(arrayCreateExpression);
			return result;
		}
Пример #9
0
		public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
		{
			if (arrayCreateExpression.ArrayInitializer.IsNull) {
				return new CodeArrayCreateExpression(ConvType(arrayCreateExpression.CreateType),
				                                     arrayCreateExpression.Arguments[0].AcceptVisitor(this, data) as CodeExpression);
			}
			return new CodeArrayCreateExpression(ConvType(arrayCreateExpression.CreateType),
			                                     GetExpressionList(arrayCreateExpression.ArrayInitializer.CreateExpressions));
		}