add api for adding more supported natives

This commit is contained in:
Daniella / Tove 2022-03-14 17:17:58 +01:00
parent d886280f10
commit 8fd3d6b8c4

View file

@ -24,12 +24,13 @@ public class ISBPL {
int exitCode;
private final ISBPLStreamer streamer = new ISBPLStreamer(this);
ArrayList<String> included = new ArrayList<>();
HashMap<String, ISBPLCallable> natives = new HashMap<>();
public ISBPL() {
functionStack.get().push(new HashMap<>());
}
public ISBPLKeyword getKeyword(String word) {
private ISBPLKeyword getKeyword(String word) {
switch (word) {
case "native":
return (idx, words, file, stack) -> {
@ -140,7 +141,7 @@ public class ISBPL {
try {
block.call(file, s);
} catch (ISBPLStop stop) {
if(stop.amount < 0) {
if(stop.amount == -1) {
System.exit(exitCode);
}
}
@ -823,6 +824,9 @@ public class ISBPL {
stack.push(new ISBPLObject(getType("int"), stack.size()));
};
break;
default:
func = natives.get(name);
break;
}
functionStack.get().peek().put(name, func);
}