mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-08-09 04:25:12 +00:00
Added two string problems (local & inline) to error-test-cases.
This commit is contained in:
@@ -124,9 +124,9 @@ public class AsmFragmentManager {
|
|||||||
|
|
||||||
List<FragmentSynthesis> synths = new ArrayList<>();
|
List<FragmentSynthesis> synths = new ArrayList<>();
|
||||||
|
|
||||||
synths.add(new FragmentSynthesis("(.*)=(.*)_(band|bor|plus)_(as?by)", ".*=as?by_.*", null, "$1=$4_$3_$2", null, null));
|
synths.add(new FragmentSynthesis("(.*)=(.*)_(band|bor|bxor|plus)_(as?by)", ".*=as?by_.*", null, "$1=$4_$3_$2", null, null));
|
||||||
synths.add(new FragmentSynthesis("(.*)=(.*)_(band|bor|plus)_(xs?by)", ".*=[xa]s?by_.*", null, "$1=$4_$3_$2", null, null));
|
synths.add(new FragmentSynthesis("(.*)=(.*)_(band|bor|bxor|plus)_(xs?by)", ".*=[xa]s?by_.*", null, "$1=$4_$3_$2", null, null));
|
||||||
synths.add(new FragmentSynthesis("(.*)=(.*)_(band|bor|plus)_(ys?by)", ".*=[axy]s?by_.*", null, "$1=$4_$3_$2", null, null));
|
synths.add(new FragmentSynthesis("(.*)=(.*)_(band|bor|bxor|plus)_(ys?by)", ".*=[axy]s?by_.*", null, "$1=$4_$3_$2", null, null));
|
||||||
|
|
||||||
synths.add(new FragmentSynthesis("xby=(.*)", null, null, "aby=$1", "tax\n", null));
|
synths.add(new FragmentSynthesis("xby=(.*)", null, null, "aby=$1", "tax\n", null));
|
||||||
synths.add(new FragmentSynthesis("xsby=(.*)", null, null, "asby=$1", "tax\n", null));
|
synths.add(new FragmentSynthesis("xsby=(.*)", null, null, "asby=$1", "tax\n", null));
|
||||||
|
@@ -24,6 +24,14 @@ public class TestErrors extends TestCase {
|
|||||||
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
|
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testLocalString() throws IOException, URISyntaxException {
|
||||||
|
compileAndCompare("local-string");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testInlineString() throws IOException, URISyntaxException {
|
||||||
|
compileAndCompare("inline-string");
|
||||||
|
}
|
||||||
|
|
||||||
public void testPrint() throws IOException, URISyntaxException {
|
public void testPrint() throws IOException, URISyntaxException {
|
||||||
compileAndCompare("print");
|
compileAndCompare("print");
|
||||||
}
|
}
|
||||||
|
14
src/main/java/dk/camelot64/kickc/test/inline-string.kc
Normal file
14
src/main/java/dk/camelot64/kickc/test/inline-string.kc
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// Inline Strings in method calls are attempted inlined all the way to ASM. This creates error during binding. Instead a local constant byte[] st = "..."; variable should be created (generating an ASM .text).
|
||||||
|
|
||||||
|
byte* screen = $0400;
|
||||||
|
byte[] msg1 = "message 1 @";
|
||||||
|
void main() {
|
||||||
|
print(msg1);
|
||||||
|
print("message 2 @");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(byte* msg) {
|
||||||
|
while(*msg!='@') {
|
||||||
|
*(screen++) = *msg;
|
||||||
|
}
|
||||||
|
}
|
9
src/main/java/dk/camelot64/kickc/test/local-string.kc
Normal file
9
src/main/java/dk/camelot64/kickc/test/local-string.kc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// Local constant strings are placed at the start of the method. This means the generated ASM jumps / calls straignt into the constant string
|
||||||
|
void main() {
|
||||||
|
byte* screen = $0400;
|
||||||
|
byte[] msg = "message 2 @";
|
||||||
|
byte i=0;
|
||||||
|
while(msg[i]!='@') {
|
||||||
|
screen[i++] = msg[i];
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user