From c24642493051161d7916016a2c373d683d63f779 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Mon, 15 Apr 2019 17:35:17 +0100 Subject: [PATCH] Fix bug raising InconsistentExitError, and type-bug in ribos2.60p. --- eg/c64/ribos/ribos2.60p | 5 ++- src/sixtypical/analyzer.py | 6 +-- tests/SixtyPical Analysis.md | 78 +++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/eg/c64/ribos/ribos2.60p b/eg/c64/ribos/ribos2.60p index ee86006..0f8a361 100644 --- a/eg/c64/ribos/ribos2.60p +++ b/eg/c64/ribos/ribos2.60p @@ -50,8 +50,9 @@ byte scanline : 85 // %01010101 // be practical. So we just jump to this location instead. define pla_tay_pla_tax_pla_rti routine - inputs a - trashes a + inputs border_color, vic_intr + outputs border_color, vic_intr + trashes a, z, n, c @ $EA81 // ----- Interrupt Handler ----- diff --git a/src/sixtypical/analyzer.py b/src/sixtypical/analyzer.py index 7008cdb..197b68c 100644 --- a/src/sixtypical/analyzer.py +++ b/src/sixtypical/analyzer.py @@ -481,11 +481,11 @@ class Analyzer(object): exit_writeable = set(exit_context.each_writeable()) for ex in self.exit_contexts[1:]: if set(ex.each_meaningful()) != exit_meaningful: - raise InconsistentExitError("Exit contexts are not consistent") + raise InconsistentExitError(routine, "Exit contexts are not consistent") if set(ex.each_touched()) != exit_touched: - raise InconsistentExitError("Exit contexts are not consistent") + raise InconsistentExitError(routine, "Exit contexts are not consistent") if set(ex.each_writeable()) != exit_writeable: - raise InconsistentExitError("Exit contexts are not consistent") + raise InconsistentExitError(routine, "Exit contexts are not consistent") # We now set the main context to the (consistent) exit context # so that this routine is perceived as having the same effect diff --git a/tests/SixtyPical Analysis.md b/tests/SixtyPical Analysis.md index 89ae302..040f48f 100644 --- a/tests/SixtyPical Analysis.md +++ b/tests/SixtyPical Analysis.md @@ -3921,7 +3921,83 @@ Here is like the above, but the two routines have different inputs, and that's O | } = ok -TODO: we should have a lot more test cases for the above, here. +Another inconsistent exit test, this one based on "real" code +(the `ribos2` demo). + + | typedef routine + | inputs border_color, vic_intr + | outputs border_color, vic_intr + | trashes a, z, n, c + | irq_handler + | + | vector irq_handler cinv @ $314 + | vector irq_handler saved_irq_vec + | byte vic_intr @ $d019 + | byte border_color @ $d020 + | + | define pla_tay_pla_tax_pla_rti routine + | inputs a + | trashes a + | @ $EA81 + | + | define our_service_routine irq_handler + | { + | ld a, vic_intr + | st a, vic_intr + | and a, 1 + | cmp a, 1 + | if not z { + | goto saved_irq_vec + | } else { + | ld a, border_color + | xor a, $ff + | st a, border_color + | goto pla_tay_pla_tax_pla_rti + | } + | } + | + | define main routine + | { + | } + ? InconsistentExitError + + | typedef routine + | inputs border_color, vic_intr + | outputs border_color, vic_intr + | trashes a, z, n, c + | irq_handler + | + | vector irq_handler cinv @ $314 + | vector irq_handler saved_irq_vec + | byte vic_intr @ $d019 + | byte border_color @ $d020 + | + | define pla_tay_pla_tax_pla_rti routine + | inputs border_color, vic_intr + | outputs border_color, vic_intr + | trashes a, z, n, c + | @ $EA81 + | + | define our_service_routine irq_handler + | { + | ld a, vic_intr + | st a, vic_intr + | and a, 1 + | cmp a, 1 + | if not z { + | goto saved_irq_vec + | } else { + | ld a, border_color + | xor a, $ff + | st a, border_color + | goto pla_tay_pla_tax_pla_rti + | } + | } + | + | define main routine + | { + | } + = ok Can't `goto` a routine that outputs or trashes more than the current routine.