Skip to content

Commit

Permalink
Allow ability to pass in a special ValueSpecificationBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-kim1 committed Jan 10, 2025
1 parent 7d26e42 commit be90b94
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.finos.legend.engine.language.pure.compiler.toPureGraph;

import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.function.Function3;
import org.eclipse.collections.api.list.ListIterable;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.tuple.Pair;
Expand Down Expand Up @@ -96,10 +97,15 @@ public static LambdaFunction<?> buildLambdaWithContext(List<org.finos.legend.eng
}

public static LambdaFunction<?> buildLambdaWithContext(String lambdaId, List<org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification> expressions, List<Variable> parameters, CompileContext context, ProcessingContext ctx)
{
return buildLambdaWithContext(lambdaId, expressions, parameters, context, ctx, ValueSpecificationBuilder::new);
}

public static LambdaFunction<?> buildLambdaWithContext(String lambdaId, List<org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification> expressions, List<Variable> parameters, CompileContext context, ProcessingContext ctx, Function3<CompileContext, MutableList<String>, ProcessingContext, ValueSpecificationBuilder> valueSpecificationBuilderFactory)
{
ctx.push("new lambda");
ctx.addVariableLevel();
MutableList<VariableExpression> pureParameters = ListIterate.collect(parameters, p -> (VariableExpression) p.accept(new ValueSpecificationBuilder(context, Lists.mutable.empty(), ctx)));
MutableList<VariableExpression> pureParameters = ListIterate.collect(parameters, p -> (VariableExpression) p.accept(valueSpecificationBuilderFactory.value(context, Lists.mutable.empty(), ctx)));
if (parameters.size() != 0 && !parameters.get(0).name.equals("v_automap"))
{
if (ctx.milestoningDatePropagationContext.size() == 0)
Expand All @@ -112,7 +118,7 @@ public static LambdaFunction<?> buildLambdaWithContext(String lambdaId, List<org
}
}
MutableList<String> openVariables = Lists.mutable.empty();
MutableList<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification> valueSpecifications = ListIterate.collect(expressions, p -> p.accept(new ValueSpecificationBuilder(context, openVariables, ctx)));
MutableList<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification> valueSpecifications = ListIterate.collect(expressions, p -> p.accept(valueSpecificationBuilderFactory.value(context, openVariables, ctx)));

// Remove Lambda parameters from openVariables
MutableList<String> cleanedOpenVariables = openVariables.distinct();
Expand Down

0 comments on commit be90b94

Please sign in to comment.