Skip to content

Commit 41822ba

Browse files
committed
Add "func.combXN5()"
1 parent ecd081e commit 41822ba

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6909,6 +6909,48 @@ public static DataObject combXN4Function(
69096909
), SCOPE_ID);
69106910
}
69116911

6912+
@LangFunction("combXN5")
6913+
@CombinatorFunction
6914+
@LangInfo("Combinator execution: a(c)(b(d)(c))")
6915+
public static DataObject combXN5Function(
6916+
LangInterpreter interpreter, int SCOPE_ID,
6917+
@LangParameter("$a") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject a,
6918+
@LangParameter("$b") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject b,
6919+
@LangParameter("$c") DataObject c,
6920+
@LangParameter("$d") DataObject d
6921+
) {
6922+
FunctionPointerObject aFunc = a.getFunctionPointer();
6923+
FunctionPointerObject bFunc = b.getFunctionPointer();
6924+
6925+
DataObject retA = interpreter.callFunctionPointer(aFunc, a.getVariableName(), Arrays.asList(
6926+
c
6927+
), SCOPE_ID);
6928+
retA = LangUtils.nullToLangVoid(retA);
6929+
6930+
if(retA.getType() != DataType.FUNCTION_POINTER)
6931+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by a(c) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
6932+
6933+
FunctionPointerObject retAFunc = retA.getFunctionPointer();
6934+
6935+
DataObject retB = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
6936+
d
6937+
), SCOPE_ID);
6938+
retB = LangUtils.nullToLangVoid(retB);
6939+
6940+
if(retB.getType() != DataType.FUNCTION_POINTER)
6941+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(d) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
6942+
6943+
FunctionPointerObject retBFunc = retB.getFunctionPointer();
6944+
6945+
DataObject retB2 = interpreter.callFunctionPointer(retBFunc, retB.getVariableName(), Arrays.asList(
6946+
c
6947+
), SCOPE_ID);
6948+
6949+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
6950+
retB2
6951+
), SCOPE_ID);
6952+
}
6953+
69126954
@LangFunction("combY")
69136955
@CombinatorFunction
69146956
@LangInfo("Combinator execution: (x -> f(x(x)))(x -> f(x(x)))")

0 commit comments

Comments
 (0)