mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-17 22:30:27 +00:00
Check that block-level reserves do not supply initial value.
This commit is contained in:
parent
915b0cfef0
commit
00daec53a7
@ -123,6 +123,35 @@ Test for many combinations of `reserve` and `assign`.
|
|||||||
| }
|
| }
|
||||||
= True
|
= 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`.
|
A program may declare an `external`.
|
||||||
|
|
||||||
| external blastoff 49152
|
| external blastoff 49152
|
||||||
|
@ -169,7 +169,8 @@ foldDeclsRenaming ((Reserve name typ Nothing):decls) id block =
|
|||||||
block'' = substDeclName name newName block'
|
block'' = substDeclName name newName block'
|
||||||
in
|
in
|
||||||
foldDeclsRenaming decls id' block''
|
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
|
-- this is kind of horrible. that we do it this way, i mean
|
||||||
substDeclName n1 n2 (Block decls instrs) =
|
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)
|
SUB (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
|
||||||
mapInstrName n1 n2 (OR sl1 sl2) =
|
mapInstrName n1 n2 (OR sl1 sl2) =
|
||||||
OR (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 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
|
| IF InternalID Branch Block Block
|
||||||
| REPEAT InternalID Branch Block
|
| REPEAT InternalID Branch Block
|
||||||
| DELTA StorageLocation DataValue
|
|
||||||
| WITH WithInstruction Block
|
| WITH WithInstruction Block
|
||||||
| COPYROUTINE RoutineName StorageLocation
|
| COPYROUTINE RoutineName StorageLocation
|
||||||
-}
|
-}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user