add def native

This commit is contained in:
Daniella / Tove 2022-04-12 16:43:51 +02:00
parent 645a78bead
commit 95da50a02a
2 changed files with 14 additions and 0 deletions

View file

@ -15,6 +15,10 @@ import java.util.function.Supplier;
*/
public class ISBPL {
// TODO: fully implement JIO
// public static final boolean ENABLE_JINTEROP = true;
static boolean debug = false;
public ISBPLDebugger.IPC debuggerIPC = new ISBPLDebugger.IPC();
ArrayList<ISBPLType> types = new ArrayList<>();
@ -846,6 +850,15 @@ public class ISBPL {
}
};
break;
case "def":
func = (stack) -> {
ISBPLObject str = stack.pop();
ISBPLObject callable = stack.pop();
String s = toJavaString(str);
callable.checkType(getType("func"));
addFunction(s, (ISBPLCallable) callable.object);
};
break;
default:
func = natives.get(name);
break;

View file

@ -64,6 +64,7 @@ native %
native ^
native fcall
native def
func ++ { 1 + }
func -- { 1 - }