1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Added two string problems (local & inline) to error-test-cases.

This commit is contained in:
jespergravgaard 2017-11-26 21:46:53 +01:00
parent ae167736d4
commit 0d622f978c
4 changed files with 34 additions and 3 deletions

View File

@ -124,9 +124,9 @@ public class AsmFragmentManager {
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|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)_(as?by)", ".*=as?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|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("xsby=(.*)", null, null, "asby=$1", "tax\n", null));

View File

@ -24,6 +24,14 @@ public class TestErrors extends TestCase {
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 {
compileAndCompare("print");
}

View 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;
}
}

View 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];
}
}