util.mli 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. (* Logging functions, they print to stderr and consider the verbosity flag *)
  2. val prt_line : string -> unit
  3. val prt_node : Ast.node -> unit
  4. val log_line : int -> string -> unit
  5. val log_node : int -> Ast.node -> unit
  6. val dbg_line : string -> unit
  7. val dbg_node : Ast.node -> unit
  8. (* Generate a fresh variable from a given prefix, e.g. "counter" -> "counter$1" *)
  9. val fresh_var : string -> string
  10. (* Generate an Ast.loc tuple from Lexing data structures *)
  11. val loc_from_lexpos : Lexing.position -> Lexing.position -> Ast.loc
  12. (* Default transformation traversal for AST nodes *)
  13. val transform_children : (Ast.node -> Ast.node) -> Ast.node -> Ast.node
  14. (* Transform all nodes in a list *)
  15. val transform_all : (Ast.node -> Ast.node) -> Ast.node list -> Ast.node list
  16. (*val visit_children : (Ast.node -> unit) -> Ast.node -> unit*)
  17. (* Extract location from node *)
  18. val locof : Ast.node -> Ast.loc
  19. (* Print file location to stderr *)
  20. val prerr_loc : Ast.loc -> unit
  21. (* Print file location to stderr *)
  22. val prerr_loc_msg : Ast.loc -> string -> int -> unit
  23. (* Flatten Block nodes into the given array of nodes *)
  24. val flatten_blocks : Ast.node list -> Ast.node list
  25. (* Get function / expression type *)
  26. val ctypeof : Ast.node -> Ast.ctype
  27. (* Extract the node list from a Block node *)
  28. val block_body : Ast.node -> Ast.node list
  29. (* Get the size of a list by traversing it recurcively *)
  30. val list_size : 'a list -> int
  31. (* Get the basic type of a ctype, removing array dimensions *)
  32. val base_type : Ast.ctype -> Ast.ctype
  33. (* Get the number of dimensions from an Array type *)
  34. val array_depth : Ast.ctype -> int