Skip to content
Snippets Groups Projects
polymorphism.mli 1.65 KiB
Newer Older
(** Handling polymorphic nodes.  

  XXX I'm not particularly happy with the way all this is done...

    Anyway,  the  idea is  the  following.  As  soon  as  we try  (in
    LazyCompiler) to dump  a polymorphic node, we push  it on a stack
    (push_on_polymorphic_node_stack),  instead of  dumping it,  as we
    have decided  that lic does  not accept polymorphic  nodes.  This
    ougth to occur  in a unique situation: when  an array iterator is
    called   over   a   polymorphic    operator,   e.g.,   in   x   =
    map<<+,3>>([1;2;3],[1;2;3]);

    in such  a situation, we  do generate a  polymorphic Eff.node_exp
    for the  expression "map<<+,3>>" (but  we don't LicDump  it). But
    once  we  get  that  node_exp (in  GetEff.translate_val_exp),  by
    unifying the  node_exp with the  dynamic arguments, we  know that
    the  type variable  was (here,  an integer).   Hence, we  can now
    print the instanciated node (unstack_polymorphic_nodes).

    Note that it is a stack because array iterators can be nested.

*)


(* To deal with polymorphism: raised when a polymorphic expr is generated. *)
exception Exc


val get_type : unit -> Eff.type_

(* Should be unnecessary, but calling it at the appriopriate
   place would avoid silent bugs *)
val reset_type : unit -> unit

val push_on_polymorphic_node_stack : 
    Eff.id_solver * Eff.local_env * Eff.node_exp -> unit

(** We have added the StructArrayExpand.node function as parameter of this function
   to break a module dependency.
*)
val unstack_polymorphic_nodes : 
  (Eff.id_solver -> Eff.local_env -> Eff.node_exp -> Eff.node_exp) ->
  Eff.type_ ->  (Eff.id_solver * Eff.local_env * Eff.node_exp) list