Open
Description
Eclipse does not complain about this code:
float foo[10];
foo[0] := 0;
This code fails when executed with the Orcc simulator
caused by: net.sf.orcc.OrccRuntimeException: unexpected type in set
at net.sf.orcc.ir.util.ValueUtil.set(ValueUtil.java:889)
Because the simulator type checks the element type in CAL with the actual type of the value, at runtime (see here )
if (type.isBool() && isBool(value) || type.isString()
&& isString(value)) {
valueToSet = value;
} else if (type.isFloat() && isFloat(value)) {
BigDecimal floatVal = (BigDecimal) value;
valueToSet = floatVal.floatValue();
} else if ((type.isInt() || type.isUint()) && isInt(value)) {
BigInteger intVal = (BigInteger) value;
int size = type.getSizeInBits();
if (size <= 8) {
valueToSet = intVal.byteValue();
} else if (size <= 16) {
valueToSet = intVal.shortValue();
} else if (size <= 32) {
valueToSet = intVal.intValue();
} else if (size <= 64) {
valueToSet = intVal.longValue();
} else {
valueToSet = value;
}
} else {
throw new OrccRuntimeException("unexpected type in set");
}
Would it be better to avoid this, by enforcing 4F66 these checks within the frontend Eclipse editor?
Metadata
Metadata
Assignees
Labels
No labels