1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-25 23:49:17 +00:00

Check that block-level reserves do not supply initial value.

This commit is contained in:
Cat's Eye Technologies 2014-04-12 12:23:10 +01:00
parent 915b0cfef0
commit 00daec53a7
2 changed files with 43 additions and 7 deletions

View File

@ -123,6 +123,35 @@ Test for many combinations of `reserve` and `assign`.
| }
= True
`reserve` may be block-level.
| routine main {
| reserve byte lives
| lda lives
| }
= True
Block-level declarations are only visible in the block in which they are
declared.
| routine main {
| reserve byte lives
| lda #3
| sta lives
| }
| routine died {
| dec lives
| }
? undeclared location 'lives'
A block-level `reserve` may not supply an initial value.
| routine main {
| reserve byte lives : 3
| lda lives
| }
? block-level 'lives' cannot supply initial value
A program may declare an `external`.
| external blastoff 49152

View File

@ -169,7 +169,8 @@ foldDeclsRenaming ((Reserve name typ Nothing):decls) id block =
block'' = substDeclName name newName block'
in
foldDeclsRenaming decls id' block''
foldDeclsRenaming ((Reserve name typ _):decls) id block =
error ("block-level '" ++ name ++ "' cannot supply initial value")
-- this is kind of horrible. that we do it this way, i mean
substDeclName n1 n2 (Block decls instrs) =
@ -198,16 +199,22 @@ mapInstrName n1 n2 (SUB sl1 sl2) =
SUB (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
mapInstrName n1 n2 (OR sl1 sl2) =
OR (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
mapInstrName n1 n2 (XOR sl1 sl2) =
XOR (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
mapInstrName n1 n2 (SHL sl1 sl2) =
SHL (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
mapInstrName n1 n2 (SHR sl1 sl2) =
SHR (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
mapInstrName n1 n2 (BIT sl1) =
BIT (mapStorageLocationName n1 n2 sl1)
mapInstrName n1 n2 (JMPVECTOR sl1) =
JMPVECTOR (mapStorageLocationName n1 n2 sl1)
mapInstrName n1 n2 (DELTA sl1 v) =
DELTA (mapStorageLocationName n1 n2 sl1) v
{-
| XOR StorageLocation StorageLocation
| SHL StorageLocation StorageLocation
| SHR StorageLocation StorageLocation
| BIT StorageLocation
| JMPVECTOR StorageLocation
| IF InternalID Branch Block Block
| REPEAT InternalID Branch Block
| DELTA StorageLocation DataValue
| WITH WithInstruction Block
| COPYROUTINE RoutineName StorageLocation
-}