retrieve ML source files;
authorwenzelm
Thu, 04 Jun 2009 22:01:54 +0200
changeset 31436 dde1b4d1c95b
parent 31435 d24ef3ff34bc
child 31437 70309dc3deac
retrieve ML source files;
etc/settings
src/Pure/System/isabelle_system.scala
--- a/etc/settings	Thu Jun 04 19:15:57 2009 +0200
+++ b/etc/settings	Thu Jun 04 22:01:54 2009 +0200
@@ -27,7 +27,7 @@
   $POLY_HOME)
 ML_SYSTEM=$("$ISABELLE_HOME/lib/scripts/polyml-version")
 ML_OPTIONS="-H 200"
-ML_DBASE=""
+ML_SOURCES="$ML_HOME/../src"
 
 # Poly/ML 5.2.1
 #ML_PLATFORM=x86-linux
--- a/src/Pure/System/isabelle_system.scala	Thu Jun 04 19:15:57 2009 +0200
+++ b/src/Pure/System/isabelle_system.scala	Thu Jun 04 22:01:54 2009 +0200
@@ -80,7 +80,25 @@
     new File(platform_path(path))
 
 
-  /* processes */
+  /* source files */
+
+  private def try_file(file: File) = if (file.isFile) Some(file) else None
+
+  def source_file(path: String): Option[File] = {
+    if (path == "ML") None
+    else if (path.startsWith("/") || path == "")
+      try_file(platform_file(path))
+    else {
+      val pure_file = platform_file("~~/src/Pure/" + path)
+      if (pure_file.isFile) Some(pure_file)
+      else if (getenv("ML_SOURCES") != "")
+        try_file(platform_file("$ML_SOURCES/" + path))
+      else None
+    }
+  }
+
+
+  /* shell processes */
 
   def execute(redirect: Boolean, args: String*): Process = {
     val cmdline = new java.util.LinkedList[String]
@@ -149,7 +167,7 @@
 
   private def read_symbols(path: String) = {
     val file = new File(platform_path(path))
-    if (file.canRead) Source.fromFile(file).getLines
+    if (file.isFile) Source.fromFile(file).getLines
     else Iterator.empty
   }
   val symbols = new Symbol.Interpretation(