let c_element (e: element): string = match e with
Reg(r,t) -> (
match t with
DInt -> "reg[" ^ (string_of_int r) ^ "]" ^ (getElementType e)
| DFloat -> "reg[" ^ (string_of_int r) ^ "]" ^ (getElementType e)
| _ -> raise (TYPE_ERROR "Unable to retrieve data type")
)
| Off(o,tp,b) -> (
match tp with
DInt -> if b then "stack[baseptr + " ^ (string_of_int o) ^ "]" ^ (getElementType e)
else "stack[" ^ (string_of_int o) ^ "]" ^ (getElementType e)
| DFloat -> if b then "stack[baseptr + " ^ (string_of_int o) ^ "]" ^ (getElementType e)
else "stack[" ^ (string_of_int o) ^ "]" ^ (getElementType e)
| _ -> raise (TYPE_ERROR "Unable to retrieve data type")
)
| Label(l) -> "L" ^ (string_of_int l)
| Val(v) -> (
match v with
I(n) -> string_of_int n
| F(r) -> string_of_float r
)
| Subr(s) -> s ^ "(stackptr);\n"
| Null -> ""