private IEnumerable <ParameterExpression> RewriteParameters(IEnumerable <ParameterExpression> parameters) { var result = new List <ParameterExpression>(); foreach (var parameter in parameters) { if (IsQueryableValue(parameter.Type)) { var rewritten = Expression.Parameter(typeof(JToken), parameter.Name); var p = new LambdaParameter( parameter, rewritten, syntax.Head); lambdaParameters.Add(parameter, p); result.Add(rewritten); } else { result.Add(parameter); } } return(result); }
private Expression ParseLambda(SimpleName parameterName, TokenSet followers) //^ requires this.currentToken == Token.Lambda; //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile; { NameDeclaration paramName = new NameDeclaration(parameterName.Name, parameterName.SourceLocation); SourceLocationBuilder slb = new SourceLocationBuilder(parameterName.SourceLocation); LambdaParameter parameter = new LambdaParameter(false, false, null, paramName, parameterName.SourceLocation); List<LambdaParameter> parameters = new List<LambdaParameter>(1); parameters.Add(parameter); //^ assume this.currentToken == Token.Lambda; //follows from the precondition return this.ParseLambda(parameters, slb, followers); }
public LambdaContextHandler(ParseInfo parseInfo, LambdaParameter parameter) { ParseInfo = parseInfo; _parameter = parameter; }
private LambdaParameter ParseLambdaParameter(bool allowType, TokenSet followers) //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile; { SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken); bool isOut = false; bool isRef = false; Token firstToken = this.currentToken; NameDeclaration parameterName = new NameDeclaration(this.GetNameFor(this.scanner.GetIdentifierString()), this.scanner.SourceLocationOfLastScannedToken); TypeExpression/*?*/ parameterType = null; if (allowType) { if (this.currentToken == Token.Out) { isOut = true; this.GetNextToken(); } else if (this.currentToken == Token.Ref) { isRef = true; this.GetNextToken(); } parameterType = this.ParseTypeExpression(false, false, followers); if ((this.currentToken == Token.Comma || this.currentToken == Token.RightParenthesis) && Parser.IdentifierOrNonReservedKeyword[firstToken]) { parameterType = null; } else { parameterName = new NameDeclaration(this.GetNameFor(this.scanner.GetIdentifierString()), this.scanner.SourceLocationOfLastScannedToken); } } slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken); LambdaParameter result = new LambdaParameter(isOut, isRef, parameterType, parameterName, slb); if (!Parser.IdentifierOrNonReservedKeyword[this.currentToken]) this.HandleError(Error.ExpectedIdentifier); else { //^ assume this.currentToken != Token.EndOfFile; //follows from definition of Parser.IdentifierOrNonReservedKeyword this.GetNextToken(); } this.SkipTo(followers); return result; }