
exception TypeCheckingError
(***********************************************************************)
(*                                                                     *)
(* This sub-module contains the C-specific offshoring arguments.       *)
(*                                                                     *)
(***********************************************************************)

module OffshoreC : sig
  type runC_record 
  val runC : runC_record
  val getDefaultArg: string -> string 

  (* most important translation functions *)
  (* val runInC_new : Typedtree.expression ->  int code -> int *)
    
  (* strings are args: compiler_flags compiler 
     working_dir file_name *)
  val runInCarg : 
    ('a,int) code -> string -> string -> string -> string -> int
    
  (* strings are args: compiler_flags compiler 
     working_dir file_name main_function_name *)
  val runInCf_all_arg : 
     ('a,'b->'c) code -> string -> string -> string -> 
    string -> string -> ('a->'b)
    
  (* These are temporary for obtaining timings.  
     They allow one to isolate
     translation, pretty print + C compilation, and execution.  *)

  val toC :  ('a,'b) code -> string*string
    (* compile a string; arguments: code compiler compiler_flags working_dir file_name *)
  val buildCexe : string -> string -> string -> string -> string -> unit
  val runCexe : string -> int
    
  (* Manipulating libraries.  *)
    
  (* Add C code to a desired library; args are: 
     code working_dir file_name  *)
  val addToLibrary : string -> string -> string -> unit
    (* compile in a dynamic library; 
       arguments: compler compiler_flags working_dir file_name *)
  val buildLibs : string -> string -> string -> string -> unit
  (* For now the programmer explicitly closes the currently open library.
     In the future, we will close this when we detect that the functions
     in the library are no longer used.  *)
  val closeCurrentLib : unit -> unit 


(*
  val runInCf_bigarray_i_i : 
    ((int, Bigarray.int_elt, Bigarray.c_layout) Bigarray.Array2.t -> int) code
    -> ((int, Bigarray.int_elt, Bigarray.c_layout) Bigarray.Array2.t -> int)
*)



end

(***********************************************************************)
(*                                                                     *)
(* This sub-module contains the F90-specific offshoring arguments.     *)
(*                                                                     *)
(***********************************************************************)

module OffshoreF : sig

  type runF_record 
  val runF : runF_record
  val getDefaultArg: string -> string 

  val runInF :  ('a, int) code -> string -> string -> string -> string -> int
  val toF :  ('a,'b) code   -> string
  val toF_fun_only :  ('a,'b) code -> (string * string)
  val addToLibrary : string -> string -> string -> unit
  val buildLibs : string -> string -> string -> string -> string -> unit
  val runInFf : ('a,int->int) code -> (int->int)
    (*
      val runInFf_array_i :(int array->int) code -> (int array->int)
      val runInFf_array_f :(float array->int) code -> (float array->int)
      val runInFf_array_c_c :(char array array->int) code -> (char array array->int)
      val runInFf_array_f_f :(float array array->int) code -> (float array array->int)
    *)
  val closeCurrentLib: unit -> unit

end

val trx_expression: int -> Typedtree.expression -> Typedtree.expression
val trx_structure: Typedtree.structure -> Typedtree.structure
val longidenttostring : Longident.t -> string
val gensymlongident : Longident.t -> Longident.t
val reset_gensymstring_counter : unit -> unit (* OXX *)

val mkcsp : Obj.t -> Typedtree.expression option  -> Longident.t -> Parsetree.expression

(* time n s f   executes f() n times and records message s plus elapsed time *)
val time : int -> string -> (unit -> 'a) -> 'a
val timenew : string -> (unit -> 'a) -> 'a
val init_times : unit -> unit
(* flushes recorded times *)
val print_times : unit -> unit
val get_times : unit -> ((string * int * float) list)
(* print code as parse tree *)
val printcode : ('a, 'b) code -> unit
val npc : ('a, 'b) code -> unit
val npcF : Format.formatter -> ('a, 'b) code -> unit


(* support for native code *)
val native_mode : bool ref
val initial_native_compilation : bool ref
val get_csp_value : int -> Obj.t
val execute_expression_hook : (Parsetree.expression -> Obj.t) ref
val load_compiled_code_hook : (int -> unit) ref
val execute_expression_result : Obj.t ref
val execute_expression : Parsetree.expression -> Obj.t
val csp_array : Obj.t array ref
val reset_csp_array : unit -> unit
val local_csp_arr_texp : Typedtree.expression ref

(* More precise timing functions *)
type ticks

val times: unit -> float * float 
(* returns user and system process times, in whole and fractional seconds.
   Resolution upto a microsecond.
 *)

val get_ticks: unit -> ticks 
(* Gets the CPU cycle counter as an abstract object. See cycle.h
   from the FFTW project *)

val elapsed_ticks: ticks -> float
(* Returns the elapsed time in abstract units from the
   specified moment till now. *)

val timecycles: string -> (unit -> 'a) -> 'a
(* like timenew but uses the CPU cycle counter for timing. 
   It's better for shorter functions that can run without being
   scheduled out.
*)

val etag : Parsetree.core_type -> Parsetree.expression ->
  Parsetree.expression -> Env.t -> Parsetree.expression
val te_success : bool ref




