src/Tools/Code/code_namespace.ML
changeset 55147 bce3dbc11f95
parent 53414 dd64696d267a
child 55150 0940309ed8f1
     1.1 --- a/src/Tools/Code/code_namespace.ML	Sat Jan 25 23:50:49 2014 +0100
     1.2 +++ b/src/Tools/Code/code_namespace.ML	Sat Jan 25 23:50:49 2014 +0100
     1.3 @@ -7,32 +7,32 @@
     1.4  signature CODE_NAMESPACE =
     1.5  sig
     1.6    type flat_program
     1.7 -  val flat_program: Proof.context -> (string -> Code_Symbol.symbol)
     1.8 +  val flat_program: Proof.context
     1.9      -> { module_prefix: string, module_name: string,
    1.10      reserved: Name.context, identifiers: Code_Target.identifier_data, empty_nsp: 'a,
    1.11      namify_stmt: Code_Thingol.stmt -> string -> 'a -> string * 'a,
    1.12      modify_stmt: Code_Thingol.stmt -> Code_Thingol.stmt option }
    1.13        -> Code_Thingol.program
    1.14 -      -> { deresolver: string -> string -> string,
    1.15 +      -> { deresolver: string -> Code_Symbol.symbol -> string,
    1.16             flat_program: flat_program }
    1.17  
    1.18    datatype ('a, 'b) node =
    1.19        Dummy
    1.20      | Stmt of 'a
    1.21 -    | Module of ('b * (string * ('a, 'b) node) Graph.T)
    1.22 +    | Module of ('b * (string * ('a, 'b) node) Code_Symbol.Graph.T)
    1.23    type ('a, 'b) hierarchical_program
    1.24 -  val hierarchical_program: Proof.context -> (string -> Code_Symbol.symbol)
    1.25 +  val hierarchical_program: Proof.context
    1.26      -> { module_name: string,
    1.27      reserved: Name.context, identifiers: Code_Target.identifier_data,
    1.28      empty_nsp: 'c, namify_module: string -> 'c -> string * 'c,
    1.29      namify_stmt: Code_Thingol.stmt -> string -> 'c -> string * 'c,
    1.30 -    cyclic_modules: bool, empty_data: 'b, memorize_data: string -> 'b -> 'b,
    1.31 -    modify_stmts: (string * Code_Thingol.stmt) list -> 'a option list }
    1.32 +    cyclic_modules: bool, empty_data: 'b, memorize_data: Code_Symbol.symbol -> 'b -> 'b,
    1.33 +    modify_stmts: (Code_Symbol.symbol * Code_Thingol.stmt) list -> 'a option list }
    1.34        -> Code_Thingol.program
    1.35 -      -> { deresolver: string list -> string -> string,
    1.36 +      -> { deresolver: string list -> Code_Symbol.symbol -> string,
    1.37             hierarchical_program: ('a, 'b) hierarchical_program }
    1.38    val print_hierarchical: { print_module: string list -> string -> 'b -> 'c list -> 'c,
    1.39 -    print_stmt: string list -> string * 'a -> 'c,
    1.40 +    print_stmt: string list -> Code_Symbol.symbol * 'a -> 'c,
    1.41      lift_markup: (Pretty.T -> Pretty.T) -> 'c -> 'c }
    1.42        -> ('a, 'b) hierarchical_program -> 'c list
    1.43  end;
    1.44 @@ -42,24 +42,22 @@
    1.45  
    1.46  (** fundamental module name hierarchy **)
    1.47  
    1.48 -val split_name = apfst Long_Name.implode o split_last o fst o split_last o Long_Name.explode;
    1.49 -
    1.50 -fun lookup_identifier symbol_of identifiers name =
    1.51 -  Code_Symbol.lookup identifiers (symbol_of name)
    1.52 +fun lookup_identifier identifiers sym =
    1.53 +  Code_Symbol.lookup identifiers sym
    1.54    |> Option.map (split_last o Long_Name.explode);
    1.55  
    1.56 -fun force_identifier symbol_of fragments_tab force_module identifiers name =
    1.57 -  case lookup_identifier symbol_of identifiers name of
    1.58 -      NONE => (apfst (the o Symtab.lookup fragments_tab) o split_name) name
    1.59 +fun force_identifier ctxt fragments_tab force_module identifiers sym =
    1.60 +  case lookup_identifier identifiers sym of
    1.61 +      NONE => ((the o Symtab.lookup fragments_tab o Code_Symbol.namespace_prefix ctxt) sym, Code_Symbol.base_name sym)
    1.62      | SOME prefix_name => if null force_module then prefix_name
    1.63          else (force_module, snd prefix_name);
    1.64  
    1.65 -fun build_module_namespace { module_prefix, module_identifiers, reserved } program =
    1.66 +fun build_module_namespace ctxt { module_prefix, module_identifiers, reserved } program =
    1.67    let
    1.68      fun alias_fragments name = case module_identifiers name
    1.69       of SOME name' => Long_Name.explode name'
    1.70        | NONE => map (fn name => fst (Name.variant name reserved)) (Long_Name.explode name);
    1.71 -    val module_names = Graph.fold (insert (op =) o fst o split_name o fst) program [];
    1.72 +    val module_names = Code_Symbol.Graph.fold (insert (op =) o Code_Symbol.namespace_prefix ctxt o fst) program [];
    1.73    in
    1.74      fold (fn name => Symtab.update (name, Long_Name.explode module_prefix @ alias_fragments name))
    1.75        module_names Symtab.empty
    1.76 @@ -68,9 +66,9 @@
    1.77  
    1.78  (** flat program structure **)
    1.79  
    1.80 -type flat_program = ((string * Code_Thingol.stmt option) Graph.T * (string * string list) list) Graph.T;
    1.81 +type flat_program = ((string * Code_Thingol.stmt option) Code_Symbol.Graph.T * (string * Code_Symbol.symbol list) list) Graph.T;
    1.82  
    1.83 -fun flat_program ctxt symbol_of { module_prefix, module_name, reserved,
    1.84 +fun flat_program ctxt { module_prefix, module_name, reserved,
    1.85      identifiers, empty_nsp, namify_stmt, modify_stmt } program =
    1.86    let
    1.87  
    1.88 @@ -78,70 +76,70 @@
    1.89      val module_identifiers = if module_name = ""
    1.90        then Code_Symbol.lookup_module_data identifiers
    1.91        else K (SOME module_name);
    1.92 -    val fragments_tab = build_module_namespace { module_prefix = module_prefix,
    1.93 +    val fragments_tab = build_module_namespace ctxt { module_prefix = module_prefix,
    1.94        module_identifiers = module_identifiers, reserved = reserved } program;
    1.95 -    val prep_name = force_identifier symbol_of fragments_tab (Long_Name.explode module_name) identifiers
    1.96 +    val prep_sym = force_identifier ctxt fragments_tab (Long_Name.explode module_name) identifiers
    1.97        #>> Long_Name.implode;
    1.98  
    1.99      (* distribute statements over hierarchy *)
   1.100 -    fun add_stmt name stmt =
   1.101 +    fun add_stmt sym stmt =
   1.102        let
   1.103 -        val (module_name, base) = prep_name name;
   1.104 +        val (module_name, base) = prep_sym sym;
   1.105        in
   1.106 -        Graph.default_node (module_name, (Graph.empty, []))
   1.107 -        #> (Graph.map_node module_name o apfst) (Graph.new_node (name, (base, stmt)))
   1.108 +        Graph.default_node (module_name, (Code_Symbol.Graph.empty, []))
   1.109 +        #> (Graph.map_node module_name o apfst) (Code_Symbol.Graph.new_node (sym, (base, stmt)))
   1.110        end;
   1.111 -    fun add_dependency name name' =
   1.112 +    fun add_dependency sym sym' =
   1.113        let
   1.114 -        val (module_name, _) = prep_name name;
   1.115 -        val (module_name', _) = prep_name name';
   1.116 +        val (module_name, _) = prep_sym sym;
   1.117 +        val (module_name', _) = prep_sym sym';
   1.118        in if module_name = module_name'
   1.119 -        then (Graph.map_node module_name o apfst) (Graph.add_edge (name, name'))
   1.120 -        else (Graph.map_node module_name o apsnd) (AList.map_default (op =) (module_name', []) (insert (op =) name'))
   1.121 +        then (Graph.map_node module_name o apfst) (Code_Symbol.Graph.add_edge (sym, sym'))
   1.122 +        else (Graph.map_node module_name o apsnd) (AList.map_default (op =) (module_name', []) (insert (op =) sym'))
   1.123        end;
   1.124      val proto_program = Graph.empty
   1.125 -      |> Graph.fold (fn (name, (stmt, _)) => add_stmt name stmt) program
   1.126 -      |> Graph.fold (fn (name, (_, (_, names))) =>
   1.127 -          Graph.Keys.fold (add_dependency name) names) program;
   1.128 +      |> Code_Symbol.Graph.fold (fn (sym, (stmt, _)) => add_stmt sym stmt) program
   1.129 +      |> Code_Symbol.Graph.fold (fn (sym, (_, (_, syms))) =>
   1.130 +          Code_Symbol.Graph.Keys.fold (add_dependency sym) syms) program;
   1.131  
   1.132      (* name declarations and statement modifications *)
   1.133 -    fun declare name (base, stmt) (gr, nsp) = 
   1.134 +    fun declare sym (base, stmt) (gr, nsp) = 
   1.135        let
   1.136          val (base', nsp') = namify_stmt stmt base nsp;
   1.137 -        val gr' = (Graph.map_node name o apfst) (K base') gr;
   1.138 +        val gr' = (Code_Symbol.Graph.map_node sym o apfst) (K base') gr;
   1.139        in (gr', nsp') end;
   1.140      fun declarations gr = (gr, empty_nsp)
   1.141 -      |> fold (fn name => declare name (Graph.get_node gr name)) (Graph.keys gr) 
   1.142 +      |> fold (fn sym => declare sym (Code_Symbol.Graph.get_node gr sym)) (Code_Symbol.Graph.keys gr) 
   1.143        |> fst
   1.144 -      |> (Graph.map o K o apsnd) modify_stmt;
   1.145 +      |> (Code_Symbol.Graph.map o K o apsnd) modify_stmt;
   1.146      val flat_program = proto_program
   1.147        |> (Graph.map o K o apfst) declarations;
   1.148  
   1.149      (* qualified and unqualified imports, deresolving *)
   1.150 -    fun base_deresolver name = fst (Graph.get_node
   1.151 -      (fst (Graph.get_node flat_program (fst (prep_name name)))) name);
   1.152 +    fun base_deresolver sym = fst (Code_Symbol.Graph.get_node
   1.153 +      (fst (Graph.get_node flat_program (fst (prep_sym sym)))) sym);
   1.154      fun classify_names gr imports =
   1.155        let
   1.156          val import_tab = maps
   1.157 -          (fn (module_name, names) => map (rpair module_name) names) imports;
   1.158 -        val imported_names = map fst import_tab;
   1.159 -        val here_names = Graph.keys gr;
   1.160 +          (fn (module_name, syms) => map (rpair module_name) syms) imports;
   1.161 +        val imported_syms = map fst import_tab;
   1.162 +        val here_syms = Code_Symbol.Graph.keys gr;
   1.163        in
   1.164 -        Symtab.empty
   1.165 -        |> fold (fn name => Symtab.update (name, base_deresolver name)) here_names
   1.166 -        |> fold (fn name => Symtab.update (name,
   1.167 -            Long_Name.append (the (AList.lookup (op =) import_tab name))
   1.168 -              (base_deresolver name))) imported_names
   1.169 +        Code_Symbol.Table.empty
   1.170 +        |> fold (fn sym => Code_Symbol.Table.update (sym, base_deresolver sym)) here_syms
   1.171 +        |> fold (fn sym => Code_Symbol.Table.update (sym,
   1.172 +            Long_Name.append (the (AList.lookup (op =) import_tab sym))
   1.173 +              (base_deresolver sym))) imported_syms
   1.174        end;
   1.175      val deresolver_tab = Symtab.make (AList.make
   1.176        (uncurry classify_names o Graph.get_node flat_program)
   1.177          (Graph.keys flat_program));
   1.178 -    fun deresolver "" name =
   1.179 -          Long_Name.append (fst (prep_name name)) (base_deresolver name)
   1.180 -      | deresolver module_name name =
   1.181 -          the (Symtab.lookup (the (Symtab.lookup deresolver_tab module_name)) name)
   1.182 +    fun deresolver "" sym =
   1.183 +          Long_Name.append (fst (prep_sym sym)) (base_deresolver sym)
   1.184 +      | deresolver module_name sym =
   1.185 +          the (Code_Symbol.Table.lookup (the (Symtab.lookup deresolver_tab module_name)) sym)
   1.186            handle Option.Option => error ("Unknown statement name: "
   1.187 -            ^ (Code_Symbol.quote_symbol ctxt o symbol_of) name);
   1.188 +            ^ Code_Symbol.quote ctxt sym);
   1.189  
   1.190    in { deresolver = deresolver, flat_program = flat_program } end;
   1.191  
   1.192 @@ -151,18 +149,18 @@
   1.193  datatype ('a, 'b) node =
   1.194      Dummy
   1.195    | Stmt of 'a
   1.196 -  | Module of ('b * (string * ('a, 'b) node) Graph.T);
   1.197 +  | Module of ('b * (string * ('a, 'b) node) Code_Symbol.Graph.T);
   1.198  
   1.199 -type ('a, 'b) hierarchical_program = (string * ('a, 'b) node) Graph.T;
   1.200 +type ('a, 'b) hierarchical_program = (string * ('a, 'b) node) Code_Symbol.Graph.T;
   1.201  
   1.202  fun map_module_content f (Module content) = Module (f content);
   1.203  
   1.204  fun map_module [] = I
   1.205    | map_module (name_fragment :: name_fragments) =
   1.206 -      apsnd o Graph.map_node name_fragment o apsnd o map_module_content
   1.207 +      apsnd o Code_Symbol.Graph.map_node (Code_Symbol.Module name_fragment) o apsnd o map_module_content
   1.208          o map_module name_fragments;
   1.209  
   1.210 -fun hierarchical_program ctxt symbol_of { module_name, reserved, identifiers, empty_nsp,
   1.211 +fun hierarchical_program ctxt { module_name, reserved, identifiers, empty_nsp,
   1.212        namify_module, namify_stmt, cyclic_modules, empty_data, memorize_data, modify_stmts } program =
   1.213    let
   1.214  
   1.215 @@ -170,95 +168,95 @@
   1.216      val module_identifiers = if module_name = ""
   1.217        then Code_Symbol.lookup_module_data identifiers
   1.218        else K (SOME module_name);
   1.219 -    val fragments_tab = build_module_namespace { module_prefix = "",
   1.220 +    val fragments_tab = build_module_namespace ctxt { module_prefix = "",
   1.221        module_identifiers = module_identifiers, reserved = reserved } program;
   1.222 -    val prep_name = force_identifier symbol_of fragments_tab (Long_Name.explode module_name) identifiers;
   1.223 +    val prep_sym = force_identifier ctxt fragments_tab (Long_Name.explode module_name) identifiers;
   1.224  
   1.225      (* building empty module hierarchy *)
   1.226 -    val empty_module = (empty_data, Graph.empty);
   1.227 +    val empty_module = (empty_data, Code_Symbol.Graph.empty);
   1.228      fun ensure_module name_fragment (data, nodes) =
   1.229 -      if can (Graph.get_node nodes) name_fragment then (data, nodes)
   1.230 +      if can (Code_Symbol.Graph.get_node nodes) (Code_Symbol.Module name_fragment) then (data, nodes)
   1.231        else (data,
   1.232 -        nodes |> Graph.new_node (name_fragment, (name_fragment, Module empty_module)));
   1.233 +        nodes |> Code_Symbol.Graph.new_node (Code_Symbol.Module name_fragment, (name_fragment, Module empty_module)));
   1.234      fun allocate_module [] = I
   1.235        | allocate_module (name_fragment :: name_fragments) =
   1.236            ensure_module name_fragment
   1.237 -          #> (apsnd o Graph.map_node name_fragment o apsnd o map_module_content o allocate_module) name_fragments;
   1.238 +          #> (apsnd o Code_Symbol.Graph.map_node (Code_Symbol.Module name_fragment) o apsnd o map_module_content o allocate_module) name_fragments;
   1.239      val empty_program =
   1.240        empty_module
   1.241        |> Symtab.fold (fn (_, fragments) => allocate_module fragments) fragments_tab
   1.242 -      |> Graph.fold (allocate_module o these o Option.map fst
   1.243 -          o lookup_identifier symbol_of identifiers o fst) program;
   1.244 +      |> Code_Symbol.Graph.fold (allocate_module o these o Option.map fst
   1.245 +          o lookup_identifier identifiers o fst) program;
   1.246  
   1.247      (* distribute statements over hierarchy *)
   1.248 -    fun add_stmt name stmt =
   1.249 +    fun add_stmt sym stmt =
   1.250        let
   1.251 -        val (name_fragments, base) = prep_name name;
   1.252 +        val (name_fragments, base) = prep_sym sym;
   1.253        in
   1.254 -        (map_module name_fragments o apsnd) (Graph.new_node (name, (base, Stmt stmt)))
   1.255 +        (map_module name_fragments o apsnd) (Code_Symbol.Graph.new_node (sym, (base, Stmt stmt)))
   1.256        end;
   1.257 -    fun add_dependency name name' =
   1.258 +    fun add_dependency sym sym' =
   1.259        let
   1.260 -        val (name_fragments, _) = prep_name name;
   1.261 -        val (name_fragments', _) = prep_name name';
   1.262 +        val (name_fragments, _) = prep_sym sym;
   1.263 +        val (name_fragments', _) = prep_sym sym';
   1.264          val (name_fragments_common, (diff, diff')) =
   1.265            chop_prefix (op =) (name_fragments, name_fragments');
   1.266          val is_module = not (null diff andalso null diff');
   1.267 -        val dep = pairself hd (diff @ [name], diff' @ [name']);
   1.268 +        val dep = pairself hd (map Code_Symbol.Module diff @ [sym], map Code_Symbol.Module diff' @ [sym']);
   1.269          val add_edge = if is_module andalso not cyclic_modules
   1.270 -          then (fn node => Graph.add_edge_acyclic dep node
   1.271 +          then (fn node => Code_Symbol.Graph.add_edge_acyclic dep node
   1.272              handle Graph.CYCLES _ => error ("Dependency "
   1.273 -              ^ (Code_Symbol.quote_symbol ctxt o symbol_of) name ^ " -> "
   1.274 -              ^ (Code_Symbol.quote_symbol ctxt o symbol_of) name'
   1.275 +              ^ Code_Symbol.quote ctxt sym ^ " -> "
   1.276 +              ^ Code_Symbol.quote ctxt sym'
   1.277                ^ " would result in module dependency cycle"))
   1.278 -          else Graph.add_edge dep
   1.279 +          else Code_Symbol.Graph.add_edge dep
   1.280        in (map_module name_fragments_common o apsnd) add_edge end;
   1.281      val proto_program = empty_program
   1.282 -      |> Graph.fold (fn (name, (stmt, _)) => add_stmt name stmt) program
   1.283 -      |> Graph.fold (fn (name, (_, (_, names))) =>
   1.284 -          Graph.Keys.fold (add_dependency name) names) program;
   1.285 +      |> Code_Symbol.Graph.fold (fn (sym, (stmt, _)) => add_stmt sym stmt) program
   1.286 +      |> Code_Symbol.Graph.fold (fn (sym, (_, (_, syms))) =>
   1.287 +          Code_Symbol.Graph.Keys.fold (add_dependency sym) syms) program;
   1.288  
   1.289      (* name declarations, data and statement modifications *)
   1.290      fun make_declarations nsps (data, nodes) =
   1.291        let
   1.292 -        val (module_fragments, stmt_names) = List.partition
   1.293 -          (fn name_fragment => case Graph.get_node nodes name_fragment
   1.294 -            of (_, Module _) => true | _ => false) (Graph.keys nodes);
   1.295 -        fun declare namify name (nsps, nodes) =
   1.296 +        val (module_fragments, stmt_syms) = List.partition
   1.297 +          (fn sym => case Code_Symbol.Graph.get_node nodes sym
   1.298 +            of (_, Module _) => true | _ => false) (Code_Symbol.Graph.keys nodes);
   1.299 +        fun declare namify sym (nsps, nodes) =
   1.300            let
   1.301 -            val (base, node) = Graph.get_node nodes name;
   1.302 +            val (base, node) = Code_Symbol.Graph.get_node nodes sym;
   1.303              val (base', nsps') = namify node base nsps;
   1.304 -            val nodes' = Graph.map_node name (K (base', node)) nodes;
   1.305 +            val nodes' = Code_Symbol.Graph.map_node sym (K (base', node)) nodes;
   1.306            in (nsps', nodes') end;
   1.307          val (nsps', nodes') = (nsps, nodes)
   1.308            |> fold (declare (K namify_module)) module_fragments
   1.309 -          |> fold (declare (namify_stmt o (fn Stmt stmt => stmt))) stmt_names;
   1.310 +          |> fold (declare (namify_stmt o (fn Stmt stmt => stmt))) stmt_syms;
   1.311          fun zip_fillup xs ys = xs ~~ ys @ replicate (length xs - length ys) NONE;
   1.312 -        fun select_names names = case filter (member (op =) stmt_names) names
   1.313 +        fun select_syms syms = case filter (member (op =) stmt_syms) syms
   1.314           of [] => NONE
   1.315 -          | xs => SOME xs;
   1.316 -        val modify_stmts' = AList.make (snd o Graph.get_node nodes)
   1.317 +          | syms => SOME syms;
   1.318 +        val modify_stmts' = AList.make (snd o Code_Symbol.Graph.get_node nodes)
   1.319            #> split_list
   1.320            ##> map (fn Stmt stmt => stmt)
   1.321 -          #> (fn (names, stmts) => zip_fillup names (modify_stmts (names ~~ stmts)));
   1.322 -        val stmtss' = (maps modify_stmts' o map_filter select_names o Graph.strong_conn) nodes;
   1.323 -        val nodes'' = Graph.map (fn name => apsnd (fn Module content => Module (make_declarations nsps' content)
   1.324 -            | _ => case AList.lookup (op =) stmtss' name of SOME (SOME stmt) => Stmt stmt | _ => Dummy)) nodes';
   1.325 -        val data' = fold memorize_data stmt_names data;
   1.326 +          #> (fn (syms, stmts) => zip_fillup syms (modify_stmts (syms ~~ stmts)));
   1.327 +        val stmtss' = (maps modify_stmts' o map_filter select_syms o Code_Symbol.Graph.strong_conn) nodes;
   1.328 +        val nodes'' = Code_Symbol.Graph.map (fn sym => apsnd (fn Module content => Module (make_declarations nsps' content)
   1.329 +            | _ => case AList.lookup (op =) stmtss' sym of SOME (SOME stmt) => Stmt stmt | _ => Dummy)) nodes';
   1.330 +        val data' = fold memorize_data stmt_syms data;
   1.331        in (data', nodes'') end;
   1.332      val (_, hierarchical_program) = make_declarations empty_nsp proto_program;
   1.333  
   1.334      (* deresolving *)
   1.335 -    fun deresolver prefix_fragments name =
   1.336 +    fun deresolver prefix_fragments sym =
   1.337        let
   1.338 -        val (name_fragments, _) = prep_name name;
   1.339 +        val (name_fragments, _) = prep_sym sym;
   1.340          val (_, (_, remainder)) = chop_prefix (op =) (prefix_fragments, name_fragments);
   1.341 -        val nodes = fold (fn name_fragment => fn nodes => case Graph.get_node nodes name_fragment
   1.342 +        val nodes = fold (fn name_fragment => fn nodes => case Code_Symbol.Graph.get_node nodes (Code_Symbol.Module name_fragment)
   1.343           of (_, Module (_, nodes)) => nodes) name_fragments hierarchical_program;
   1.344 -        val (base', _) = Graph.get_node nodes name;
   1.345 +        val (base', _) = Code_Symbol.Graph.get_node nodes sym;
   1.346        in Long_Name.implode (remainder @ [base']) end
   1.347 -        handle Graph.UNDEF _ => error ("Unknown statement name: "
   1.348 -          ^ (Code_Symbol.quote_symbol ctxt o symbol_of) name);
   1.349 +        handle Code_Symbol.Graph.UNDEF _ => error ("Unknown statement name: "
   1.350 +          ^ Code_Symbol.quote ctxt sym);
   1.351  
   1.352    in { deresolver = deresolver, hierarchical_program = hierarchical_program } end;
   1.353  
   1.354 @@ -266,10 +264,10 @@
   1.355    let
   1.356      fun print_node _ (_, Dummy) =
   1.357            NONE
   1.358 -      | print_node prefix_fragments (name, Stmt stmt) =
   1.359 -          SOME (lift_markup (Code_Printer.markup_stmt name)
   1.360 -            (print_stmt prefix_fragments (name, stmt)))
   1.361 -      | print_node prefix_fragments (name_fragment, Module (data, nodes)) =
   1.362 +      | print_node prefix_fragments (sym, Stmt stmt) =
   1.363 +          SOME (lift_markup (Code_Printer.markup_stmt sym)
   1.364 +            (print_stmt prefix_fragments (sym, stmt)))
   1.365 +      | print_node prefix_fragments (Code_Symbol.Module name_fragment, Module (data, nodes)) =
   1.366            let
   1.367              val prefix_fragments' = prefix_fragments @ [name_fragment]
   1.368            in
   1.369 @@ -278,9 +276,9 @@
   1.370            end
   1.371      and print_nodes prefix_fragments nodes =
   1.372        let
   1.373 -        val xs = (map_filter (fn name => print_node prefix_fragments
   1.374 -          (name, snd (Graph.get_node nodes name))) o rev o flat o Graph.strong_conn) nodes
   1.375 +        val xs = (map_filter (fn sym => print_node prefix_fragments
   1.376 +          (sym, snd (Code_Symbol.Graph.get_node nodes sym))) o rev o flat o Code_Symbol.Graph.strong_conn) nodes
   1.377        in if null xs then NONE else SOME xs end;
   1.378    in these o print_nodes [] end;
   1.379  
   1.380 -end;
   1.381 \ No newline at end of file
   1.382 +end;