From ce8e34b16ae6eb08577710ec523f6097069c623d Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Fri, 6 Aug 2021 11:03:16 +0200 Subject: [PATCH] Fixed problem with automatic C-file loading included the same file twice. Closes #697 --- .../cache/fragment-cache-csg65ce02.asm | 2 +- .../cache/fragment-cache-mega45gs02.asm | 2 +- .../fragment/cache/fragment-cache-mos6502.asm | 2 +- .../cache/fragment-cache-mos6502x.asm | 42 +++++++++---------- .../cache/fragment-cache-rom6502x.asm | 2 +- .../cache/fragment-cache-wdc65c02.asm | 2 +- .../dk/camelot64/kickc/parser/CParser.java | 11 ++--- 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/main/fragment/cache/fragment-cache-csg65ce02.asm b/src/main/fragment/cache/fragment-cache-csg65ce02.asm index 9ffd711ea..1f61ee73d 100644 --- a/src/main/fragment/cache/fragment-cache-csg65ce02.asm +++ b/src/main/fragment/cache/fragment-cache-csg65ce02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 +//KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac //FRAGMENT vbuzz=vbuc1 ldz #{c1} //FRAGMENT vbuzz_lt_vbuc1_then_la1 diff --git a/src/main/fragment/cache/fragment-cache-mega45gs02.asm b/src/main/fragment/cache/fragment-cache-mega45gs02.asm index a5f84b485..842b16f42 100644 --- a/src/main/fragment/cache/fragment-cache-mega45gs02.asm +++ b/src/main/fragment/cache/fragment-cache-mega45gs02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 +//KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac //FRAGMENT _deref_pbuc1=vbuc2 lda #{c2} sta {c1} diff --git a/src/main/fragment/cache/fragment-cache-mos6502.asm b/src/main/fragment/cache/fragment-cache-mos6502.asm index 4248b5c82..e238a1ebe 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 +//KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} diff --git a/src/main/fragment/cache/fragment-cache-mos6502x.asm b/src/main/fragment/cache/fragment-cache-mos6502x.asm index 4642d9c3f..0649d07fd 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502x.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502x.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 +//KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} @@ -3594,6 +3594,26 @@ sta {z1}+1 //FRAGMENT vwuz1=vwuz1_rol_1 asl {z1} 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 sec lda {c1} @@ -8688,18 +8708,6 @@ tax lda {c1} eor #$ff 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 ldy #{c1} lda ({z2}),y @@ -8707,14 +8715,6 @@ 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 _deref_pwsc1=vwsc2 lda #<{c2} sta {c1} diff --git a/src/main/fragment/cache/fragment-cache-rom6502x.asm b/src/main/fragment/cache/fragment-cache-rom6502x.asm index 563f7b2f2..a8adb08c2 100644 --- a/src/main/fragment/cache/fragment-cache-rom6502x.asm +++ b/src/main/fragment/cache/fragment-cache-rom6502x.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 +//KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac //FRAGMENT _deref_pbuc1=_inc__deref_pbuc1 inc {c1} //FRAGMENT isr_hardware_all_entry diff --git a/src/main/fragment/cache/fragment-cache-wdc65c02.asm b/src/main/fragment/cache/fragment-cache-wdc65c02.asm index ce1d1b8f8..17b50115a 100644 --- a/src/main/fragment/cache/fragment-cache-wdc65c02.asm +++ b/src/main/fragment/cache/fragment-cache-wdc65c02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 81e098389 81e09a3d7 +//KICKC FRAGMENT CACHE 81bc8cd4f 81bc8edac //FRAGMENT vbuz1=_deref_pbuc1 lda {c1} sta {z1} diff --git a/src/main/java/dk/camelot64/kickc/parser/CParser.java b/src/main/java/dk/camelot64/kickc/parser/CParser.java index 3a8f1634b..f23dadd2f 100644 --- a/src/main/java/dk/camelot64/kickc/parser/CParser.java +++ b/src/main/java/dk/camelot64/kickc/parser/CParser.java @@ -228,19 +228,20 @@ public class CParser { return null; else throw new CompileError("File not found " + fileName); + Path filePath = file.toPath().toAbsolutePath().normalize(); List included = program.getLoadedFiles(); - if(included.contains(file.getAbsolutePath())) { + if(included.contains(filePath.toString())) { return null; } - final CharStream fileStream = CharStreams.fromPath(file.toPath().toAbsolutePath()); - included.add(file.getAbsolutePath()); + final CharStream fileStream = CharStreams.fromPath(filePath); + included.add(filePath.toString()); if(program.getLog().isVerboseParse()) { - program.getLog().append("PARSING " + file.getPath().replace("\\", "/")); + program.getLog().append("PARSING " + filePath.toString().replace("\\", "/")); program.getLog().append(fileStream.toString()); } KickCLexer lexer = makeLexer(fileStream); CFile cFile = new CFile(file, lexer); - cFiles.put(file.getAbsolutePath(), cFile); + cFiles.put(filePath.toString(), cFile); return lexer; } catch(IOException e) { throw new CompileError("Error parsing file " + fileName, e);