Skip to content

Commit 4afe8e1

Browse files
committed
Add "func.combXNF()"
1 parent fbed241 commit 4afe8e1

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/main/java/at/jddev0/lang/LangPredefinedFunctions.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7470,6 +7470,49 @@ public static DataObject combXNEFunction(
74707470
), SCOPE_ID);
74717471
}
74727472

7473+
@LangFunction("combXNF")
7474+
@CombinatorFunction
7475+
@LangInfo("Combinator execution: a(b(d)(e))(c)")
7476+
public static DataObject combXNFFunction(
7477+
LangInterpreter interpreter, int SCOPE_ID,
7478+
@LangParameter("$a") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject a,
7479+
@LangParameter("$b") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject b,
7480+
@LangParameter("$c") DataObject c,
7481+
@LangParameter("$d") DataObject d,
7482+
@LangParameter("$e") DataObject e
7483+
) {
7484+
FunctionPointerObject aFunc = a.getFunctionPointer();
7485+
FunctionPointerObject bFunc = b.getFunctionPointer();
7486+
7487+
DataObject retB = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
7488+
d
7489+
), SCOPE_ID);
7490+
retB = LangUtils.nullToLangVoid(retB);
7491+
7492+
if(retB.getType() != DataType.FUNCTION_POINTER)
7493+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(d) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7494+
7495+
FunctionPointerObject retBFunc = retB.getFunctionPointer();
7496+
7497+
DataObject retB2 = interpreter.callFunctionPointer(retBFunc, retB.getVariableName(), Arrays.asList(
7498+
e
7499+
), SCOPE_ID);
7500+
7501+
DataObject retA = interpreter.callFunctionPointer(aFunc, a.getVariableName(), Arrays.asList(
7502+
LangUtils.nullToLangVoid(retB2)
7503+
), SCOPE_ID);
7504+
retA = LangUtils.nullToLangVoid(retA);
7505+
7506+
if(retA.getType() != DataType.FUNCTION_POINTER)
7507+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by a(b(d)(e)) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7508+
7509+
FunctionPointerObject retAFunc = retA.getFunctionPointer();
7510+
7511+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
7512+
c
7513+
), SCOPE_ID);
7514+
}
7515+
74737516
@LangFunction("combY")
74747517
@CombinatorFunction
74757518
@LangInfo("Combinator execution: (x -> f(x(x)))(x -> f(x(x)))")

0 commit comments

Comments
 (0)