mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-08 13:31:03 +00:00
Minor fixes
This commit is contained in:
parent
6cfa5c750c
commit
17a0db4472
5
src/main/fragment/vwuz1=vbuaa_rol_1.asm
Normal file
5
src/main/fragment/vwuz1=vbuaa_rol_1.asm
Normal file
@ -0,0 +1,5 @@
|
||||
asl
|
||||
sta {z1}
|
||||
lda #0
|
||||
rol
|
||||
sta {z1}+1
|
@ -13,7 +13,7 @@ public class NumberParser {
|
||||
throw new NumberFormatException("Not Implemented: non-integer parsing. " + literal);
|
||||
}
|
||||
|
||||
SymbolType type = null;
|
||||
SymbolType type = SymbolType.NUMBER;
|
||||
if(literal.endsWith("ub") || literal.endsWith("uc")) {
|
||||
type = SymbolType.BYTE;
|
||||
literal = literal.substring(0, literal.length()-2);
|
||||
|
@ -213,7 +213,11 @@ public class SymbolTypeInference {
|
||||
if(type == null) {
|
||||
type = valueType;
|
||||
} else if(!type.equals(valueType))
|
||||
throw new CompileError("Types not compatible " + type + " and " + valueType);
|
||||
if(valueType instanceof SymbolTypeInteger && type instanceof SymbolTypeInteger) {
|
||||
type = SymbolTypeConversion.convertedMathType((SymbolTypeInteger) valueType, (SymbolTypeInteger) type);
|
||||
} else {
|
||||
throw new CompileError("Phi value has type mismatch "+phiRValue.toString() + " not matching type " + type.getTypeName());
|
||||
}
|
||||
}
|
||||
if(!SymbolType.VAR.equals(symbol.getType()) && !type.equals(symbol.getType())) {
|
||||
program.getLog().append("Inferred type updated to " + type + " for " + symbol.toString(program));
|
||||
|
@ -32,6 +32,11 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeInference() throws IOException, URISyntaxException {
|
||||
compileAndCompare("type-inference", log().verboseSSAOptimize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMixedArray1() throws IOException, URISyntaxException {
|
||||
compileAndCompare("mixed-array-1", log());
|
||||
|
@ -47,9 +47,9 @@ byte myprintf(byte *dst, byte *str, word w1, word w2, word w3) {
|
||||
for (digit = 0; digit < b; ++digit) dst[bLen++] = buf6[digit];
|
||||
if (bTrailing != 0 && bDigits > b) for (; bDigits > b; --bDigits) dst[bLen++] = ' ';
|
||||
} else if (b == 'x' || b == 'X'){ // hex
|
||||
b = (w >> 4) & 0xF;
|
||||
b = ((byte)w >> 4) & 0xF;
|
||||
dst[bLen++] = (b < 10 ? '0' : 0x57) + b; // "('a' - 10)" is the normal way -- not supported -- https://gitlab.com/camelot/kickc/issues/184 [FIXED]
|
||||
b = w & 0xF; dst[bLen++] = (b < 10 ? '0' : 0x57) + b;
|
||||
b = (byte)w & 0xF; dst[bLen++] = (b < 10 ? '0' : 0x57) + b;
|
||||
}
|
||||
bFormat = 0;
|
||||
continue;
|
||||
|
9
src/test/kc/type-inference.kc
Normal file
9
src/test/kc/type-inference.kc
Normal file
@ -0,0 +1,9 @@
|
||||
// Test inference of integer types in expressions
|
||||
|
||||
void main() {
|
||||
const word* screen = 0x0400;
|
||||
for( byte b: 0..20) {
|
||||
screen[b] = -0x30+b;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user