util.mli 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. (** Utility functions used by multiple phases. *)
  2. (**
  3. Extended description...
  4. *)
  5. (** *)
  6. val repeat : string -> int -> string
  7. (** *)
  8. val expand : int -> string -> string
  9. (** Logging functions, they print to stderr and consider the verbosity flag *)
  10. val hline : string
  11. (** *)
  12. val prt_line : string -> unit
  13. (** *)
  14. val prt_node : Types.node -> unit
  15. (** *)
  16. val log_line : int -> string -> unit
  17. (** *)
  18. val log_plain_line : int -> string -> unit
  19. (** *)
  20. val log_node : int -> Types.node -> unit
  21. (** Generate a fresh variable from a given prefix, e.g. "foo" -> "foo$1" *)
  22. val fresh_var : string -> string
  23. (** Generate a fresg constant from a given prefix, e.g. "foo" -> "foo$$1" *)
  24. val fresh_const : string -> string
  25. (** Generate an Types.location tuple from Lexing data structures *)
  26. val loc_from_lexpos : Lexing.position -> Lexing.position -> Types.location
  27. (** Default transformation traversal for AST nodes *)
  28. val transform_children : (Types.node -> Types.node) -> Types.node -> Types.node
  29. (** Add a single annotation to a node (no traversal) *)
  30. val annotate : Types.annotation -> Types.node -> Types.node
  31. (** Extract annotation from node *)
  32. val annof : Types.node -> Types.annotation list
  33. (** *)
  34. val locof : Types.node -> Types.location
  35. (** *)
  36. val depthof : Types.node -> int
  37. (** *)
  38. val indexof : Types.node -> int
  39. (** *)
  40. val typeof : Types.node -> Types.ctype
  41. (** *)
  42. val labelof : Types.node -> string
  43. (** *)
  44. val const_type : Types.const -> Types.ctype
  45. (** Print file location to stderr *)
  46. val prerr_loc : Types.location -> unit
  47. (** Print file location to stderr *)
  48. val prerr_loc_msg : Types.location -> string -> unit
  49. (** Flatten Block nodes into the given array of nodes *)
  50. val flatten_blocks : Types.node list -> Types.node list
  51. (** Extract the node list from a Block node *)
  52. val block_body : Types.node -> Types.node list
  53. (** Get the basic type of a declaration, removing array dimensions *)
  54. val basetypeof : Types.node -> Types.ctype
  55. (** Get name from variable or function declaration *)
  56. val nameof : Types.node -> string
  57. (** *)
  58. val optmap : ('a -> 'b) -> 'a list option -> 'b list option
  59. (** *)
  60. val optmapl : ('a -> 'b) -> 'a list option -> 'b list
  61. (** List.mapi clone (only available in OCaml version >= 4.00 *)
  62. val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
  63. (** *)
  64. val is_immediate_const : Types.const -> bool
  65. (** *)
  66. val is_array : Types.node -> bool
  67. (** *)
  68. val node_warning : Types.node -> string -> unit
  69. (** *)
  70. val noloc : Types.location
  71. (** *)
  72. val immediate_consts : Types.const list