Skip to content

Commit c2ee16d

Browse files
committed
Add "func.combXN7()"
1 parent 7df2d74 commit c2ee16d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6993,6 +6993,62 @@ public static DataObject combXN6Function(
69936993
), SCOPE_ID);
69946994
}
69956995

6996+
@LangFunction("combXN7")
6997+
@CombinatorFunction
6998+
@LangInfo("Combinator execution: a(b(c)(d))(c)")
6999+
public static DataObject combXN7Function(
7000+
LangInterpreter interpreter, int SCOPE_ID,
7001+
@LangParameter("$a") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject a,
7002+
@LangParameter("$b") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject b,
7003+
@LangParameter("$c") DataObject c,
7004+
@LangParameter("$d") DataObject d
7005+
) {
7006+
FunctionPointerObject aFunc = a.getFunctionPointer();
7007+
FunctionPointerObject bFunc = b.getFunctionPointer();
7008+
7009+
DataObject retB = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
7010+
c
7011+
), SCOPE_ID);
7012+
retB = LangUtils.nullToLangVoid(retB);
7013+
7014+
if(retB.getType() != DataType.FUNCTION_POINTER)
7015+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(c) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7016+
7017+
FunctionPointerObject retBFunc = retB.getFunctionPointer();
7018+
7019+
DataObject retB2 = interpreter.callFunctionPointer(retBFunc, retB.getVariableName(), Arrays.asList(
7020+
d
7021+
), SCOPE_ID);
7022+
7023+
DataObject retA = interpreter.callFunctionPointer(aFunc, a.getVariableName(), Arrays.asList(
7024+
LangUtils.nullToLangVoid(retB2)
7025+
), SCOPE_ID);
7026+
retA = LangUtils.nullToLangVoid(retA);
7027+
7028+
if(retA.getType() != DataType.FUNCTION_POINTER)
7029+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by a(b(c)(d)) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7030+
7031+
FunctionPointerObject retAFunc = retA.getFunctionPointer();
7032+
7033+
DataObject retB3 = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
7034+
d
7035+
), SCOPE_ID);
7036+
retB3 = LangUtils.nullToLangVoid(retB3);
7037+
7038+
if(retB3.getType() != DataType.FUNCTION_POINTER)
7039+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(d) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7040+
7041+
FunctionPointerObject retB3Func = retB3.getFunctionPointer();
7042+
7043+
DataObject retB4 = interpreter.callFunctionPointer(retB3Func, retB3.getVariableName(), Arrays.asList(
7044+
c
7045+
), SCOPE_ID);
7046+
7047+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
7048+
LangUtils.nullToLangVoid(retB4)
7049+
), SCOPE_ID);
7050+
}
7051+
69967052
@LangFunction("combY")
69977053
@CombinatorFunction
69987054
@LangInfo("Combinator execution: (x -> f(x(x)))(x -> f(x(x)))")

0 commit comments

Comments
 (0)