From 0ba0a20b99c663f7d23be1829dca334a9754bac5 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 25 Apr 2022 04:42:30 +0200 Subject: [PATCH] fix primitive types --- bootstrap/ISBPL.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bootstrap/ISBPL.java b/bootstrap/ISBPL.java index 6c74786..c2c9663 100644 --- a/bootstrap/ISBPL.java +++ b/bootstrap/ISBPL.java @@ -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;