JIO subclasses, java.lang.Runnable integration

This commit is contained in:
Daniella / Tove 2022-05-23 08:32:05 +02:00
parent ff2561043a
commit 1421317515

View file

@ -1126,6 +1126,14 @@ public class ISBPL {
for(Class<?> c : interfaces) {
type.superTypes.add(toISBPL(c).type);
}
for (Class<?> subclass : clazz.getDeclaredClasses()) {
addFunction(type, subclass.getSimpleName(), stack -> {
if(debug)
ISBPL.gErrorStream.println("Java GetSubclass: " + subclass.getName());
stack.pop();
stack.push(toISBPL(subclass));
});
}
if (clazz.isEnum()) {
for (Object o : clazz.getEnumConstants()) {
addFunction(type, o.toString(), stack -> {
@ -1342,6 +1350,11 @@ public class ISBPL {
if(expectedType == byte.class)
return (byte) o.toLong();
}
if(expectedType == Runnable.class) {
return (Runnable) () -> {
((ISBPLCallable) o.object).call(new ISBPLStack<>());
};
}
if(!expectedType.isAssignableFrom(o.object.getClass()))
typeError(o.type.name, expectedType.getName());
return o.object;