util.mli 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 basic type of a declaration, removing array dimensions *)
  38. val basetypeof : Types.node -> Types.ctype
  39. (* Get name from variable or function declaration *)
  40. val nameof : Types.node -> string
  41. val optmap : ('a -> 'b) -> 'a list option -> 'b list option
  42. val optmapl : ('a -> 'b) -> 'a list option -> 'b list
  43. (* List.mapi clone (only available in OCaml version >= 4.00 *)
  44. val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
  45. val is_immediate_const : Types.const -> bool
  46. val is_array : Types.node -> bool
  47. val node_warning : Types.node -> string -> unit