444 (str "import /*implicits*/" :: Pretty.brk 1 :: Pretty.commas (map (str o deresolve) implicits)); |
444 (str "import /*implicits*/" :: Pretty.brk 1 :: Pretty.commas (map (str o deresolve) implicits)); |
445 fun print_module base implicits p = Pretty.chunks2 |
445 fun print_module base implicits p = Pretty.chunks2 |
446 ([str ("object " ^ base ^ " {")] @ the_list (print_implicits implicits) |
446 ([str ("object " ^ base ^ " {")] @ the_list (print_implicits implicits) |
447 @ [p, str ("} /* object " ^ base ^ " */")]); |
447 @ [p, str ("} /* object " ^ base ^ " */")]); |
448 fun print_node (_, Dummy) = NONE |
448 fun print_node (_, Dummy) = NONE |
449 | print_node (name, Stmt stmt) = if not (not (null presentation_stmt_names) |
449 | print_node (name, Stmt stmt) = if null presentation_stmt_names |
450 andalso member (op =) presentation_stmt_names name) |
450 orelse member (op =) presentation_stmt_names name |
451 then SOME (print_stmt (name, stmt)) |
451 then SOME (print_stmt (name, stmt)) |
452 else NONE |
452 else NONE |
453 | print_node (name, Module (_, (implicits, nodes))) = if null presentation_stmt_names |
453 | print_node (name, Module (_, (implicits, nodes))) = if null presentation_stmt_names |
454 then case print_nodes nodes |
454 then case print_nodes nodes |
455 of NONE => NONE |
455 of NONE => NONE |
460 snd (Graph.get_node nodes name))) |
460 snd (Graph.get_node nodes name))) |
461 ((rev o flat o Graph.strong_conn) nodes); |
461 ((rev o flat o Graph.strong_conn) nodes); |
462 in if null ps then NONE else SOME (Pretty.chunks2 ps) end; |
462 in if null ps then NONE else SOME (Pretty.chunks2 ps) end; |
463 |
463 |
464 (* serialization *) |
464 (* serialization *) |
465 val p = Pretty.chunks2 (map (fn (base, p) => print_module base [] p) includes |
465 val p_includes = if null presentation_stmt_names |
466 @ the_list (print_nodes sca_program)); |
466 then map (fn (base, p) => print_module base [] p) includes else []; |
|
467 val p = Pretty.chunks2 (p_includes @ the_list (print_nodes sca_program)); |
467 in |
468 in |
468 Code_Target.mk_serialization target |
469 Code_Target.mk_serialization target |
469 (fn NONE => code_writeln | SOME file => File.write file o code_of_pretty) |
470 (fn NONE => code_writeln | SOME file => File.write file o code_of_pretty) |
470 (rpair [] o code_of_pretty) p destination |
471 (rpair [] o code_of_pretty) p destination |
471 end; |
472 end; |