12 | Module of ('b * (string * ('a, 'b) node) Graph.T); |
12 | Module of ('b * (string * ('a, 'b) node) Graph.T); |
13 val hierarchical_program: (string -> string) -> { module_alias: string -> string option, |
13 val hierarchical_program: (string -> string) -> { module_alias: string -> string option, |
14 reserved: Name.context, empty_nsp: 'c, namify_module: string -> 'c -> string * 'c, |
14 reserved: Name.context, empty_nsp: 'c, namify_module: string -> 'c -> string * 'c, |
15 namify_stmt: Code_Thingol.stmt -> string -> 'c -> string * 'c, |
15 namify_stmt: Code_Thingol.stmt -> string -> 'c -> string * 'c, |
16 cyclic_modules: bool, empty_data: 'b, memorize_data: string -> 'b -> 'b, |
16 cyclic_modules: bool, empty_data: 'b, memorize_data: string -> 'b -> 'b, |
17 modify_stmts: Code_Thingol.stmt list -> 'a option list } |
17 modify_stmts: (string * Code_Thingol.stmt) list -> 'a option list } |
18 -> Code_Thingol.program |
18 -> Code_Thingol.program |
19 -> { deresolver: string list -> string -> string, |
19 -> { deresolver: string list -> string -> string, |
20 hierarchical_program: (string * ('a, 'b) node) Graph.T } |
20 hierarchical_program: (string * ('a, 'b) node) Graph.T } |
21 end; |
21 end; |
22 |
22 |
107 |> fold (declare (namify_stmt o (fn Stmt stmt => stmt))) stmt_names; |
107 |> fold (declare (namify_stmt o (fn Stmt stmt => stmt))) stmt_names; |
108 val modify_stmts' = filter (member (op =) stmt_names) |
108 val modify_stmts' = filter (member (op =) stmt_names) |
109 #> AList.make (snd o Graph.get_node nodes) |
109 #> AList.make (snd o Graph.get_node nodes) |
110 #> split_list |
110 #> split_list |
111 ##> map (fn Stmt stmt => stmt) |
111 ##> map (fn Stmt stmt => stmt) |
112 ##> modify_stmts |
112 #> (fn (names, stmts) => names ~~ modify_stmts (names ~~ stmts)); |
113 #> op ~~; |
|
114 val stmtss' = maps modify_stmts' (Graph.strong_conn nodes); |
113 val stmtss' = maps modify_stmts' (Graph.strong_conn nodes); |
115 val nodes'' = Graph.map (fn name => apsnd (fn Module content => Module (make_declarations nsps' content) |
114 val nodes'' = Graph.map (fn name => apsnd (fn Module content => Module (make_declarations nsps' content) |
116 | _ => case AList.lookup (op =) stmtss' name of SOME (SOME stmt) => Stmt stmt | _ => Dummy)) nodes'; |
115 | _ => case AList.lookup (op =) stmtss' name of SOME (SOME stmt) => Stmt stmt | _ => Dummy)) nodes'; |
117 val data' = fold memorize_data stmt_names data; |
116 val data' = fold memorize_data stmt_names data; |
118 in (data', nodes'') end; |
117 in (data', nodes'') end; |