Number each temporary uniquely across program. Sweet!
Cat's Eye Technologies
11 years ago
146 | 146 |
-- TODO: look at all blocks, not just routine's blocks
|
147 | 147 |
renameBlockDecls (Program decls routines) =
|
148 | 148 |
let
|
149 | |
routines' = map renameRoutineDecls routines
|
|
149 |
routines' = renameRoutineDecls 1 routines
|
150 | 150 |
in
|
151 | 151 |
Program decls routines'
|
152 | 152 |
|
153 | |
renameRoutineDecls (Routine name outputs block) =
|
|
153 |
renameRoutineDecls id [] = []
|
|
154 |
renameRoutineDecls id ((Routine name outputs block):routs) =
|
154 | 155 |
let
|
155 | 156 |
(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 |
|
161 | 162 |
foldDeclsRenaming [] id block = (id, block)
|
162 | 163 |
foldDeclsRenaming ((Reserve name typ Nothing):decls) id block =
|
163 | 164 |
let
|