util.mli 2.0 KB

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