|
@@ -1,16 +1,12 @@
|
|
|
open Types
|
|
open Types
|
|
|
open Util
|
|
open Util
|
|
|
|
|
+open Stringify
|
|
|
|
|
|
|
|
let tab = " "
|
|
let tab = " "
|
|
|
let max_instr_width = 26
|
|
let max_instr_width = 26
|
|
|
|
|
|
|
|
let si = string_of_int
|
|
let si = string_of_int
|
|
|
|
|
|
|
|
-let ctype2str = Stringify.type2str
|
|
|
|
|
-let type2str = function
|
|
|
|
|
- | ArrayDims (t, dims) -> ctype2str t ^ repeat "," (List.length dims - 1)
|
|
|
|
|
- | t -> ctype2str t
|
|
|
|
|
-
|
|
|
|
|
let op2str = function
|
|
let op2str = function
|
|
|
| Neg -> "neg"
|
|
| Neg -> "neg"
|
|
|
| Not -> "not"
|
|
| Not -> "not"
|
|
@@ -31,13 +27,13 @@ let prefix = function
|
|
|
| Bool _ -> "b"
|
|
| Bool _ -> "b"
|
|
|
| Int _ -> "i"
|
|
| Int _ -> "i"
|
|
|
| Float _ -> "f"
|
|
| Float _ -> "f"
|
|
|
- | Void -> ""
|
|
|
|
|
- | _ -> "a"
|
|
|
|
|
|
|
+ | Void -> ""
|
|
|
|
|
+ | _ -> "a"
|
|
|
|
|
|
|
|
let suffix = function
|
|
let suffix = function
|
|
|
- | Glob -> "g"
|
|
|
|
|
- | Current -> ""
|
|
|
|
|
- | Local -> "l"
|
|
|
|
|
|
|
+ | Glob -> "g"
|
|
|
|
|
+ | Current -> ""
|
|
|
|
|
+ | Local -> "l"
|
|
|
| Rel nesting -> "n " ^ si nesting
|
|
| Rel nesting -> "n " ^ si nesting
|
|
|
|
|
|
|
|
let rtn_suffix = function
|
|
let rtn_suffix = function
|
|
@@ -64,7 +60,7 @@ let rec instr2str = function
|
|
|
| Global ctype ->
|
|
| Global ctype ->
|
|
|
".global " ^ (type2str ctype)
|
|
".global " ^ (type2str ctype)
|
|
|
| ConstDef value ->
|
|
| ConstDef value ->
|
|
|
- ".const " ^ type2str (const_type value) ^ " " ^ Stringify.const2str value
|
|
|
|
|
|
|
+ ".const " ^ type2str (const_type value) ^ " " ^ const2str value
|
|
|
|
|
|
|
|
(* Store *)
|
|
(* Store *)
|
|
|
| Store (ctype, scope, index) ->
|
|
| Store (ctype, scope, index) ->
|
|
@@ -162,7 +158,7 @@ let rec print_assembly oc instrs =
|
|
|
let phase = function
|
|
let phase = function
|
|
|
| Ast node as input ->
|
|
| Ast node as input ->
|
|
|
prerr_endline hline;
|
|
prerr_endline hline;
|
|
|
- prerr_endline (Stringify.node2str node);
|
|
|
|
|
|
|
+ prerr_endline (node2str node);
|
|
|
prerr_endline hline;
|
|
prerr_endline hline;
|
|
|
input
|
|
input
|
|
|
|
|
|