1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-01-05 14:32:15 +00:00

Number each temporary uniquely across program. Sweet!

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

View File

@ -234,17 +234,19 @@ temporaries are not unioned yet, but they could be.
= jsr a
= jsr b
= rts
=
= a:
= lda _temp_1
= sta _temp_2+1
= rts
=
= b:
= lda _temp_3
= sta _temp_4
= rts
=
= .data
= .space _temp_3 1
= .space _temp_4 2
= .space _temp_1 1
= .space _temp_2 2
= .space _temp_3 1
= .space _temp_4 2

View File

@ -147,18 +147,19 @@ fillOutNamedLocationTypes p@(Program decls routines) =
-- TODO: look at all blocks, not just routine's blocks
renameBlockDecls (Program decls routines) =
let
routines' = map renameRoutineDecls routines
routines' = renameRoutineDecls 1 routines
in
Program decls routines'
renameRoutineDecls (Routine name outputs block) =
renameRoutineDecls id [] = []
renameRoutineDecls id ((Routine name outputs block):routs) =
let
(Block decls _) = block
(id', block') = foldDeclsRenaming decls 0 block
(id', block') = foldDeclsRenaming decls id block
rest = renameRoutineDecls id' routs
in
(Routine name outputs block')
((Routine name outputs block'):rest)
-- TODO accumulator has to range across all routines too!
foldDeclsRenaming [] id block = (id, block)
foldDeclsRenaming ((Reserve name typ Nothing):decls) id block =
let