1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-29 03:51:35 +00:00

Fix table access bug where index wasn't required to be initialized.

This commit is contained in:
Chris Pressey 2018-02-05 12:35:19 +00:00
parent 11d6c08369
commit 20c824743e
3 changed files with 44 additions and 2 deletions

View File

@ -8,6 +8,7 @@ History of SixtyPical
* Initialized `byte table` values need not have all 256 bytes initialized. * Initialized `byte table` values need not have all 256 bytes initialized.
* Constraints for `vector` type come immediately after the type, not the variable. * Constraints for `vector` type come immediately after the type, not the variable.
* `vector table` storage, and ability to copy vectors in and out of same. * `vector table` storage, and ability to copy vectors in and out of same.
* Fixed bug where index register wasn't required to be initialized before table access.
0.10 0.10
---- ----

View File

@ -238,6 +238,7 @@ class Analyzer(object):
raise TypeMismatchError('%s and %s in %s' % raise TypeMismatchError('%s and %s in %s' %
(src.name, dest.name, self.current_routine.name) (src.name, dest.name, self.current_routine.name)
) )
context.assert_meaningful(instr.index)
elif src.type != dest.type: elif src.type != dest.type:
raise TypeMismatchError('%s and %s in %s' % raise TypeMismatchError('%s and %s in %s' %
(src.name, dest.name, self.current_routine.name) (src.name, dest.name, self.current_routine.name)
@ -250,6 +251,7 @@ class Analyzer(object):
pass pass
else: else:
raise TypeMismatchError((src, dest)) raise TypeMismatchError((src, dest))
context.assert_meaningful(instr.index)
elif src.type != dest.type: elif src.type != dest.type:
raise TypeMismatchError('%s and %s in %s' % raise TypeMismatchError('%s and %s in %s' %
(src.name, dest.name, self.current_routine.name) (src.name, dest.name, self.current_routine.name)

View File

@ -240,7 +240,7 @@ Can't `st` a `word` type.
### tables ### ### tables ###
Storing to a table, you must use an index, and vice-versa. Storing to a table, you must use an index.
| byte one | byte one
| byte table[256] many | byte table[256] many
@ -294,7 +294,21 @@ Storing to a table, you must use an index, and vice-versa.
| } | }
= ok = ok
Reading from a table, you must use an index, and vice-versa. The index must be initialized.
| byte one
| byte table[256] many
|
| routine main
| outputs many
| trashes a, x, n, z
| {
| ld a, 0
| st a, many + x
| }
? UnmeaningfulReadError: x
Reading from a table, you must use an index.
| byte one | byte one
| |
@ -346,6 +360,31 @@ Reading from a table, you must use an index, and vice-versa.
| } | }
= ok = ok
| byte table[256] many
|
| routine main
| inputs many
| outputs many
| trashes a, x, n, z
| {
| ld x, 0
| ld a, many + x
| }
= ok
The index must be initialized.
| byte table[256] many
|
| routine main
| inputs many
| outputs many
| trashes a, x, n, z
| {
| ld a, many + x
| }
? UnmeaningfulReadError: x
Copying to and from a word table. Copying to and from a word table.
| word one | word one