@Override protected Type visitBindExpression(BindExpression node, StackableAstVisitorContext<Context> context) { verify(context.getContext().isExpectingLambda(), "bind expression found when lambda is not expected"); StackableAstVisitorContext<Context> innerContext = new StackableAstVisitorContext<>(context.getContext().notExpectingLambda()); ImmutableList.Builder<Type> functionInputTypesBuilder = ImmutableList.builder(); for (Expression value : node.getValues()) { functionInputTypesBuilder.add(process(value, innerContext)); } functionInputTypesBuilder.addAll(context.getContext().getFunctionInputTypes()); List<Type> functionInputTypes = functionInputTypesBuilder.build(); FunctionType functionType = (FunctionType) process(node.getFunction(), new StackableAstVisitorContext<>(context.getContext().expectingLambda(functionInputTypes))); List<Type> argumentTypes = functionType.getArgumentTypes(); int numCapturedValues = node.getValues().size(); verify(argumentTypes.size() == functionInputTypes.size()); for (int i = 0; i < numCapturedValues; i++) { verify(functionInputTypes.get(i).equals(argumentTypes.get(i))); } FunctionType result = new FunctionType(argumentTypes.subList(numCapturedValues, argumentTypes.size()), functionType.getReturnType()); return setExpressionType(node, result); }
Type returnType = process(node.getBody(), new StackableAstVisitorContext<>(Context.inLambda(lambdaScope, fieldToLambdaArgumentDeclaration.build()))); FunctionType functionType = new FunctionType(types, returnType); return setExpressionType(node, functionType);
process(expression, new StackableAstVisitorContext<>(context.getContext().expectingLambda(expectedFunctionType.getArgumentTypes())));
/** * @param tupleDescriptor the tuple descriptor to use to resolve QualifiedNames * @param context the namespace context of the surrounding query */ public Type analyze(Expression expression, RelationType tupleDescriptor, AnalysisContext context) { Visitor visitor = new Visitor(tupleDescriptor); return visitor.process(expression, new StackableAstVisitor.StackableAstVisitorContext<>(context)); }
private Type analyze(Expression expression, Scope baseScope, Context context) { Visitor visitor = new Visitor(baseScope, warningCollector); return visitor.process(expression, new StackableAstVisitor.StackableAstVisitorContext<>(context)); }
public Type analyze(Expression expression, Scope scope) { Visitor visitor = new Visitor(scope, warningCollector); return visitor.process(expression, new StackableAstVisitor.StackableAstVisitorContext<>(Context.notInLambda(scope))); }