util.mli 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (* Logging functions, they print to stderr and consider the verbosity flag *)
  2. val log_line : int -> string -> unit
  3. val log_node : int -> Ast.node -> unit
  4. val dbg_line : string -> unit
  5. val dbg_node : Ast.node -> unit
  6. (* Generate a fresh variable from a given prefix, e.g. "counter" -> "counter$1" *)
  7. val fresh_var : string -> string
  8. (* Generate an Ast.loc tuple from Lexing data structures *)
  9. val loc_from_lexpos : Lexing.position -> Lexing.position -> Ast.loc
  10. (* Default transformation traversal for AST nodes *)
  11. val transform_children : (Ast.node -> Ast.node) -> Ast.node -> Ast.node
  12. (* Transform all nodes in a list *)
  13. val transform_all : (Ast.node -> Ast.node) -> Ast.node list -> Ast.node list
  14. (*val visit_children : (Ast.node -> unit) -> Ast.node -> unit*)
  15. (* Extract location from node *)
  16. val locof : Ast.node -> Ast.loc
  17. (* Print file location to stderr *)
  18. val prerr_loc : Ast.loc -> unit
  19. (* Print file location to stderr *)
  20. val prerr_loc_msg : Ast.loc -> string -> int -> unit
  21. (* Flatten Block nodes into the given array of nodes *)
  22. val flatten_blocks : Ast.node list -> Ast.node list
  23. (* Get function / expression type *)
  24. val ctypeof : Ast.node -> Ast.ctype
  25. (* Extract the node list from a Block node *)
  26. val block_body : Ast.node -> Ast.node list
  27. (* Get the size of a list by traversing it recurcively *)
  28. val list_size : 'a list -> int
  29. (* Get the basic type of a ctype, removing array dimensions *)
  30. val base_type : Ast.ctype -> Ast.ctype
  31. (* Get the number of dimensions from an Array type *)
  32. val array_depth : Ast.ctype -> int