Skip to content

Commit fbed241

Browse files
committed
Add "func.combXNE()"
1 parent ec42b3e commit fbed241

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
@@ -7427,6 +7427,49 @@ public static DataObject combXNDFunction(
74277427
), SCOPE_ID);
74287428
}
74297429

7430+
@LangFunction("combXNE")
7431+
@CombinatorFunction
7432+
@LangInfo("Combinator execution: a(b(e)(d))(c)")
7433+
public static DataObject combXNEFunction(
7434+
LangInterpreter interpreter, int SCOPE_ID,
7435+
@LangParameter("$a") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject a,
7436+
@LangParameter("$b") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject b,
7437+
@LangParameter("$c") DataObject c,
7438+
@LangParameter("$d") DataObject d,
7439+
@LangParameter("$e") DataObject e
7440+
) {
7441+
FunctionPointerObject aFunc = a.getFunctionPointer();
7442+
FunctionPointerObject bFunc = b.getFunctionPointer();
7443+
7444+
DataObject retB = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
7445+
e
7446+
), SCOPE_ID);
7447+
retB = LangUtils.nullToLangVoid(retB);
7448+
7449+
if(retB.getType() != DataType.FUNCTION_POINTER)
7450+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by b(e) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7451+
7452+
FunctionPointerObject retBFunc = retB.getFunctionPointer();
7453+
7454+
DataObject retB2 = interpreter.callFunctionPointer(retBFunc, retB.getVariableName(), Arrays.asList(
7455+
d
7456+
), SCOPE_ID);
7457+
7458+
DataObject retA = interpreter.callFunctionPointer(aFunc, a.getVariableName(), Arrays.asList(
7459+
LangUtils.nullToLangVoid(retB2)
7460+
), SCOPE_ID);
7461+
retA = LangUtils.nullToLangVoid(retA);
7462+
7463+
if(retA.getType() != DataType.FUNCTION_POINTER)
7464+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by a(b(e)(d)) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
7465+
7466+
FunctionPointerObject retAFunc = retA.getFunctionPointer();
7467+
7468+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
7469+
c
7470+
), SCOPE_ID);
7471+
}
7472+
74307473
@LangFunction("combY")
74317474
@CombinatorFunction
74327475
@LangInfo("Combinator execution: (x -> f(x(x)))(x -> f(x(x)))")

0 commit comments

Comments
 (0)