Skip to content

Instantly share code, notes, and snippets.

@awreece
Last active December 10, 2015 04:38
Show Gist options
  • Save awreece/4382721 to your computer and use it in GitHub Desktop.
Save awreece/4382721 to your computer and use it in GitHub Desktop.
File "sreedhar.ml", line 30, characters 62-63:
Error: This expression has type G.V.t but an expression was expected of type
DJG.V.t
make: *** [sreedhar.cmx] Error 2
exception NotComparable
module DJEdge = struct
type t = D | J
(* TODO(awreece) Can we avoid needing a comparison function? *)
let compare l r = raise NotComparable
let default = D
end
(* TODO(awreece) Accept a builder parameter? *)
module Make(G : Dominator.G) = struct
module UF = Graph.Unionfind.Make(G.V)
module Dom = Dominator.Make(G)
(*
* http://ocamlgraph.lri.fr/doc/Imperative.S.AbstractLabeled.html
*
* module AbstractLabeled:
* functor (V : Sig.ANY_TYPE) ->
* functor (E : Sig.ORDERED_TYPE_DFT) -> Sig.IM with type V.label = V.t and type E.label = E.t
*)
module DJG = Graph.Imperative.Digraph.AbstractLabeled(struct type t = G.V.t end)(DJEdge)
let dj_graph cfg s0 =
let idom = Dom.compute_idom cfg s0 in
(* TODO(awreece) I feel like this should ask for s0. *)
let dom_tree:(G.V.t -> G.V.t list) = Dom.idom_to_dom_tree cfg idom in
let graph:(DJG.t) = DJG.create ~size:(G.nb_vertex cfg) () in
let add_d_edge (g:DJG.t) (v:DJG.V.t) (w:DJG.V.t) = DJG.add_edge_e g (DJG.E.create v DJEdge.D w) in
let add_d_edges (g:DJG.t) (v:DJG.V.t) (idoms:DJG.V.t list) = List.iter (add_d_edge g v) idoms in
let () = G.iter_vertex (fun (v:G.V.t) -> add_d_edge graph v (dom_tree v)) cfg in
"Let the games begin"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment