use of org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser.LambdaPipeContext in project legend-pure by finos.
the class AntlrContextToM3CoreInstance method lambdaPipe.
private Any lambdaPipe(LambdaPipeContext ctx, Token firstToken, ListIterable<VariableExpression> params, MutableList<String> typeParametersNames, LambdaContext lambdaContext, String space, boolean wrapFlag, ImportGroup importId, boolean addLines) {
Token lambdaStartToken = firstToken != null ? firstToken : ctx.PIPE().getSymbol();
ListIterable<ValueSpecification> block = codeBlock(ctx.codeBlock(), typeParametersNames, importId, lambdaContext, addLines, spacePlusTabs(space, 6));
FunctionTypeInstance signature = FunctionTypeInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(lambdaStartToken), null, null);
if (Iterate.notEmpty(params)) {
signature._parameters(params);
}
// Note: we cannot set the function of the signature FunctionType, as this can cause stack overflow if serializing to M4
GenericTypeInstance genericTypeInstance = GenericTypeInstance.createPersistent(this.repository);
Type type = (Type) this.processorSupport.package_getByUserPath(M3Paths.LambdaFunction);
genericTypeInstance._rawTypeCoreInstance(type);
GenericTypeInstance genericTypeInstanceTa = GenericTypeInstance.createPersistent(this.repository);
genericTypeInstanceTa._rawTypeCoreInstance(signature);
genericTypeInstance._typeArguments(Lists.mutable.<GenericType>of(genericTypeInstanceTa));
LambdaFunctionInstance lambdaFunction = LambdaFunctionInstance.createPersistent(this.repository, lambdaContext.getLambdaFunctionUniqueName(), this.sourceInformation.getPureSourceInformation(lambdaStartToken));
lambdaFunction._classifierGenericType(genericTypeInstance);
lambdaFunction._expressionSequence(block);
return wrapFlag ? this.doWrap(lambdaFunction, lambdaStartToken) : lambdaFunction;
}
Aggregations