fix primitive types

This commit is contained in:
Daniella / Tove 2022-04-25 04:42:30 +02:00
parent 120e827d32
commit 0ba0a20b99

View file

@ -1126,10 +1126,28 @@ public class ISBPL {
else
typeError("array", "matching-array");
for (int i = 0 ; i < isbplArray.length ; i++) {
Array.set(array, i, fromISBPL(isbplArray[i]));
Array.set(array, i, fromISBPL(isbplArray[i], expectedType.getComponentType()));
}
return array;
}
if(expectedType.isPrimitive()) {
if(expectedType == long.class)
return o.toLong();
if(expectedType == int.class)
return (int) o.toLong();
if(expectedType == double.class)
return o.toDouble();
if(expectedType == float.class)
return (float) o.toDouble();
if(expectedType == short.class)
return (short) o.toLong();
if(expectedType == boolean.class)
return o.isTruthy();
if(expectedType == char.class)
return (char) o.toLong();
if(expectedType == byte.class)
return (byte) o.toLong();
}
if(!expectedType.isAssignableFrom(o.object.getClass()))
typeError(o.type.name, expectedType.getName());
return o.object;