mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-06 00:33:42 +00:00
Fixed 2/3. One remaining!
This commit is contained in:
parent
c42156c4e9
commit
999afdcbc7
@ -54,9 +54,22 @@ public class PassNFinalizeNumberTypeConversions extends Pass2SsaOptimization {
|
||||
constantCastValue.setToType(smallestUnsigned);
|
||||
}
|
||||
}
|
||||
} else if(SymbolType.SNUMBER.equals(toType)) {
|
||||
if(constantCastValue.getValue() instanceof ConstantRef) {
|
||||
ConstantRef constRef = (ConstantRef) constantCastValue.getValue();
|
||||
ConstantVar constant = getScope().getConstant(constRef);
|
||||
if(constant.isInferredType())
|
||||
constant.setTypeInferred(toType);
|
||||
else
|
||||
throw new InternalError("Cannot cast declared type!" + constant.toString());
|
||||
} else {
|
||||
ConstantLiteral constantLiteral = constantCastValue.getValue().calculateLiteral(getProgram().getScope());
|
||||
SymbolType smallestSigned = SymbolTypeConversion.getSmallestSignedFixedIntegerType(constantLiteral, getScope());
|
||||
if(smallestSigned!=null) {
|
||||
constantCastValue.setToType(smallestSigned);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(SymbolType.SNUMBER.equals(toType))
|
||||
throw new InternalError("TODO: Finalize ConstantCast");
|
||||
}
|
||||
});
|
||||
return modified.get();
|
||||
|
Loading…
Reference in New Issue
Block a user