Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Commit

Permalink
* h_program-lang/dependencies_matrix_code.ml: type
Browse files Browse the repository at this point in the history
  • Loading branch information
pad committed May 18, 2012
1 parent c67f6f9 commit 3a04f52
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
24 changes: 21 additions & 3 deletions h_program-lang/dependencies_matrix_code.ml
Expand Up @@ -32,7 +32,11 @@ module G = Graph_code
(*****************************************************************************)

(* dependency structure matrix *)
type dm = unit
type dm = {
matrix: int array array;
(* could be a tree *)
names: Graph_code.node array;
}

(* list of nodes to expand *)
type config = Graph_code.node list
Expand All @@ -47,11 +51,25 @@ type config = Graph_code.node list

(* poor's man DSM visualizer; use codegraph for a real visualization *)
let display dm =
raise Todo
pr2_gen dm;
()

(*****************************************************************************)
(* Main entry point *)
(*****************************************************************************)

let build config g =
raise Todo

let top_nodes = G.succ G.root G.Has g in

(* todo: iterate while in config *)
let nodes = top_nodes in
let n = List.length nodes in

let dm = {
matrix = Common.make_matrix_init ~nrow:n ~ncolumn:n (fun i j -> 0);
names = Array.of_list nodes;
}
in
dm

11 changes: 11 additions & 0 deletions h_program-lang/graph_code.ml
Expand Up @@ -146,6 +146,17 @@ let load file =
let has_node n g =
G.has_node n g.has

let pred n e g =
match e with
| Has -> G.pred n g.has
| Use -> G.pred n g.use

let succ n e g =
match e with
| Has -> G.succ n g.has
| Use -> G.succ n g.use


let parent n g =
let xs = G.pred n g.has in
Common.list_to_single_or_exn xs
Expand Down
2 changes: 2 additions & 0 deletions h_program-lang/graph_code.mli
Expand Up @@ -19,6 +19,8 @@ val add_edge: (node * node) -> edge -> graph -> unit

(* graph access *)
val has_node: node -> graph -> bool
val succ: node -> edge -> graph -> node list
val pred: node -> edge -> graph -> node list
(* can raise exception *)
val parent: node -> graph -> node
val parents: node -> graph -> node list
Expand Down

0 comments on commit 3a04f52

Please sign in to comment.