add api for adding more supported natives
This commit is contained in:
parent
d886280f10
commit
8fd3d6b8c4
1 changed files with 6 additions and 2 deletions
|
@ -24,12 +24,13 @@ public class ISBPL {
|
||||||
int exitCode;
|
int exitCode;
|
||||||
private final ISBPLStreamer streamer = new ISBPLStreamer(this);
|
private final ISBPLStreamer streamer = new ISBPLStreamer(this);
|
||||||
ArrayList<String> included = new ArrayList<>();
|
ArrayList<String> included = new ArrayList<>();
|
||||||
|
HashMap<String, ISBPLCallable> natives = new HashMap<>();
|
||||||
|
|
||||||
public ISBPL() {
|
public ISBPL() {
|
||||||
functionStack.get().push(new HashMap<>());
|
functionStack.get().push(new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISBPLKeyword getKeyword(String word) {
|
private ISBPLKeyword getKeyword(String word) {
|
||||||
switch (word) {
|
switch (word) {
|
||||||
case "native":
|
case "native":
|
||||||
return (idx, words, file, stack) -> {
|
return (idx, words, file, stack) -> {
|
||||||
|
@ -140,7 +141,7 @@ public class ISBPL {
|
||||||
try {
|
try {
|
||||||
block.call(file, s);
|
block.call(file, s);
|
||||||
} catch (ISBPLStop stop) {
|
} catch (ISBPLStop stop) {
|
||||||
if(stop.amount < 0) {
|
if(stop.amount == -1) {
|
||||||
System.exit(exitCode);
|
System.exit(exitCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -823,6 +824,9 @@ public class ISBPL {
|
||||||
stack.push(new ISBPLObject(getType("int"), stack.size()));
|
stack.push(new ISBPLObject(getType("int"), stack.size()));
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
func = natives.get(name);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
functionStack.get().peek().put(name, func);
|
functionStack.get().peek().put(name, func);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue