Skip to content

Commit 1201260

Browse files
committed
Add "func.combXN2()"
1 parent 1da45c0 commit 1201260

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6788,10 +6788,40 @@ public static DataObject combXN1Function(
67886788

67896789
FunctionPointerObject retAFunc = retA.getFunctionPointer();
67906790

6791-
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), LangUtils.separateArgumentsWithArgumentSeparators(
6792-
Arrays.asList(
6793-
d
6794-
)
6791+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
6792+
d
6793+
), SCOPE_ID);
6794+
}
6795+
6796+
@LangFunction("combXN2")
6797+
@CombinatorFunction
6798+
@LangInfo("Combinator execution: a(c)(b(d))")
6799+
public static DataObject combXN2Function(
6800+
LangInterpreter interpreter, int SCOPE_ID,
6801+
@LangParameter("$a") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject a,
6802+
@LangParameter("$b") @AllowedTypes(DataObject.DataType.FUNCTION_POINTER) DataObject b,
6803+
@LangParameter("$c") DataObject c,
6804+
@LangParameter("$d") DataObject d
6805+
) {
6806+
FunctionPointerObject aFunc = a.getFunctionPointer();
6807+
FunctionPointerObject bFunc = b.getFunctionPointer();
6808+
6809+
DataObject retA = interpreter.callFunctionPointer(aFunc, a.getVariableName(), Arrays.asList(
6810+
c
6811+
), SCOPE_ID);
6812+
retA = LangUtils.nullToLangVoid(retA);
6813+
6814+
if(retA.getType() != DataType.FUNCTION_POINTER)
6815+
return interpreter.setErrnoErrorObject(InterpretingError.INVALID_FUNC_PTR, "The value returned by a(c) must be of type " + DataType.FUNCTION_POINTER, SCOPE_ID);
6816+
6817+
FunctionPointerObject retAFunc = retA.getFunctionPointer();
6818+
6819+
DataObject retB = interpreter.callFunctionPointer(bFunc, b.getVariableName(), Arrays.asList(
6820+
d
6821+
), SCOPE_ID);
6822+
6823+
return interpreter.callFunctionPointer(retAFunc, retA.getVariableName(), Arrays.asList(
6824+
LangUtils.nullToLangVoid(retB)
67956825
), SCOPE_ID);
67966826
}
67976827

0 commit comments

Comments
 (0)