From 0f3da0ea3ee86886f1c289ee88bd48e028656811 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 31 May 2017 01:12:23 +0200 Subject: [PATCH] Fixed bresenham array again --- .../kickc/asm/fragment/ptr_cowo1_zpwo1=coby2.asm | 9 +++++++++ src/dk/camelot64/kickc/icl/PassTypeInference.java | 5 +++++ src/dk/camelot64/kickc/test/Main.java | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/dk/camelot64/kickc/asm/fragment/ptr_cowo1_zpwo1=coby2.asm diff --git a/src/dk/camelot64/kickc/asm/fragment/ptr_cowo1_zpwo1=coby2.asm b/src/dk/camelot64/kickc/asm/fragment/ptr_cowo1_zpwo1=coby2.asm new file mode 100644 index 000000000..8eb348269 --- /dev/null +++ b/src/dk/camelot64/kickc/asm/fragment/ptr_cowo1_zpwo1=coby2.asm @@ -0,0 +1,9 @@ +lda #<{cowo1} +clc +adc {zpwo1} +sta !s+ +1 +lda #>{cowo1} +adc {zpwo1}+1 +sta !s+ +2 +lda #{coby2} +!s: sta {cowo1} diff --git a/src/dk/camelot64/kickc/icl/PassTypeInference.java b/src/dk/camelot64/kickc/icl/PassTypeInference.java index baf21fdae..8537b45fc 100644 --- a/src/dk/camelot64/kickc/icl/PassTypeInference.java +++ b/src/dk/camelot64/kickc/icl/PassTypeInference.java @@ -88,6 +88,11 @@ public class PassTypeInference { if(type1==null && type2 instanceof SymbolTypePointer) { return ((SymbolTypePointer) type2).getElementType(); } + if (SymbolTypeBasic.WORD.equals(type1) || SymbolTypeBasic.WORD.equals(type2)) { + return SymbolTypeBasic.WORD; + } else if (SymbolTypeBasic.BYTE.equals(type1) && SymbolTypeBasic.BYTE.equals(type2)) { + return SymbolTypeBasic.BYTE; + } throw new RuntimeException("Type inference case not handled " + type1 + " " + operator + " " + type2); case "/": if (SymbolTypeBasic.WORD.equals(type1) || SymbolTypeBasic.WORD.equals(type2)) { diff --git a/src/dk/camelot64/kickc/test/Main.java b/src/dk/camelot64/kickc/test/Main.java index 256b2d426..28eea3a9a 100644 --- a/src/dk/camelot64/kickc/test/Main.java +++ b/src/dk/camelot64/kickc/test/Main.java @@ -13,7 +13,7 @@ import java.util.List; /** Test my KickC Grammar */ public class Main { public static void main(String[] args) throws IOException { - final String fileName = "src/dk/camelot64/kickc/test/sprtabs.kc"; + final String fileName = "src/dk/camelot64/kickc/test/bresenhamarr.kc"; final CharStream input = CharStreams.fromFileName(fileName); System.out.println(input.toString()); KickCLexer lexer = new KickCLexer(input);