util.mli 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. (* Print file location to stderr *)
  27. val prerr_loc : Types.location -> unit
  28. (* Print file location to stderr *)
  29. val prerr_loc_msg : Types.location -> string -> unit
  30. (* Flatten Block nodes into the given array of nodes *)
  31. val flatten_blocks : Types.node list -> Types.node list
  32. (* Extract the node list from a Block node *)
  33. val block_body : Types.node -> Types.node list
  34. (* Get the size of a list by traversing it recurcively *)
  35. val list_size : 'a list -> int
  36. (* Get the basic type of a declaration, removing array dimensions *)
  37. val basetypeof : Types.node -> Types.ctype
  38. (* Get the number of dimensions from an Array type *)
  39. val array_depth : Types.ctype -> int
  40. (* Get name from variable or function declaration *)
  41. val nameof : Types.node -> string
  42. val optmap : ('a -> 'b) -> 'a list option -> 'b list option
  43. val optmapl : ('a -> 'b) -> 'a list option -> 'b list
  44. (* List.mapi clone (only available in OCaml version >= 4.00 *)
  45. val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list