mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-27 19:50:10 +00:00
parent
8bbddf5651
commit
ea7df4761f
@ -94,10 +94,12 @@ public class PassNTypeInference extends Pass2SsaOptimization {
|
||||
if(type == null) {
|
||||
type = valueType;
|
||||
} else if(!type.equals(valueType))
|
||||
if(valueType instanceof SymbolTypeInteger && type instanceof SymbolTypeInteger) {
|
||||
if(type.equals(SymbolType.VAR) && valueType!=null) {
|
||||
type = valueType;
|
||||
} else 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());
|
||||
throw new CompileError("Phi value has type mismatch " + rValue.toString() + " not matching type " + type.getTypeName());
|
||||
}
|
||||
}
|
||||
if(!SymbolType.VAR.equals(symbol.getType()) && !type.equals(symbol.getType())) {
|
||||
|
@ -81,11 +81,20 @@ public class TestPrograms {
|
||||
compileAndCompare("string-escapes-0");
|
||||
}
|
||||
|
||||
// TODO: Fix loop head problem!
|
||||
//@Test
|
||||
//public void testLoopheadProblem() throws IOException, URISyntaxException {
|
||||
// compileAndCompare("loophead-problem");
|
||||
//}
|
||||
|
||||
// TODO: Fail with proper error when continue is encountered without a loop
|
||||
/*
|
||||
@Test
|
||||
public void testSwitch3Err() throws IOException, URISyntaxException {
|
||||
compileAndCompare("switch-3-err");
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testSwitch2() throws IOException, URISyntaxException {
|
||||
compileAndCompare("switch-2");
|
||||
@ -331,6 +340,14 @@ public class TestPrograms {
|
||||
compileAndCompare("font-hex-show");
|
||||
}
|
||||
|
||||
// TODO: Fix string not converted to void* properly https://gitlab.com/camelot/kickc/issues/281
|
||||
/*
|
||||
@Test
|
||||
public void testMemcpy1() throws IOException, URISyntaxException {
|
||||
compileAndCompare("memcpy-1", log());
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testMemcpy0() throws IOException, URISyntaxException {
|
||||
compileAndCompare("memcpy-0");
|
||||
@ -1294,6 +1311,14 @@ public class TestPrograms {
|
||||
compileAndCompare("examples/plasma/plasma");
|
||||
}
|
||||
|
||||
// TODO: Fix number type conversion https://gitlab.com/camelot/kickc/issues/199
|
||||
/*
|
||||
@Test
|
||||
public void testTernary4() throws IOException, URISyntaxException {
|
||||
compileAndCompare("ternary-4");
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testTernary3() throws IOException, URISyntaxException {
|
||||
compileAndCompare("ternary-3");
|
||||
|
25
src/test/kc/memcpy-1.kc
Normal file
25
src/test/kc/memcpy-1.kc
Normal file
@ -0,0 +1,25 @@
|
||||
// Test memcpy on strings (
|
||||
|
||||
import "string"
|
||||
|
||||
const char* SCREEN = 0x0400;
|
||||
const char[] CAMELOT = "camelot";
|
||||
|
||||
void main() {
|
||||
// Working memory copy of string
|
||||
char* sc = SCREEN;
|
||||
char* camelot= CAMELOT;
|
||||
for( char i: 0..6) {
|
||||
*sc++ = *camelot++;
|
||||
}
|
||||
char* sc2 = SCREEN+40;
|
||||
char* reigns = "reigns";
|
||||
for( char i: 0..5) {
|
||||
*sc2++ = *reigns++;
|
||||
}
|
||||
|
||||
// Not working
|
||||
memcpy(SCREEN+10, CAMELOT, 7);
|
||||
memcpy(SCREEN+50, "rules", 5);
|
||||
|
||||
}
|
13
src/test/kc/switch-3-err.kc
Normal file
13
src/test/kc/switch-3-err.kc
Normal file
@ -0,0 +1,13 @@
|
||||
// Tests simple switch()-statement - including a continue statement for the enclosing loop
|
||||
|
||||
void main() {
|
||||
char* SCREEN = 0x0400;
|
||||
char b=0;
|
||||
char v64 = 0;
|
||||
switch(v64){
|
||||
case 0: b = 1; break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
SCREEN[0] = b;
|
||||
}
|
13
src/test/kc/ternary-4.kc
Normal file
13
src/test/kc/ternary-4.kc
Normal file
@ -0,0 +1,13 @@
|
||||
// Tests the ternary operator - complex nested conditional operators
|
||||
|
||||
void main() {
|
||||
const char* SCREEN = $400;
|
||||
char i=0;
|
||||
for(char b: 0..3) {
|
||||
for( char v: 0..3) {
|
||||
char x = (b) ? 24 + (v & 2 ? 8 : 13) * 8 : 0;
|
||||
SCREEN[i++] = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user