util.mli 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. val repeat : string -> int -> string
  2. val expand : int -> string -> string
  3. (* Logging functions, they print to stderr and consider the verbosity flag *)
  4. val hline : string
  5. val prt_line : string -> unit
  6. val prt_node : Types.node -> unit
  7. val log_line : int -> string -> unit
  8. val log_plain_line : int -> string -> unit
  9. val log_node : int -> Types.node -> unit
  10. (* Generate a fresh variable from a given prefix, e.g. "foo" -> "foo$1" *)
  11. val fresh_var : string -> string
  12. (* Generate a fresg constant from a given prefix, e.g. "foo" -> "foo$$1" *)
  13. val fresh_const : string -> string
  14. (* Generate an Types.location tuple from Lexing data structures *)
  15. val loc_from_lexpos : Lexing.position -> Lexing.position -> Types.location
  16. (* Default transformation traversal for AST nodes *)
  17. val transform_children : (Types.node -> Types.node) -> Types.node -> Types.node
  18. (* Add a single annotation to a node (no traversal) *)
  19. val annotate : Types.annotation -> Types.node -> Types.node
  20. (*val visit_children : (Types.node -> unit) -> Types.node -> unit*)
  21. (* Extract annotation from node *)
  22. val annof : Types.node -> Types.annotation list
  23. val locof : Types.node -> Types.location
  24. val depthof : Types.node -> int
  25. val indexof : Types.node -> int
  26. val typeof : Types.node -> Types.ctype
  27. val labelof : Types.node -> string
  28. val const_type : Types.const -> Types.ctype
  29. (* Print file location to stderr *)
  30. val prerr_loc : Types.location -> unit
  31. (* Print file location to stderr *)
  32. val prerr_loc_msg : Types.location -> string -> unit
  33. (* Flatten Block nodes into the given array of nodes *)
  34. val flatten_blocks : Types.node list -> Types.node list
  35. (* Extract the node list from a Block node *)
  36. val block_body : Types.node -> Types.node list
  37. (* Get the size of a list by traversing it recurcively *)
  38. val list_size : 'a list -> int
  39. (* Get the basic type of a declaration, removing array dimensions *)
  40. val basetypeof : Types.node -> Types.ctype
  41. (* Get the number of dimensions from an Array type *)
  42. val array_depth : Types.ctype -> int
  43. (* Get name from variable or function declaration *)
  44. val nameof : Types.node -> string
  45. val optmap : ('a -> 'b) -> 'a list option -> 'b list option
  46. val optmapl : ('a -> 'b) -> 'a list option -> 'b list
  47. (* List.mapi clone (only available in OCaml version >= 4.00 *)
  48. val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
  49. val is_immediate_const : Types.const -> bool