util.mli 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. "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 Ast.loc tuple from Lexing data structures *)
  13. val loc_from_lexpos : Lexing.position -> Lexing.position -> Ast.loc
  14. (* Default transformation traversal for AST nodes *)
  15. val transform_children : (Ast.node -> Ast.node) -> Ast.node -> Ast.node
  16. (* Transform all nodes in a list *)
  17. val transform_all : (Ast.node -> Ast.node) -> Ast.node list -> Ast.node list
  18. (*val visit_children : (Ast.node -> unit) -> Ast.node -> unit*)
  19. (* Extract location from node *)
  20. val locof : Ast.node -> Ast.loc
  21. (* Print file location to stderr *)
  22. val prerr_loc : Ast.loc -> unit
  23. (* Print file location to stderr *)
  24. val prerr_loc_msg : Ast.loc -> string -> int -> unit
  25. (* Flatten Block nodes into the given array of nodes *)
  26. val flatten_blocks : Ast.node list -> Ast.node list
  27. (* Get function / expression type *)
  28. val ctypeof : Ast.node -> Ast.ctype
  29. (* Extract the node list from a Block node *)
  30. val block_body : Ast.node -> Ast.node list
  31. (* Get the size of a list by traversing it recurcively *)
  32. val list_size : 'a list -> int
  33. (* Get the basic type of a ctype, removing array dimensions *)
  34. val base_type : Ast.ctype -> Ast.ctype
  35. (* Get the number of dimensions from an Array type *)
  36. val array_depth : Ast.ctype -> int