util.mli 2.2 KB

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