Debian Codegraph @

lib/mlrisc-lib/MLRISC/gc-safety/gc-cells.sml

raw
1 (*
2 * This makes a new cell function that automatically propagate gc type info.
3 *)
4 functor GCCells(structure C : CELLS
5 structure GC : GC_TYPE
6 ) : GC_CELLS =
7 struct
8
9 structure C = C
10 structure GC = GC
11 structure CB = CellsBasis
12
13 (*
14 * Generate a new virtual register and update the gc information
15 * at the same time.
16 *)
17 fun newCell k =
18 let val new = C.newCell k
19 val set = #set GC.GC_TYPE
20 fun genVar gc =
21 let val r as CB.CELL{an, ...} = new()
22 in an := set(gc,!an); r end
23 in genVar
24 end
25
26 fun getGCType(CB.CELL{an, ...}) = #lookup GC.GC_TYPE (!an)
27 fun setGCType(CB.CELL{an, ...}, gc) = an := #set GC.GC_TYPE (gc, !an)
28
29 fun printType(CB.CELL{an, ...}) =
30 case #get GC.GC_TYPE (!an) of
31 SOME ty => ":"^GC.toString ty
32 | NONE => ":?"
33
34 val GCLIVEOUT = Annotations.new(SOME(fn _ => "GCLIVEOUT"))
35 : (CB.cell * GC.gctype) list Annotations.property
36 end