1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-16 21:07:56 +00:00

Fixed problem with automatic C-file loading included the same file twice. Closes #697

This commit is contained in:
jespergravgaard 2021-08-06 11:03:16 +02:00
parent f01db23d0d
commit ce8e34b16a
7 changed files with 32 additions and 31 deletions

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 //KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac
//FRAGMENT vbuzz=vbuc1 //FRAGMENT vbuzz=vbuc1
ldz #{c1} ldz #{c1}
//FRAGMENT vbuzz_lt_vbuc1_then_la1 //FRAGMENT vbuzz_lt_vbuc1_then_la1

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 //KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac
//FRAGMENT _deref_pbuc1=vbuc2 //FRAGMENT _deref_pbuc1=vbuc2
lda #{c2} lda #{c2}
sta {c1} sta {c1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 //KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac
//FRAGMENT vbuz1=vbuc1 //FRAGMENT vbuz1=vbuc1
lda #{c1} lda #{c1}
sta {z1} sta {z1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 //KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac
//FRAGMENT vbuz1=vbuc1 //FRAGMENT vbuz1=vbuc1
lda #{c1} lda #{c1}
sta {z1} sta {z1}
@ -3594,6 +3594,26 @@ sta {z1}+1
//FRAGMENT vwuz1=vwuz1_rol_1 //FRAGMENT vwuz1=vwuz1_rol_1
asl {z1} asl {z1}
rol {z1}+1 rol {z1}+1
//FRAGMENT pssz1=pssc1
lda #<{c1}
sta {z1}
lda #>{c1}
sta {z1}+1
//FRAGMENT pbuz1=qbuz2_derefidx_vbuc1
ldy #{c1}
lda ({z2}),y
sta {z1}
iny
lda ({z2}),y
sta {z1}+1
//FRAGMENT pssz1=pssz1_plus_vbuc1
lda #{c1}
clc
adc {z1}
sta {z1}
bcc !+
inc {z1}+1
!:
//FRAGMENT vwuz1=_deref_pwuc1_minus_vwuc2 //FRAGMENT vwuz1=_deref_pwuc1_minus_vwuc2
sec sec
lda {c1} lda {c1}
@ -8688,18 +8708,6 @@ tax
lda {c1} lda {c1}
eor #$ff eor #$ff
tay tay
//FRAGMENT pssz1=pssc1
lda #<{c1}
sta {z1}
lda #>{c1}
sta {z1}+1
//FRAGMENT pbuz1=qbuz2_derefidx_vbuc1
ldy #{c1}
lda ({z2}),y
sta {z1}
iny
lda ({z2}),y
sta {z1}+1
//FRAGMENT vwuz1=pwuz2_derefidx_vbuc1 //FRAGMENT vwuz1=pwuz2_derefidx_vbuc1
ldy #{c1} ldy #{c1}
lda ({z2}),y lda ({z2}),y
@ -8707,14 +8715,6 @@ sta {z1}
iny iny
lda ({z2}),y lda ({z2}),y
sta {z1}+1 sta {z1}+1
//FRAGMENT pssz1=pssz1_plus_vbuc1
lda #{c1}
clc
adc {z1}
sta {z1}
bcc !+
inc {z1}+1
!:
//FRAGMENT _deref_pwsc1=vwsc2 //FRAGMENT _deref_pwsc1=vwsc2
lda #<{c2} lda #<{c2}
sta {c1} sta {c1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 //KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac
//FRAGMENT _deref_pbuc1=_inc__deref_pbuc1 //FRAGMENT _deref_pbuc1=_inc__deref_pbuc1
inc {c1} inc {c1}
//FRAGMENT isr_hardware_all_entry //FRAGMENT isr_hardware_all_entry

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 //KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac
//FRAGMENT vbuz1=_deref_pbuc1 //FRAGMENT vbuz1=_deref_pbuc1
lda {c1} lda {c1}
sta {z1} sta {z1}

View File

@ -228,19 +228,20 @@ public class CParser {
return null; return null;
else else
throw new CompileError("File not found " + fileName); throw new CompileError("File not found " + fileName);
Path filePath = file.toPath().toAbsolutePath().normalize();
List<String> included = program.getLoadedFiles(); List<String> included = program.getLoadedFiles();
if(included.contains(file.getAbsolutePath())) { if(included.contains(filePath.toString())) {
return null; return null;
} }
final CharStream fileStream = CharStreams.fromPath(file.toPath().toAbsolutePath()); final CharStream fileStream = CharStreams.fromPath(filePath);
included.add(file.getAbsolutePath()); included.add(filePath.toString());
if(program.getLog().isVerboseParse()) { if(program.getLog().isVerboseParse()) {
program.getLog().append("PARSING " + file.getPath().replace("\\", "/")); program.getLog().append("PARSING " + filePath.toString().replace("\\", "/"));
program.getLog().append(fileStream.toString()); program.getLog().append(fileStream.toString());
} }
KickCLexer lexer = makeLexer(fileStream); KickCLexer lexer = makeLexer(fileStream);
CFile cFile = new CFile(file, lexer); CFile cFile = new CFile(file, lexer);
cFiles.put(file.getAbsolutePath(), cFile); cFiles.put(filePath.toString(), cFile);
return lexer; return lexer;
} catch(IOException e) { } catch(IOException e) {
throw new CompileError("Error parsing file " + fileName, e); throw new CompileError("Error parsing file " + fileName, e);