Skip to content

Commit 128116d

Browse files
committed
Add "func.combXN9()"
1 parent b6fd7e3 commit 128116d

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
@@ -7105,6 +7105,62 @@ public static DataObject combXN8Function(
71057105
), SCOPE_ID);
71067106
}
71077107

7108+
@LangFunction("combXN9")
7109+
@CombinatorFunction
7110+
@LangInfo("Combinator execution: a(b(d)(d))(b(c)(c))")
7111+
public static DataObject combXN9Function(
7112+
LangInterpreter interpreter, int SCOPE_ID,
7113+
@LangParameter("$a") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject a,
7114+
@LangParameter("$b") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject b,
7115+
@LangParameter("$c") DataObject c,
7116+
@LangParameter("$d") DataObject d
7117+
) {
7118+
FunctionPointerObject aFunc = a.getFunctionPointer();
7119+
FunctionPointerObject bFunc = b.getFunctionPointer();
7120+
7121+
DataObject retB = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
7122+
d
7123+
), SCOPE_ID);
7124+
retB = LangUtils.nullToLangVoid(retB);
7125+
7126+
if(retB.getType() != DataType.FUNCTION_POINTER)
7127+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(d) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7128+
7129+
FunctionPointerObject retBFunc = retB.getFunctionPointer();
7130+
7131+
DataObject retB2 = interpreter.callFunctionPointer(retBFunc, retB.getVariableName(), Arrays.asList(
7132+
d
7133+
), SCOPE_ID);
7134+
7135+
DataObject retA = interpreter.callFunctionPointer(aFunc, a.getVariableName(), Arrays.asList(
7136+
LangUtils.nullToLangVoid(retB2)
7137+
), SCOPE_ID);
7138+
retA = LangUtils.nullToLangVoid(retA);
7139+
7140+
if(retA.getType() != DataType.FUNCTION_POINTER)
7141+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by a(b(d)(d)) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7142+
7143+
FunctionPointerObject retAFunc = retA.getFunctionPointer();
7144+
7145+
DataObject retB3 = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
7146+
c
7147+
), SCOPE_ID);
7148+
retB3 = LangUtils.nullToLangVoid(retB3);
7149+
7150+
if(retB3.getType() != DataType.FUNCTION_POINTER)
7151+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(c) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7152+
7153+
FunctionPointerObject retB3Func = retB3.getFunctionPointer();
7154+
7155+
DataObject retB4 = interpreter.callFunctionPointer(retB3Func, retB3.getVariableName(), Arrays.asList(
7156+
c
7157+
), SCOPE_ID);
7158+
7159+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
7160+
LangUtils.nullToLangVoid(retB4)
7161+
), SCOPE_ID);
7162+
}
7163+
71087164
@LangFunction("combY")
71097165
@CombinatorFunction
71107166
@LangInfo("Combinator execution: (x -> f(x(x)))(x -> f(x(x)))")

0 commit comments

Comments
 (0)