From 4fbaf943dd177b854db571d7e603baea07d87769 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 17 May 2022 13:22:45 +0200 Subject: [PATCH] merge, fix a few JIO bugs --- ISBPL.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ISBPL.java b/ISBPL.java index 05dac15..bc72ccf 100644 --- a/ISBPL.java +++ b/ISBPL.java @@ -1106,7 +1106,7 @@ public class ISBPL { if(debug) ISBPL.gErrorStream.println("Java Get: " + field); try { - stack.push(toISBPL(field.get(stack.pop().object))); + stack.push(toISBPL(field.get(fromISBPL(stack.pop(), clazz)))); } catch (IllegalAccessException ignored) { } @@ -1116,7 +1116,7 @@ public class ISBPL { if(debug) ISBPL.gErrorStream.println("Java Set: " + field); try { - field.set(stack.pop().object, fromISBPL(stack.pop(), field.getType())); + field.set(fromISBPL(stack.pop(), clazz), fromISBPL(stack.pop(), field.getType())); } catch (IllegalAccessException ignored) { } @@ -1132,7 +1132,7 @@ public class ISBPL { } for (Map.Entry> entry : methods.entrySet()) { addFunction(type, entry.getKey(), stack -> { - Object o = stack.pop().object; + Object o = fromISBPL(stack.pop(), clazz); // Resolve AtomicInteger mid = new AtomicInteger(0); ArrayList ms = entry.getValue(); @@ -1266,9 +1266,10 @@ public class ISBPL { public Object fromISBPL(ISBPLObject o, Class expectedType) { ISBPLType type = o.type; - if (type.equals(getType("null"))) { + if (type.equals(getType("null"))) + return null; + if(o.object == null) return null; - } if (type.equals(getType("string"))) { if(expectedType.isAssignableFrom(String.class)) return toJavaString(o); @@ -1345,7 +1346,7 @@ public class ISBPL { public void addFunction(ISBPLType type, String name, ISBPLCallable callable) { type.methods.put(name, callable); - type.methods.put("&" + name, stack -> stack.push(new ISBPLObject(getType("func"), callable))); + type.methods.put("&" + name, stack -> {stack.pop(); stack.push(new ISBPLObject(getType("func"), callable)); }); } private String getFilePathForInclude(Stack stack, Stack file) {