src/Pure/Thy/sessions.scala
changeset 70647 3047b7671279
parent 70645 fc27cecb66d8
child 70650 fa04b549f652
equal deleted inserted replaced
70646:a4d265a6c5cc 70647:3047b7671279
   118         files = for ((a, b) <- files) yield (a, b.map(c => c.map(File.standard_path(_)))))
   118         files = for ((a, b) <- files) yield (a, b.map(c => c.map(File.standard_path(_)))))
   119 
   119 
   120     def theory_names: List[Document.Node.Name] = theories.iterator.map(p => p._2.name).toList
   120     def theory_names: List[Document.Node.Name] = theories.iterator.map(p => p._2.name).toList
   121 
   121 
   122     lazy val theory_graph: Graph[Document.Node.Name, Unit] =
   122     lazy val theory_graph: Graph[Document.Node.Name, Unit] =
   123     {
   123       Document.theory_graph(
   124       val entries =
       
   125         for ((_, entry) <- theories.toList)
   124         for ((_, entry) <- theories.toList)
   126         yield ((entry.name, ()), entry.header.imports.map(imp => theories(imp.theory).name))
   125         yield ((entry.name, ()), entry.header.imports.map(imp => theories(imp.theory).name)))
   127       Graph.make(entries, symmetric = true)(Document.Node.Name.Theory_Ordering)
       
   128     }
       
   129 
   126 
   130     def get_file(file: JFile, bootstrap: Boolean = false): Option[Document.Node.Name] =
   127     def get_file(file: JFile, bootstrap: Boolean = false): Option[Document.Node.Name] =
   131     {
   128     {
   132       val res = files.getOrElse(File.canonical(file), Nil).headOption
   129       val res = files.getOrElse(File.canonical(file), Nil).headOption
   133       if (bootstrap) res.map(_.map_theory(Thy_Header.bootstrap_name(_))) else res
   130       if (bootstrap) res.map(_.map_theory(Thy_Header.bootstrap_name(_))) else res
   209 
   206 
   210     def used_theories_condition(default_options: Options, progress: Progress = No_Progress)
   207     def used_theories_condition(default_options: Options, progress: Progress = No_Progress)
   211       : Graph[Document.Node.Name, Options] =
   208       : Graph[Document.Node.Name, Options] =
   212     {
   209     {
   213       val default_skip_proofs = default_options.bool("skip_proofs")
   210       val default_skip_proofs = default_options.bool("skip_proofs")
   214       val used =
   211       Document.theory_graph(
   215         for {
   212         permissive = true,
   216           session_name <- sessions_structure.build_topological_order
   213         entries =
   217           entry @ ((name, options), _) <- session_bases(session_name).used_theories
   214           for {
   218           if {
   215             session_name <- sessions_structure.build_topological_order
   219             def warn(msg: String): Unit =
   216             entry @ ((name, options), _) <- session_bases(session_name).used_theories
   220               progress.echo_warning("Skipping theory " + name + "  (" + msg + ")")
   217             if {
   221 
   218               def warn(msg: String): Unit =
   222             val conditions =
   219                 progress.echo_warning("Skipping theory " + name + "  (" + msg + ")")
   223               space_explode(',', options.string("condition")).
   220 
   224                 filter(cond => Isabelle_System.getenv(cond) == "")
   221               val conditions =
   225             if (conditions.nonEmpty) {
   222                 space_explode(',', options.string("condition")).
   226               warn("undefined " + conditions.mkString(", "))
   223                   filter(cond => Isabelle_System.getenv(cond) == "")
   227               false
   224               if (conditions.nonEmpty) {
       
   225                 warn("undefined " + conditions.mkString(", "))
       
   226                 false
       
   227               }
       
   228               else if (default_skip_proofs && !options.bool("skip_proofs")) {
       
   229                 warn("option skip_proofs")
       
   230                 false
       
   231               }
       
   232               else true
   228             }
   233             }
   229             else if (default_skip_proofs && !options.bool("skip_proofs")) {
   234           } yield entry)
   230               warn("option skip_proofs")
       
   231               false
       
   232             }
       
   233             else true
       
   234           }
       
   235         } yield entry
       
   236       Graph.make[Document.Node.Name, Options](used, symmetric = true, permissive = true)(
       
   237         Document.Node.Name.Theory_Ordering)
       
   238     }
   235     }
   239 
   236 
   240     def sources(name: String): List[SHA1.Digest] =
   237     def sources(name: String): List[SHA1.Digest] =
   241       session_bases(name).sources.map(_._2)
   238       session_bases(name).sources.map(_._2)
   242 
   239