git @ Cat's Eye Technologies SixtyPical / 00daec5
Check that block-level reserves do not supply initial value. Cat's Eye Technologies 7 years ago
2 changed file(s) with 43 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
121121 | nop
122122 | }
123123 = True
124
125 `reserve` may be block-level.
126
127 | routine main {
128 | reserve byte lives
129 | lda lives
130 | }
131 = True
132
133 Block-level declarations are only visible in the block in which they are
134 declared.
135
136 | routine main {
137 | reserve byte lives
138 | lda #3
139 | sta lives
140 | }
141 | routine died {
142 | dec lives
143 | }
144 ? undeclared location 'lives'
145
146 A block-level `reserve` may not supply an initial value.
147
148 | routine main {
149 | reserve byte lives : 3
150 | lda lives
151 | }
152 ? block-level 'lives' cannot supply initial value
124153
125154 A program may declare an `external`.
126155
168168 block'' = substDeclName name newName block'
169169 in
170170 foldDeclsRenaming decls id' block''
171
171 foldDeclsRenaming ((Reserve name typ _):decls) id block =
172 error ("block-level '" ++ name ++ "' cannot supply initial value")
172173
173174 -- this is kind of horrible. that we do it this way, i mean
174175 substDeclName n1 n2 (Block decls instrs) =
197198 SUB (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
198199 mapInstrName n1 n2 (OR sl1 sl2) =
199200 OR (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
201 mapInstrName n1 n2 (XOR sl1 sl2) =
202 XOR (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
203 mapInstrName n1 n2 (SHL sl1 sl2) =
204 SHL (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
205 mapInstrName n1 n2 (SHR sl1 sl2) =
206 SHR (mapStorageLocationName n1 n2 sl1) (mapStorageLocationName n1 n2 sl2)
207 mapInstrName n1 n2 (BIT sl1) =
208 BIT (mapStorageLocationName n1 n2 sl1)
209 mapInstrName n1 n2 (JMPVECTOR sl1) =
210 JMPVECTOR (mapStorageLocationName n1 n2 sl1)
211 mapInstrName n1 n2 (DELTA sl1 v) =
212 DELTA (mapStorageLocationName n1 n2 sl1) v
200213
201214 {-
202 | XOR StorageLocation StorageLocation
203 | SHL StorageLocation StorageLocation
204 | SHR StorageLocation StorageLocation
205 | BIT StorageLocation
206 | JMPVECTOR StorageLocation
207215 | IF InternalID Branch Block Block
208216 | REPEAT InternalID Branch Block
209 | DELTA StorageLocation DataValue
210217 | WITH WithInstruction Block
211218 | COPYROUTINE RoutineName StorageLocation
212219 -}