mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
C backend: fix bug in type inference, fix code generation for small int and long values
This commit is contained in:
parent
4530167061
commit
899725b6bd
|
@ -30,15 +30,22 @@ public final class CodeGeneratorUtil {
|
|||
} else if (value instanceof Integer) {
|
||||
int i = (Integer) value;
|
||||
long v = i;
|
||||
if (i == Integer.MIN_VALUE) {
|
||||
writer.print("(int32_t) INT32_C(0x80000000)");
|
||||
} else {
|
||||
if (i < 0) {
|
||||
writer.print("-");
|
||||
v = -i;
|
||||
v = -v;
|
||||
}
|
||||
writer.print("INT32_C(");
|
||||
writeLongConstant(writer, v);
|
||||
writer.print(")");
|
||||
}
|
||||
} else if (value instanceof Long) {
|
||||
long v = (Long) value;
|
||||
if (v == Long.MIN_VALUE) {
|
||||
writer.print("(int64_t) INT64_C(0x8000000000000000)");
|
||||
} else {
|
||||
if (v < 0) {
|
||||
writer.print("-");
|
||||
v = -v;
|
||||
|
@ -46,6 +53,7 @@ public final class CodeGeneratorUtil {
|
|||
writer.print("INT64_C(");
|
||||
writeLongConstant(writer, v);
|
||||
writer.print(")");
|
||||
}
|
||||
} else if (value instanceof Float) {
|
||||
float f = (Float) value;
|
||||
if (Float.isInfinite(f)) {
|
||||
|
|
|
@ -90,7 +90,8 @@ public class TypeInferer {
|
|||
}
|
||||
|
||||
public VariableType typeOf(int variableIndex) {
|
||||
return types[variableIndex];
|
||||
VariableType result = types[variableIndex];
|
||||
return result != null ? result : VariableType.OBJECT;
|
||||
}
|
||||
|
||||
VariableType convert(ValueType type) {
|
||||
|
@ -183,11 +184,6 @@ public class TypeInferer {
|
|||
types[receiver.getIndex()] = VariableType.OBJECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nullConstant(VariableReader receiver) {
|
||||
types[receiver.getIndex()] = VariableType.OBJECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nullCheck(VariableReader receiver, VariableReader value) {
|
||||
builder.addEdge(value.getIndex(), receiver.getIndex());
|
||||
|
|
Loading…
Reference in New Issue
Block a user