src/Pure/Thy/sessions.scala
changeset 70673 b0172698d0d3
parent 70672 e4bba654d085
child 70674 29bb1ebb188f
equal deleted inserted replaced
70672:e4bba654d085 70673:b0172698d0d3
   131     }
   131     }
   132   }
   132   }
   133 
   133 
   134   object Base
   134   object Base
   135   {
   135   {
   136     def bootstrap(global_theories: Map[String, String]): Base =
   136     def bootstrap(
       
   137         session_directories: Map[JFile, (String, Boolean)],
       
   138         global_theories: Map[String, String]): Base =
   137       Base(
   139       Base(
       
   140         session_directories = session_directories,
   138         global_theories = global_theories,
   141         global_theories = global_theories,
   139         overall_syntax = Thy_Header.bootstrap_syntax)
   142         overall_syntax = Thy_Header.bootstrap_syntax)
   140   }
   143   }
   141 
   144 
   142   sealed case class Base(
   145   sealed case class Base(
   143     pos: Position.T = Position.none,
   146     pos: Position.T = Position.none,
   144     doc_names: List[String] = Nil,
   147     doc_names: List[String] = Nil,
       
   148     session_directories: Map[JFile, (String, Boolean)] = Map.empty,
   145     global_theories: Map[String, String] = Map.empty,
   149     global_theories: Map[String, String] = Map.empty,
   146     loaded_theories: Graph[String, Outer_Syntax] = Graph.string,
   150     loaded_theories: Graph[String, Outer_Syntax] = Graph.string,
   147     used_theories: List[((Document.Node.Name, Options), List[Document.Node.Name])] = Nil,
   151     used_theories: List[((Document.Node.Name, Options), List[Document.Node.Name])] = Nil,
   148     dump_checkpoints: Set[Document.Node.Name] = Set.empty,
   152     dump_checkpoints: Set[Document.Node.Name] = Set.empty,
   149     known: Known = Known.empty,
   153     known: Known = Known.empty,
   181 
   185 
   182     def dest_known_theories: List[(String, String)] =
   186     def dest_known_theories: List[(String, String)] =
   183       for ((theory, entry) <- known.theories.toList)
   187       for ((theory, entry) <- known.theories.toList)
   184         yield (theory, entry.name.node)
   188         yield (theory, entry.name.node)
   185 
   189 
   186     def get_imports: Base = imports getOrElse Base.bootstrap(global_theories)
   190     def get_imports: Base =
       
   191       imports getOrElse Base.bootstrap(session_directories, global_theories)
   187   }
   192   }
   188 
   193 
   189   sealed case class Deps(
   194   sealed case class Deps(
   190     sessions_structure: Structure, session_bases: Map[String, Base], all_known: Known)
   195     sessions_structure: Structure, session_bases: Map[String, Base], all_known: Known)
   191   {
   196   {
   287 
   292 
   288           val info = sessions_structure(session_name)
   293           val info = sessions_structure(session_name)
   289           try {
   294           try {
   290             val parent_base: Sessions.Base =
   295             val parent_base: Sessions.Base =
   291               info.parent match {
   296               info.parent match {
   292                 case None => Base.bootstrap(sessions_structure.global_theories)
   297                 case None =>
       
   298                   Base.bootstrap(
       
   299                     sessions_structure.session_directories,
       
   300                     sessions_structure.global_theories)
   293                 case Some(parent) => session_bases(parent)
   301                 case Some(parent) => session_bases(parent)
   294               }
   302               }
   295             val imports_base: Sessions.Base =
   303             val imports_base: Sessions.Base =
   296               parent_base.copy(known =
   304               parent_base.copy(known =
   297                 Known.make(info.dir, parent_base :: info.imports.map(session_bases(_))))
   305                 Known.make(info.dir, parent_base :: info.imports.map(session_bases(_))))
   384 
   392 
   385             val base =
   393             val base =
   386               Base(
   394               Base(
   387                 pos = info.pos,
   395                 pos = info.pos,
   388                 doc_names = doc_names,
   396                 doc_names = doc_names,
       
   397                 session_directories = sessions_structure.session_directories,
   389                 global_theories = sessions_structure.global_theories,
   398                 global_theories = sessions_structure.global_theories,
   390                 loaded_theories = dependencies.loaded_theories,
   399                 loaded_theories = dependencies.loaded_theories,
   391                 used_theories = used_theories,
   400                 used_theories = used_theories,
   392                 dump_checkpoints = dump_checkpoints,
   401                 dump_checkpoints = dump_checkpoints,
   393                 known = known,
   402                 known = known,