Skip to content
Snippets Groups Projects
compile.ml 2.22 KiB
Newer Older
(* Time-stamp: <modified the 03/04/2013 (at 14:41) by Erwan Jahier> *)
Erwan Jahier's avatar
Erwan Jahier committed
open Lxm
open Errors
open AstV6
open AstCore
Erwan Jahier's avatar
Erwan Jahier committed

(* get the first package in the package/model list *)
Erwan Jahier's avatar
Erwan Jahier committed

let (doit : AstV6.pack_or_model list -> Ident.idref option -> LicPrg.t) = 
    let syntax_tab = AstTab.create srclist in
    (* Pour chaque package, on a un solveur de rfrences
       globales, pour les types, const et node :
       - les rfrences pointes (p::n) sont recherches
       directement dans la syntax_tab puisqu'il n'y a pas 
       d'ambiguit
       - les rfrences simples sont recherches :
       . dans le pack lui-mme
       . dans un des packs dclars "uses", avec
       priorit dans l'ordre
    *)
    let lic_tab = LicTab.create syntax_tab in
    Verbose.exe ~level:2 (fun () -> AstTab.dump syntax_tab);
Erwan Jahier's avatar
Erwan Jahier committed

    let lic_tab = match main_node with
      | None -> LicTab.compile_all lic_tab
      | Some main_node -> 
        if !Global.compile_all_items then
          LicTab.compile_all lic_tab
          LicTab.compile_node lic_tab main_node
    let zelic = LicTab.to_lic_prg lic_tab in
    (* limination polymorphisme  surcharge *)
    let zelic = L2lRmPoly.doit zelic in
    (* alias des types array *)
    (*     let zelic = L2lAliasType.doit zelic in *)
    let zelic = if not !Global.inline_iterator then zelic else
        (* to be done before array expansion otherwise they won't be expanded *)
        L2lExpandMetaOp.doit zelic 
        !Global.one_op_per_equation 
        || !Global.expand_nodes (* expand performs no fixpoint, so it will work
                                   only if we have one op per equation...*)
        (* Split des equations (1 eq = 1 op) *)
        L2lSplit.doit zelic 
    (* Array and struct expansion: to do after polymorphism elimination *)
    let zelic = if not !Global.expand_nodes then zelic else 
        L2lExpandNodes.doit zelic 
    in
    let zelic = if not !Global.expand_arrays then zelic else
        L2lExpandArrays.doit zelic 
    in    

    (* Currently only works in this mode *)
    if  !Global.ec then L2lCheckLoops.doit zelic;
    L2lCheckOutputs.doit zelic;