예제 #1
0
		public LocalLookupVariable(string name, TypeReference typeRef, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression, bool isQueryContinuation)
		{
			this.Name = name;
			this.TypeRef = typeRef;
			this.StartPos = startPos;
			this.EndPos = endPos;
			this.IsConst = isConst;
			this.IsLoopVariable = isLoopVariable;
			this.Initializer = initializer;
			this.ParentLambdaExpression = parentLambdaExpression;
			this.IsQueryContinuation = isQueryContinuation;
		}
예제 #2
0
		public void AddVariable(TypeReference typeRef, string name,
		                        Location startPos, Location endPos, bool isConst,
		                        bool isLoopVariable, Expression initializer,
		                        LambdaExpression parentLambdaExpression,
		                        bool isQueryContinuation)
		{
			if (name == null || name.Length == 0) {
				return;
			}
			List<LocalLookupVariable> list;
			if (!variables.ContainsKey(name)) {
				variables[name] = list = new List<LocalLookupVariable>();
			} else {
				list = (List<LocalLookupVariable>)variables[name];
			}
			list.Add(new LocalLookupVariable(name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression, isQueryContinuation));
		}
예제 #3
0
		public virtual object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			Debug.Assert((lambdaExpression != null));
			Debug.Assert((lambdaExpression.Parameters != null));
			Debug.Assert((lambdaExpression.StatementBody != null));
			Debug.Assert((lambdaExpression.ExpressionBody != null));
			Debug.Assert((lambdaExpression.ReturnType != null));
			foreach (ParameterDeclarationExpression o in lambdaExpression.Parameters) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			lambdaExpression.StatementBody.AcceptVisitor(this, data);
			lambdaExpression.ExpressionBody.AcceptVisitor(this, data);
			return lambdaExpression.ReturnType.AcceptVisitor(this, data);
		}
		public virtual object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			throw new global::System.NotImplementedException("LambdaExpression");
		}
예제 #5
0
		public virtual object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			Debug.Assert((lambdaExpression != null));
			Debug.Assert((lambdaExpression.Parameters != null));
			Debug.Assert((lambdaExpression.StatementBody != null));
			Debug.Assert((lambdaExpression.ExpressionBody != null));
			Debug.Assert((lambdaExpression.ReturnType != null));
			for (int i = 0; i < lambdaExpression.Parameters.Count; i++) {
				ParameterDeclarationExpression o = lambdaExpression.Parameters[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (ParameterDeclarationExpression)nodeStack.Pop();
				if (o == null)
					lambdaExpression.Parameters.RemoveAt(i--);
				else
					lambdaExpression.Parameters[i] = o;
			}
			nodeStack.Push(lambdaExpression.StatementBody);
			lambdaExpression.StatementBody.AcceptVisitor(this, data);
			lambdaExpression.StatementBody = ((Statement)(nodeStack.Pop()));
			nodeStack.Push(lambdaExpression.ExpressionBody);
			lambdaExpression.ExpressionBody.AcceptVisitor(this, data);
			lambdaExpression.ExpressionBody = ((Expression)(nodeStack.Pop()));
			nodeStack.Push(lambdaExpression.ReturnType);
			lambdaExpression.ReturnType.AcceptVisitor(this, data);
			lambdaExpression.ReturnType = ((TypeReference)(nodeStack.Pop()));
			return null;
		}
예제 #6
0
	void FunctionLambdaExpression(out LambdaExpression lambda) {
		lambda = new LambdaExpression();
		TypeReference typeRef = null;
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;

		Expect(127);
		Expect(37);
		if (StartOf(7)) {
			FormalParameterList(lambda.Parameters);
		}
		Expect(38);
		if (la.kind == 63) {
			Get();
			TypeName(out typeRef);
			lambda.ReturnType = typeRef;
		}
		if (StartOf(24)) {
			Expr(out inner);
			lambda.ExpressionBody = inner;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;

		} else if (la.kind == 1) {
			Get();
			Block(out statement);
			Expect(113);
			Expect(127);
			lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;

		} else SynErr(294);
	}
예제 #7
0
	void SubLambdaExpression(out LambdaExpression lambda) {
		lambda = new LambdaExpression();
		lambda.ReturnType = new TypeReference("System.Void", true);
		Statement statement = null;
		lambda.StartLocation = la.Location;

		Expect(210);
		Expect(37);
		if (StartOf(7)) {
			FormalParameterList(lambda.Parameters);
		}
		Expect(38);
		if (StartOf(1)) {
			EmbeddedStatement(out statement);
			lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;

		} else if (la.kind == 1) {
			Get();
			Block(out statement);
			Expect(113);
			Expect(210);
			lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;

		} else SynErr(293);
	}
예제 #8
0
		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			foreach (ParameterDeclarationExpression p in lambdaExpression.Parameters) {
				AddVariable(p.TypeReference, p.ParameterName,
				            lambdaExpression.StartLocation, lambdaExpression.ExtendedEndLocation,
				            false, false, null, lambdaExpression, false);
			}
			return base.VisitLambdaExpression(lambdaExpression, data);
		}
예제 #9
0
		public sealed override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			this.BeginVisit(lambdaExpression);
			object result = this.TrackedVisitLambdaExpression(lambdaExpression, data);
			this.EndVisit(lambdaExpression);
			return result;
		}
예제 #10
0
		public virtual object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			return base.VisitLambdaExpression(lambdaExpression, data);
		}