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

Fix compiled gen for preval native func #857

Open
wants to merge 1 commit 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 @@ -15,21 +15,21 @@
import meta::pure::functions::lang::tests::eval::*;
import meta::pure::test::pct::*;

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<V|m>(func:Function<{->V[m]}>[1]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<V|m>(func:Function<{->V[m]}>[1]):V[m];

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,V|m,n>(func:Function<{T[n]->V[m]}>[1], param:T[n]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,V|m,n>(func:Function<{T[n]->V[m]}>[1], param:T[n]):V[m];

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V|m,n,p>(func:Function<{T[n],U[p]->V[m]}>[1], param1:T[n], param2:U[p]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V|m,n,p>(func:Function<{T[n],U[p]->V[m]}>[1], param1:T[n], param2:U[p]):V[m];

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W|m,n,p,q>(func:Function<{T[n],U[p],W[q]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W|m,n,p,q>(func:Function<{T[n],U[p],W[q]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q]):V[m];

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W,X|m,n,p,q,r>(func:Function<{T[n],U[p],W[q],X[r]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q], param4:X[r]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W,X|m,n,p,q,r>(func:Function<{T[n],U[p],W[q],X[r]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q], param4:X[r]):V[m];

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W,X,Y|m,n,p,q,r,s>(func:Function<{T[n],U[p],W[q],X[r],Y[s]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q], param4:X[r], param5:Y[s]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W,X,Y|m,n,p,q,r,s>(func:Function<{T[n],U[p],W[q],X[r],Y[s]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q], param4:X[r], param5:Y[s]):V[m];

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W,X,Y,Z|m,n,p,q,r,s,t>(func:Function<{T[n],U[p],W[q],X[r],Y[s],Z[t]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q], param4:X[r], param5:Y[s], param6:Z[t]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<T,U,V,W,X,Y,Z|m,n,p,q,r,s,t>(func:Function<{T[n],U[p],W[q],X[r],Y[s],Z[t]->V[m]}>[1], param1:T[n], param2:U[p], param3:W[q], param4:X[r], param5:Y[s], param6:Z[t]):V[m];

native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<S,T,V,U,W,X,Y,Z|m,n,o,p,q,r,s,t>(func:Function<{S[n],T[o],U[p],W[q],X[r],Y[s],Z[t]->V[m]}>[1], param1:S[n], param2:T[o], param3:U[p], param4:W[q], param5:X[r], param6:Y[s], param7:Z[t]):V[m];
native function <<functionType.NormalizeRequiredFunction, PCT.function, PCT.platformOnly>> meta::pure::functions::lang::eval<S,T,V,U,W,X,Y,Z|m,n,o,p,q,r,s,t>(func:Function<{S[n],T[o],U[p],W[q],X[r],Y[s],Z[t]->V[m]}>[1], param1:S[n], param2:T[o], param3:U[p], param4:W[q], param5:X[r], param6:Y[s], param7:Z[t]):V[m];



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public String buildBody()
{
String typeName = getClassName(type);
String parameterType = type instanceof Class && ((Class<?>) type).isArray() ? "ListIterable<" + typeName + ">" : typeName;
parameterAccessStrings.add("(" + parameterType + ")vars.get(" + index + ")");
boolean isCollection = type instanceof Class && Iterable.class.isAssignableFrom(((Class<?>) type));
parameterAccessStrings.add("(" + parameterType + ")" + (!isCollection ? "CompiledSupport.toOne(" : "") + "vars.get(" + index + ")" + (!isCollection ? ", null)" : ""));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,12 @@

package org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.essentials.math.operation;

import org.eclipse.collections.api.list.ListIterable;
import org.finos.legend.pure.m4.coreinstance.CoreInstance;
import org.finos.legend.pure.runtime.java.compiled.generation.ProcessorContext;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNative;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNativeFunctionGeneric;

public class Mod extends AbstractNative
public class Mod extends AbstractNativeFunctionGeneric
{
public Mod()
{
super("mod_Integer_1__Integer_1__Integer_1_");
}

@Override
public String build(CoreInstance topLevelElement, CoreInstance functionExpression, ListIterable<String> transformedParams, ProcessorContext processorContext)
{
return "CoreGen.mod(" + transformedParams.get(0) + "," + transformedParams.get(1) + ")";
}

@Override
public String buildBody()
{
return "new DefendedPureFunction2<Long, Long, Long>()\n" +
" {\n" +
" @Override\n" +
" public Long value(Long input1, Long input2, ExecutionSupport es)\n" +
" {\n" +
" return CoreGen.mod(input1, input2);\n" +
" }\n" +
" }";
super("CoreGen.mod", new Class[]{Long.class, Long.class}, "mod_Integer_1__Integer_1__Integer_1_");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,13 @@

package org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.essentials.string.toString;

import org.eclipse.collections.api.list.ListIterable;
import org.finos.legend.pure.m4.coreinstance.CoreInstance;
import org.finos.legend.pure.runtime.java.compiled.generation.ProcessorContext;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNative;
import org.finos.legend.pure.m3.execution.ExecutionSupport;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNativeFunctionGeneric;

public class Format extends AbstractNative
public class Format extends AbstractNativeFunctionGeneric
{
public Format()
{
super("format_String_1__Any_MANY__String_1_");
}

@Override
public String build(CoreInstance topLevelElement, CoreInstance functionExpression, ListIterable<String> transformedParams, ProcessorContext processorContext)
{
return "CoreGen.format(" + transformedParams.get(0) + ", " + transformedParams.get(1) + ", es)";
}

@Override
public String buildBody()
{
return "new DefendedPureFunction2<String, Object, Object>()\n" +
" {\n" +
" @Override\n" +
" public Object value(String formatString, Object formatArgs, ExecutionSupport es)\n" +
" {\n" +
" return CoreGen.format(formatString, formatArgs, es);\n" +
" }\n" +
" }";
super("CoreGen.format", new Class[]{String.class, Object.class, ExecutionSupport.class}, false, true, false, "format_String_1__Any_MANY__String_1_");
}
}
Loading