git @ Cat's Eye Technologies SixtyPical / 915b0cf
Number each temporary uniquely across program. Sweet! Cat's Eye Technologies 11 years ago
2 changed file(s) with 12 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
233233 = jsr a
234234 = jsr b
235235 = rts
236 =
236237 = a:
237238 = lda _temp_1
238239 = sta _temp_2+1
239240 = rts
241 =
240242 = b:
241243 = lda _temp_3
242244 = sta _temp_4
243245 = rts
244246 =
245247 = .data
248 = .space _temp_3 1
249 = .space _temp_4 2
246250 = .space _temp_1 1
247251 = .space _temp_2 2
248 = .space _temp_3 1
249 = .space _temp_4 2
146146 -- TODO: look at all blocks, not just routine's blocks
147147 renameBlockDecls (Program decls routines) =
148148 let
149 routines' = map renameRoutineDecls routines
149 routines' = renameRoutineDecls 1 routines
150150 in
151151 Program decls routines'
152152
153 renameRoutineDecls (Routine name outputs block) =
153 renameRoutineDecls id [] = []
154 renameRoutineDecls id ((Routine name outputs block):routs) =
154155 let
155156 (Block decls _) = block
156 (id', block') = foldDeclsRenaming decls 0 block
157 in
158 (Routine name outputs block')
159
160 -- TODO accumulator has to range across all routines too!
157 (id', block') = foldDeclsRenaming decls id block
158 rest = renameRoutineDecls id' routs
159 in
160 ((Routine name outputs block'):rest)
161
161162 foldDeclsRenaming [] id block = (id, block)
162163 foldDeclsRenaming ((Reserve name typ Nothing):decls) id block =
163164 let