Project

General

Profile

« Previous | Next » 

Revision 70466917

Added by Pierre-Loïc Garoche over 5 years ago

[main] node locals are now sorted according to their dependencies wrt clocks. The produced lustre node with types shall now be compilable

View differences:

src/causality.ml
29 29

  
30 30

  
31 31
module IdentDepGraph = Graph.Imperative.Digraph.ConcreteBidirectional (IdentModule)
32
module TopologicalDepGraph = Topological.Make(IdentDepGraph)
33

  
32 34
(*module DotGraph = Graphviz.Dot (IdentDepGraph)*)
33 35
module Bfs = Traverse.Bfs (IdentDepGraph)
34 36
  
......
652 654
      raise (Error (exc))
653 655
  )
654 656

  
657
(* A module to sort dependencies among local variables when relying on clocked declarations *)
658
module VarClockDep =
659
struct
660
  let rec get_clock_dep ck =
661
    match ck.Clocks.cdesc with
662
    | Clocks.Con (ck ,c ,l) -> l::(get_clock_dep ck)
663
    | Clocks.Clink ck' 
664
    | Clocks.Ccarrying (_, ck') -> get_clock_dep ck'
665
    | _ -> []
666
      
667
  let sort locals =
668
    let g = new_graph () in
669
    let g = List.fold_left (
670
      fun g var_decl ->
671
	let deps = get_clock_dep var_decl.var_clock in
672
	add_edges [var_decl.var_id] deps g
673
    ) g locals
674
    in
675
    let sorted, no_deps =
676
      TopologicalDepGraph.fold (fun vid (accu, remaining) -> (
677
	let select v = v.var_id = vid in
678
	let selected, not_selected = List.partition select remaining in
679
	selected@accu, not_selected
680
      )) g ([],locals)
681
    in
682
    no_deps @ sorted
683
    
684
end
685
  
655 686
(* Local Variables: *)
656 687
(* compile-command:"make -C .." *)
657 688
(* End: *)

Also available in: Unified diff