src/Pure/Tools/codegen_thingol.ML
changeset 19953 2f54a51f1801
parent 19937 d1b8374d8df7
child 19956 f992e507020e
equal deleted inserted replaced
19952:eaf2c25654d3 19953:2f54a51f1801
    55   val unfold_let: iexpr -> ((iexpr * itype) * iexpr) list * iexpr;
    55   val unfold_let: iexpr -> ((iexpr * itype) * iexpr) list * iexpr;
    56   val unfold_const_app: iexpr ->
    56   val unfold_const_app: iexpr ->
    57     ((string * (iclasslookup list list * itype)) * iexpr list) option;
    57     ((string * (iclasslookup list list * itype)) * iexpr list) option;
    58   val add_constnames: iexpr -> string list -> string list;
    58   val add_constnames: iexpr -> string list -> string list;
    59   val add_varnames: iexpr -> string list -> string list;
    59   val add_varnames: iexpr -> string list -> string list;
    60   val is_pat: iexpr -> bool;
    60   val is_pat: (string -> bool) -> iexpr -> bool;
    61   val map_pure: (iexpr -> 'a) -> iexpr -> 'a;
    61   val map_pure: (iexpr -> 'a) -> iexpr -> 'a;
    62   val resolve_tycos: (string -> string) -> itype * iexpr list -> itype * iexpr list;
    62   val resolve_tycos: (string -> string) -> itype * iexpr list -> itype * iexpr list;
    63   val resolve_consts: (string -> string) -> iexpr -> iexpr;
    63   val resolve_consts: (string -> string) -> iexpr -> iexpr;
    64   val eta_expand: (string * (iclasslookup list list * itype)) * iexpr list -> int -> iexpr;
    64   val eta_expand: (string * (iclasslookup list list * itype)) * iexpr list -> int -> iexpr;
    65 
    65 
    72     | Datatype of datatyp
    72     | Datatype of datatyp
    73     | Datatypecons of string
    73     | Datatypecons of string
    74     | Class of class list * (vname * (string * (sortcontext * itype)) list)
    74     | Class of class list * (vname * (string * (sortcontext * itype)) list)
    75     | Classmember of class
    75     | Classmember of class
    76     | Classinst of ((class * (string * (vname * sort) list))
    76     | Classinst of ((class * (string * (vname * sort) list))
    77           * (class * (string * iclasslookup list list)) list)
    77           * (class * iclasslookup list) list)
    78         * (string * ((string * funn) * iclasslookup list list)) list
    78         * (string * ((string * funn) * iclasslookup list list)) list
    79     | Classinstmember;
    79     | Classinstmember;
    80   type module;
    80   type module;
    81   type transact;
    81   type transact;
    82   type 'dst transact_fin;
    82   type 'dst transact_fin;
   302   let
   302   let
   303     fun instant (ITyVar x) = f x
   303     fun instant (ITyVar x) = f x
   304       | instant y = map_itype instant y;
   304       | instant y = map_itype instant y;
   305   in instant end;
   305   in instant end;
   306 
   306 
   307 fun is_pat (e as IConst (_, ([], _))) = true
   307 fun is_pat is_cons (e as IConst (c, ([], _))) = is_cons  c
   308   | is_pat (e as IVar _) = true
   308   | is_pat _ (e as IVar _) = true
   309   | is_pat (e as (e1 `$ e2)) =
   309   | is_pat is_cons (e as (e1 `$ e2)) =
   310       is_pat e1 andalso is_pat e2
   310       is_pat is_cons e1 andalso is_pat is_cons e2
   311   | is_pat (e as INum _) = true
   311   | is_pat _ (e as INum _) = true
   312   | is_pat (e as IChar _) = true
   312   | is_pat _ (e as IChar _) = true
   313   | is_pat e = false;
   313   | is_pat _ _ = false;
   314 
   314 
   315 fun map_pure f (e as IConst _) =
   315 fun map_pure f (e as IConst _) =
   316       f e
   316       f e
   317   | map_pure f (e as IVar _) =
   317   | map_pure f (e as IVar _) =
   318       f e
   318       f e
   395   | Datatype of datatyp
   395   | Datatype of datatyp
   396   | Datatypecons of string
   396   | Datatypecons of string
   397   | Class of class list * (vname * (string * (sortcontext * itype)) list)
   397   | Class of class list * (vname * (string * (sortcontext * itype)) list)
   398   | Classmember of class
   398   | Classmember of class
   399   | Classinst of ((class * (string * (vname * sort) list))
   399   | Classinst of ((class * (string * (vname * sort) list))
   400         * (class * (string * iclasslookup list list)) list)
   400         * (class * iclasslookup list) list)
   401       * (string * ((string * funn) * iclasslookup list list)) list
   401       * (string * ((string * funn) * iclasslookup list list)) list
   402   | Classinstmember;
   402   | Classinstmember;
   403 
   403 
   404 datatype node = Def of def | Module of node Graph.T;
   404 datatype node = Def of def | Module of node Graph.T;
   405 type module = node Graph.T;
   405 type module = node Graph.T;
   666           |> AList.default (op =) (n, PN ([], []))
   666           |> AList.default (op =) (n, PN ([], []))
   667           |> AList.map_entry (op =) n (mk_ipath (ns, base))
   667           |> AList.map_entry (op =) n (mk_ipath (ns, base))
   668           |> (pair defs #> PN);
   668           |> (pair defs #> PN);
   669     fun select (PN (defs, modls)) (Module module) =
   669     fun select (PN (defs, modls)) (Module module) =
   670       module
   670       module
   671       |> Graph.subgraph (Graph.all_succs module (defs @ map fst modls))
   671       |> Graph.project (member (op =) (Graph.all_succs module (defs @ map fst modls)))
   672       |> fold (fn (name, modls) => Graph.map_node name (select modls)) modls
   672       |> fold (fn (name, modls) => Graph.map_node name (select modls)) modls
   673       |> Module;
   673       |> Module;
   674   in
   674   in
   675     Module modl
   675     Module modl
   676     |> select (fold (mk_ipath o dest_name)
   676     |> select (fold (mk_ipath o dest_name)
  1001       | seri prfx ds =
  1001       | seri prfx ds =
  1002           seri_defs sresolver (NameSpace.pack prfx)
  1002           seri_defs sresolver (NameSpace.pack prfx)
  1003             (map (fn (name, Def def) => (fst (mk_name prfx name), def)) ds)
  1003             (map (fn (name, Def def) => (fst (mk_name prfx name), def)) ds)
  1004   in
  1004   in
  1005     seri_module (resolver []) (map (resolver []) ((the o Symtab.lookup imptab) ""))
  1005     seri_module (resolver []) (map (resolver []) ((the o Symtab.lookup imptab) ""))
  1006       (*map (resolver []) (Graph.strong_conn module |> flat |> rev)*)
       
  1007       (("", name_root), (mk_contents [] module))
  1006       (("", name_root), (mk_contents [] module))
  1008   end;
  1007   end;
  1009 
  1008 
  1010 end; (* struct *)
  1009 end; (* struct *)
  1011 
  1010