Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move special handling for PackageableElementPtr in ValueSpecificationBuilderForFuncExpr to ValueSpecificationBuilder #3346

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Tag r

// ------------------------------------------ FUNCTION EXPRESSION BUILDER -----------------------------------------

public Pair<SimpleFunctionExpression, List<ValueSpecification>> buildFunctionExpression(String functionName, String fControl, List<org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification> parameters, MutableList<String> openVariables, SourceInformation sourceInformation, ProcessingContext processingContext)
public Pair<SimpleFunctionExpression, List<ValueSpecification>> buildFunctionExpression(String functionName, String fControl, List<org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification> parameters, SourceInformation sourceInformation, ValueSpecificationBuilder valueSpecificationBuilder)
{
Pair<SimpleFunctionExpression, List<ValueSpecification>> functionExpression;
functionExpression = this.pureModel.handlers.buildFunctionExpression(functionName, parameters, openVariables, sourceInformation, this, processingContext);
functionExpression = this.pureModel.handlers.buildFunctionExpression(functionName, parameters, sourceInformation, valueSpecificationBuilder);
if (fControl != null)
{
testFunction(fControl, processingContext, functionExpression.getOne());
testFunction(fControl, valueSpecificationBuilder.getProcessingContext(), functionExpression.getOne());
}
return functionExpression;
}
Expand Down
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 Expand Up @@ -274,7 +280,7 @@ else if (foundFunction instanceof QualifiedProperty)
automapLambda.parameters = lambdaParams;
List<ValueSpecification> newParams = Lists.mutable.of(parameters.get(0), automapLambda);
MilestoningDatePropagationHelper.updateMilestoningPropagationContextWhileReprocessingFunctionExpression(processingContext);
result = context.buildFunctionExpression("map", null, newParams, openVariables, sourceInformation, processingContext).getOne();
result = context.buildFunctionExpression("map", null, newParams, sourceInformation, new ValueSpecificationBuilder(context, openVariables, processingContext)).getOne();
processingContext.pop();
}
else
Expand Down
Loading
Loading