use of org.finos.legend.engine.language.pure.compiler.toPureGraph.ValueSpecificationBuilder in project legend-engine by finos.
the class Handlers method aggInference.
public static void aggInference(Object obj, GenericType gt, int mapOffset, int aggOffset, CompileContext cc, MutableList<String> ov, ProcessingContext pc) {
Lambda aggFirstLambda = null;
Lambda aggSecondLambda = null;
if (obj instanceof AppliedFunction) {
aggFirstLambda = ((Lambda) ((AppliedFunction) obj).parameters.get(mapOffset));
aggSecondLambda = ((Lambda) ((AppliedFunction) obj).parameters.get(aggOffset));
} else if (obj instanceof AggregateValue) {
aggFirstLambda = ((AggregateValue) obj).mapFn;
aggSecondLambda = ((AggregateValue) obj).aggregateFn;
} else if (obj instanceof TDSAggregateValue) {
aggFirstLambda = ((TDSAggregateValue) obj).mapFn;
aggSecondLambda = ((TDSAggregateValue) obj).aggregateFn;
}
if (aggFirstLambda != null && aggSecondLambda != null) {
updateSimpleLambda(aggFirstLambda, gt, new org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity(1, 1));
ValueSpecification processLambda = aggFirstLambda.accept(new ValueSpecificationBuilder(cc, ov, pc));
updateSimpleLambda(aggSecondLambda, funcReturnType(processLambda, cc.pureModel), new org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity());
}
}
use of org.finos.legend.engine.language.pure.compiler.toPureGraph.ValueSpecificationBuilder in project legend-engine by finos.
the class ServiceTestGenerationHelper method generateJavaForAsserts.
// Java
public static String generateJavaForAsserts(List<TestContainer> asserts, Service service, PureModel pureModel, String packageName, String className) {
CompileContext compileContext = pureModel.getContext(service);
ProcessorSupport processorSupport = pureModel.getExecutionSupport().getProcessorSupport();
ProcessorContext processorContext = new ProcessorContext(processorSupport, false);
processorContext.setInLineAllLambda(true);
return "package " + packageName + ";\n" + "\n" + "import org.eclipse.collections.api.RichIterable;\n" + "import org.eclipse.collections.api.list.ListIterable;\n" + "import org.eclipse.collections.impl.factory.Lists;\n" + "import org.eclipse.collections.api.map.MutableMap;\n" + "import org.eclipse.collections.impl.map.mutable.UnifiedMap;\n" + "import org.eclipse.collections.impl.factory.Maps;\n" + "import org.finos.legend.pure.generated.*;\n" + "import org.finos.legend.pure.m3.execution.ExecutionSupport;\n" + "import org.finos.legend.pure.runtime.java.compiled.generation.processors.support.CompiledSupport;\n" + "import org.finos.legend.pure.runtime.java.compiled.generation.processors.support.function.*;\n" + "import java.util.Map;" + "" + "public class " + className + "\n" + "{\n" + " private static Map localLambdas = UnifiedMap.newMap();\n" + LazyIterate.collect(asserts, tc -> (InstanceValue) tc._assert.accept(new ValueSpecificationBuilder(compileContext, Lists.mutable.empty(), new ProcessingContext("")))).collect(vs -> ValueSpecificationProcessor.createFunctionForLambda(null, (CoreInstance) vs._values().getAny(), processorSupport, processorContext)).zipWithIndex().collect(tuple -> " public static boolean " + getAssertMethodName(tuple.getTwo()) + "(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Result _res, ExecutionSupport es)\n" + " {\n" + " return " + tuple.getOne() + ".value(_res, es);\n" + " }\n").makeString("", "\n", "}");
}
Aggregations