Skip to content

Commit 7df2d74

Browse files
committed
Add "func.combXN6()"
1 parent 41822ba commit 7df2d74

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
@@ -6951,6 +6951,48 @@ public static DataObject combXN5Function(
69516951
), SCOPE_ID);
69526952
}
69536953

6954+
@LangFunction("combXN6")
6955+
@CombinatorFunction
6956+
@LangInfo("Combinator execution: a(d)(b(c)(d))")
6957+
public static DataObject combXN6Function(
6958+
LangInterpreter interpreter, int SCOPE_ID,
6959+
@LangParameter("$a") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject a,
6960+
@LangParameter("$b") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject b,
6961+
@LangParameter("$c") DataObject c,
6962+
@LangParameter("$d") DataObject d
6963+
) {
6964+
FunctionPointerObject aFunc = a.getFunctionPointer();
6965+
FunctionPointerObject bFunc = b.getFunctionPointer();
6966+
6967+
DataObject retA = interpreter.callFunctionPointer(aFunc, a.getVariableName(), Arrays.asList(
6968+
d
6969+
), SCOPE_ID);
6970+
retA = LangUtils.nullToLangVoid(retA);
6971+
6972+
if(retA.getType() != DataType.FUNCTION_POINTER)
6973+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by a(d) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
6974+
6975+
FunctionPointerObject retAFunc = retA.getFunctionPointer();
6976+
6977+
DataObject retB = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
6978+
c
6979+
), SCOPE_ID);
6980+
retB = LangUtils.nullToLangVoid(retB);
6981+
6982+
if(retB.getType() != DataType.FUNCTION_POINTER)
6983+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(c) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
6984+
6985+
FunctionPointerObject retBFunc = retB.getFunctionPointer();
6986+
6987+
DataObject retB2 = interpreter.callFunctionPointer(retBFunc, retB.getVariableName(), Arrays.asList(
6988+
d
6989+
), SCOPE_ID);
6990+
6991+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
6992+
retB2
6993+
), SCOPE_ID);
6994+
}
6995+
69546996
@LangFunction("combY")
69556997
@CombinatorFunction
69566998
@LangInfo("Combinator execution: (x -> f(x(x)))(x -> f(x(x)))")

0 commit comments

Comments
 (0)