5 datatype place
= P
of int
7 datatype info
= Info1 | Info2 | Info3
9 datatype 'a tr
= TR
of 'a exp
* info | K
of 'a
-> int
10 and 'a exp
= SWITCH_I
of ('a
, int) switch
11 | SWITCH_S
of ('a
, string) switch
12 | STRING
of string * 'a
13 and ('a
,'c
) switch
= SWITCH
of 'a tr
* ('c
* 'a tr
) list
15 datatype 'a pgm
= PGM
of string * 'a tr
17 type mulexp
= place exp
18 and multrip
= place tr
19 type mulexp_llv
= (place
*int) exp
20 and trip_llv
= (place
*int) tr
22 fun llv(tr
: multrip
as TR(e
,Info1
)) : trip_llv
=
29 and llvExp(e
: mulexp
) : mulexp_llv
=
31 fun llv_switch(SWITCH(e
,branches
)) =
32 (* Note
: e is trivial
*)
33 let val branches
' = map (fn (c
,e
) => (c
,llv e
)) branches
35 SWITCH(llv e
, branches
')
40 let val switch
' = llv_switch switch
44 let val switch
' = llv_switch switch
47 |
STRING(s
,place
) => STRING(s
, (place
, 5))
52 val llv
= fn (PGM (label
,expression
)) =>
54 val tr
' = llv expression