src/Pure/Tools/dump.scala
changeset 69896 be7243b97c41
parent 69857 a4b430ad848a
child 69897 a9849222844d
equal deleted inserted replaced
69895:6b03a8cf092d 69896:be7243b97c41
    12   /* aspects */
    12   /* aspects */
    13 
    13 
    14   sealed case class Aspect_Args(
    14   sealed case class Aspect_Args(
    15     options: Options,
    15     options: Options,
    16     progress: Progress,
    16     progress: Progress,
       
    17     output_dir: Path,
    17     deps: Sessions.Deps,
    18     deps: Sessions.Deps,
    18     output_dir: Path,
       
    19     snapshot: Document.Snapshot,
    19     snapshot: Document.Snapshot,
    20     status: Document_Status.Node_Status)
    20     status: Document_Status.Node_Status)
    21   {
    21   {
    22     def write(file_name: Path, bytes: Bytes)
    22     def write(file_name: Path, bytes: Bytes)
    23     {
    23     {
    88   }
    88   }
    89 
    89 
    90 
    90 
    91   /* session */
    91   /* session */
    92 
    92 
       
    93   sealed case class Args(
       
    94     deps: Sessions.Deps, snapshot: Document.Snapshot, status: Document_Status.Node_Status)
       
    95   {
       
    96     def print_node: String = snapshot.node_name.toString
       
    97 
       
    98     def aspect_args(options: Options, progress: Progress, output_dir: Path): Aspect_Args =
       
    99       Aspect_Args(options, progress, output_dir, deps, snapshot, status)
       
   100   }
       
   101 
    93   def session(
   102   def session(
    94     deps: Sessions.Deps,
   103     deps: Sessions.Deps,
    95     resources: Headless.Resources,
   104     resources: Headless.Resources,
    96     process_theory: (Sessions.Deps, Document.Snapshot, Document_Status.Node_Status) => Unit,
   105     process_theory: Args => Unit,
    97     progress: Progress = No_Progress)
   106     progress: Progress = No_Progress)
    98   {
   107   {
    99     /* asynchronous consumer */
   108     /* asynchronous consumer */
   100 
   109 
   101     object Consumer
   110     object Consumer
   112           consume = (args: (Document.Snapshot, Document_Status.Node_Status)) =>
   121           consume = (args: (Document.Snapshot, Document_Status.Node_Status)) =>
   113             {
   122             {
   114               val (snapshot, status) = args
   123               val (snapshot, status) = args
   115               val name = snapshot.node_name
   124               val name = snapshot.node_name
   116               if (status.ok) {
   125               if (status.ok) {
   117                 try { process_theory(deps, snapshot, status) }
   126                 try { process_theory(Args(deps, snapshot, status)) }
   118                 catch {
   127                 catch {
   119                   case exn: Throwable if !Exn.is_interrupt(exn) =>
   128                   case exn: Throwable if !Exn.is_interrupt(exn) =>
   120                   val msg = Exn.message(exn)
   129                   val msg = Exn.message(exn)
   121                   progress.echo("FAILED to process theory " + name)
   130                   progress.echo("FAILED to process theory " + name)
   122                   progress.echo_error_message(msg)
   131                   progress.echo_error_message(msg)
   212       Headless.Resources.make(dump_options, logic, progress = progress, log = log,
   221       Headless.Resources.make(dump_options, logic, progress = progress, log = log,
   213         session_dirs = dirs ::: select_dirs,
   222         session_dirs = dirs ::: select_dirs,
   214         include_sessions = deps.sessions_structure.imports_topological_order)
   223         include_sessions = deps.sessions_structure.imports_topological_order)
   215 
   224 
   216     session(deps, resources, progress = progress,
   225     session(deps, resources, progress = progress,
   217       process_theory =
   226       process_theory = (args: Args) =>
   218         (deps: Sessions.Deps, snapshot: Document.Snapshot, status: Document_Status.Node_Status) =>
       
   219         {
   227         {
   220           progress.echo("Processing theory " + snapshot.node_name + " ...")
   228           progress.echo("Processing theory " + args.print_node + " ...")
   221 
   229 
   222           val aspect_args = Aspect_Args(dump_options, progress, deps, output_dir, snapshot, status)
   230           val aspect_args = args.aspect_args(dump_options, progress, output_dir)
   223           aspects.foreach(_.operation(aspect_args))
   231           aspects.foreach(_.operation(aspect_args))
   224         })
   232         })
   225   }
   233   }
   226 
   234 
   227 
   235