rearrangements to make latest Poly/ML the default, not old 4.x;
authorwenzelm
Thu, 06 Mar 2008 19:21:26 +0100
changeset 26215 94d32a7cd0fb
parent 26214 73ed8cb8ac4d
child 26216 c7d0cd2c7715
rearrangements to make latest Poly/ML the default, not old 4.x;
lib/scripts/run-polyml
lib/scripts/run-polyml-4.1.3
lib/scripts/run-polyml-4.1.4
lib/scripts/run-polyml-4.2.0
lib/scripts/run-polyml-5.1
src/Pure/ML-Systems/polyml-4.1.3.ML
src/Pure/ML-Systems/polyml-4.1.4.ML
src/Pure/ML-Systems/polyml-4.2.0.ML
src/Pure/ML-Systems/polyml-5.0.ML
src/Pure/ML-Systems/polyml-5.1.ML
src/Pure/ML-Systems/polyml.ML
src/Pure/ML-Systems/polyml_common.ML
--- a/lib/scripts/run-polyml	Thu Mar 06 19:21:25 2008 +0100
+++ b/lib/scripts/run-polyml	Thu Mar 06 19:21:26 2008 +0100
@@ -1,9 +1,9 @@
 #!/usr/bin/env bash
 #
 # $Id$
-# Author: Markus Wenzel, TU Muenchen
+# Author: Makarius
 #
-# Poly/ML startup script.
+# Poly/ML 5.1/5.2 startup script.
 
 export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
 
@@ -26,82 +26,59 @@
 }
 
 
-## Poly/ML executable and database
-
-ML_DBASE_PREFIX=""
+## compiler executables and libraries
 
 POLY="$ML_HOME/poly"
 check_file "$POLY"
 
-if [ -z "$ML_DBASE" ]; then
-  if [ ! -e "$ML_HOME/ML_dbase" -a "$(basename "$ML_HOME")" = bin ]; then
-    ML_DBASE_HOME="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib/poly; pwd)"
-  else
-    ML_DBASE_HOME="$ML_HOME"
-  fi
-  if [ -z "$COPYDB" ]; then
-    ML_DBASE_PREFIX="$ML_DBASE_HOME/"
-    ML_DBASE="ML_dbase"
-  else
-    ML_DBASE="$ML_DBASE_HOME/ML_dbase"
-  fi
-  export POLYPATH="$ML_DBASE_HOME"
+if [ "$(basename "$ML_HOME")" = bin ]; then
+  POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)"
 else
-  export POLYPATH="$(dirname "$ML_DBASE")"
+  POLYLIB="$ML_HOME"
 fi
 
-DISCGARB_OPTIONS="-d -c"
-
-EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
+export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH"
+export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH"
 
 
 ## prepare databases
 
 if [ -z "$INFILE" ]; then
-  check_file "$ML_DBASE_PREFIX$ML_DBASE"
-  INFILE="$ML_DBASE"
-  MLTEXT="val use = PolyML.use; $EXIT $MLTEXT"
-  DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S max"
+  INIT=""
+  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
 else
-  COPYDB=true
+  check_file "$INFILE"
+  INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle Fail msg => (TextIO.output (TextIO.stdErr, msg ^ \"\\n\"); OS.Process.exit OS.Process.failure));"
+  EXIT=""
 fi
 
 if [ -z "$OUTFILE" ]; then
-  DB="$INFILE"
-  ML_OPTIONS="-r $ML_OPTIONS"
-elif [ "$INFILE" -ef "$OUTFILE" ]; then
-  DB="$INFILE"
-elif [ -n "$COPYDB" ]; then
-  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
-  cp "$INFILE" "$OUTFILE" || fail_out
-  chmod +w "$OUTFILE" || fail_out
-  DB="$OUTFILE"
+  COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
 else
-  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
-  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE"
-  [ -f "$OUTFILE" ] || fail_out
-  DB="$OUTFILE"
+  if [ -z "$COMPRESS" ]; then
+    COMMIT="fun commit () = (TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);"
+  else
+    COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);"
+  fi
+  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
 fi
 
 
 ## run it!
 
+MLTEXT="$INIT $EXIT $COMMIT $MLTEXT"
+MLEXIT="commit();"
+
 if [ -z "$TERMINATE" ]; then
   FEEDER_OPTS=""
 else
   FEEDER_OPTS="-q"
 fi
 
-DB_INFO="$(ls -l "$DB" 2>/dev/null)"
-
-"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | {
-  read FPID; "$POLY" $ML_OPTIONS "$DB";
-  RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
+"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
+  { read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
 RC="$?"
 
-NEW_DB_INFO="$(ls -l "$DB" 2>/dev/null)"
-[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \
-  "$POLY" $DISCGARB_OPTIONS "$OUTFILE"
 [ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
 
 exit "$RC"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/scripts/run-polyml-4.1.3	Thu Mar 06 19:21:26 2008 +0100
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+#
+# $Id$
+# Author: Markus Wenzel, TU Muenchen
+#
+# Poly/ML 4.x startup script.
+
+export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
+
+
+## diagnostics
+
+function fail_out()
+{
+  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
+  exit 2
+}
+
+function check_file()
+{
+  if [ ! -f "$1" ]; then
+    echo "Unable to locate $1" >&2
+    echo "Please check your ML system settings!" >&2
+    exit 2
+  fi
+}
+
+
+## Poly/ML executable and database
+
+ML_DBASE_PREFIX=""
+
+POLY="$ML_HOME/poly"
+check_file "$POLY"
+
+if [ -z "$ML_DBASE" ]; then
+  if [ ! -e "$ML_HOME/ML_dbase" -a "$(basename "$ML_HOME")" = bin ]; then
+    ML_DBASE_HOME="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib/poly; pwd)"
+  else
+    ML_DBASE_HOME="$ML_HOME"
+  fi
+  if [ -z "$COPYDB" ]; then
+    ML_DBASE_PREFIX="$ML_DBASE_HOME/"
+    ML_DBASE="ML_dbase"
+  else
+    ML_DBASE="$ML_DBASE_HOME/ML_dbase"
+  fi
+  export POLYPATH="$ML_DBASE_HOME"
+else
+  export POLYPATH="$(dirname "$ML_DBASE")"
+fi
+
+DISCGARB_OPTIONS="-d -c"
+
+EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
+
+
+## prepare databases
+
+if [ -z "$INFILE" ]; then
+  check_file "$ML_DBASE_PREFIX$ML_DBASE"
+  INFILE="$ML_DBASE"
+  MLTEXT="val use = PolyML.use; $EXIT $MLTEXT"
+  DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S max"
+else
+  COPYDB=true
+fi
+
+if [ -z "$OUTFILE" ]; then
+  DB="$INFILE"
+  ML_OPTIONS="-r $ML_OPTIONS"
+elif [ "$INFILE" -ef "$OUTFILE" ]; then
+  DB="$INFILE"
+elif [ -n "$COPYDB" ]; then
+  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
+  cp "$INFILE" "$OUTFILE" || fail_out
+  chmod +w "$OUTFILE" || fail_out
+  DB="$OUTFILE"
+else
+  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
+  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE"
+  [ -f "$OUTFILE" ] || fail_out
+  DB="$OUTFILE"
+fi
+
+
+## run it!
+
+if [ -z "$TERMINATE" ]; then
+  FEEDER_OPTS=""
+else
+  FEEDER_OPTS="-q"
+fi
+
+DB_INFO="$(ls -l "$DB" 2>/dev/null)"
+
+"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | {
+  read FPID; "$POLY" $ML_OPTIONS "$DB";
+  RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
+RC="$?"
+
+NEW_DB_INFO="$(ls -l "$DB" 2>/dev/null)"
+[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \
+  "$POLY" $DISCGARB_OPTIONS "$OUTFILE"
+[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
+
+exit "$RC"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/scripts/run-polyml-4.1.4	Thu Mar 06 19:21:26 2008 +0100
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+#
+# $Id$
+# Author: Markus Wenzel, TU Muenchen
+#
+# Poly/ML 4.x startup script.
+
+export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
+
+
+## diagnostics
+
+function fail_out()
+{
+  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
+  exit 2
+}
+
+function check_file()
+{
+  if [ ! -f "$1" ]; then
+    echo "Unable to locate $1" >&2
+    echo "Please check your ML system settings!" >&2
+    exit 2
+  fi
+}
+
+
+## Poly/ML executable and database
+
+ML_DBASE_PREFIX=""
+
+POLY="$ML_HOME/poly"
+check_file "$POLY"
+
+if [ -z "$ML_DBASE" ]; then
+  if [ ! -e "$ML_HOME/ML_dbase" -a "$(basename "$ML_HOME")" = bin ]; then
+    ML_DBASE_HOME="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib/poly; pwd)"
+  else
+    ML_DBASE_HOME="$ML_HOME"
+  fi
+  if [ -z "$COPYDB" ]; then
+    ML_DBASE_PREFIX="$ML_DBASE_HOME/"
+    ML_DBASE="ML_dbase"
+  else
+    ML_DBASE="$ML_DBASE_HOME/ML_dbase"
+  fi
+  export POLYPATH="$ML_DBASE_HOME"
+else
+  export POLYPATH="$(dirname "$ML_DBASE")"
+fi
+
+DISCGARB_OPTIONS="-d -c"
+
+EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
+
+
+## prepare databases
+
+if [ -z "$INFILE" ]; then
+  check_file "$ML_DBASE_PREFIX$ML_DBASE"
+  INFILE="$ML_DBASE"
+  MLTEXT="val use = PolyML.use; $EXIT $MLTEXT"
+  DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S max"
+else
+  COPYDB=true
+fi
+
+if [ -z "$OUTFILE" ]; then
+  DB="$INFILE"
+  ML_OPTIONS="-r $ML_OPTIONS"
+elif [ "$INFILE" -ef "$OUTFILE" ]; then
+  DB="$INFILE"
+elif [ -n "$COPYDB" ]; then
+  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
+  cp "$INFILE" "$OUTFILE" || fail_out
+  chmod +w "$OUTFILE" || fail_out
+  DB="$OUTFILE"
+else
+  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
+  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE"
+  [ -f "$OUTFILE" ] || fail_out
+  DB="$OUTFILE"
+fi
+
+
+## run it!
+
+if [ -z "$TERMINATE" ]; then
+  FEEDER_OPTS=""
+else
+  FEEDER_OPTS="-q"
+fi
+
+DB_INFO="$(ls -l "$DB" 2>/dev/null)"
+
+"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | {
+  read FPID; "$POLY" $ML_OPTIONS "$DB";
+  RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
+RC="$?"
+
+NEW_DB_INFO="$(ls -l "$DB" 2>/dev/null)"
+[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \
+  "$POLY" $DISCGARB_OPTIONS "$OUTFILE"
+[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
+
+exit "$RC"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/scripts/run-polyml-4.2.0	Thu Mar 06 19:21:26 2008 +0100
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+#
+# $Id$
+# Author: Markus Wenzel, TU Muenchen
+#
+# Poly/ML 4.x startup script.
+
+export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
+
+
+## diagnostics
+
+function fail_out()
+{
+  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
+  exit 2
+}
+
+function check_file()
+{
+  if [ ! -f "$1" ]; then
+    echo "Unable to locate $1" >&2
+    echo "Please check your ML system settings!" >&2
+    exit 2
+  fi
+}
+
+
+## Poly/ML executable and database
+
+ML_DBASE_PREFIX=""
+
+POLY="$ML_HOME/poly"
+check_file "$POLY"
+
+if [ -z "$ML_DBASE" ]; then
+  if [ ! -e "$ML_HOME/ML_dbase" -a "$(basename "$ML_HOME")" = bin ]; then
+    ML_DBASE_HOME="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib/poly; pwd)"
+  else
+    ML_DBASE_HOME="$ML_HOME"
+  fi
+  if [ -z "$COPYDB" ]; then
+    ML_DBASE_PREFIX="$ML_DBASE_HOME/"
+    ML_DBASE="ML_dbase"
+  else
+    ML_DBASE="$ML_DBASE_HOME/ML_dbase"
+  fi
+  export POLYPATH="$ML_DBASE_HOME"
+else
+  export POLYPATH="$(dirname "$ML_DBASE")"
+fi
+
+DISCGARB_OPTIONS="-d -c"
+
+EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
+
+
+## prepare databases
+
+if [ -z "$INFILE" ]; then
+  check_file "$ML_DBASE_PREFIX$ML_DBASE"
+  INFILE="$ML_DBASE"
+  MLTEXT="val use = PolyML.use; $EXIT $MLTEXT"
+  DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S max"
+else
+  COPYDB=true
+fi
+
+if [ -z "$OUTFILE" ]; then
+  DB="$INFILE"
+  ML_OPTIONS="-r $ML_OPTIONS"
+elif [ "$INFILE" -ef "$OUTFILE" ]; then
+  DB="$INFILE"
+elif [ -n "$COPYDB" ]; then
+  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
+  cp "$INFILE" "$OUTFILE" || fail_out
+  chmod +w "$OUTFILE" || fail_out
+  DB="$OUTFILE"
+else
+  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
+  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE"
+  [ -f "$OUTFILE" ] || fail_out
+  DB="$OUTFILE"
+fi
+
+
+## run it!
+
+if [ -z "$TERMINATE" ]; then
+  FEEDER_OPTS=""
+else
+  FEEDER_OPTS="-q"
+fi
+
+DB_INFO="$(ls -l "$DB" 2>/dev/null)"
+
+"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | {
+  read FPID; "$POLY" $ML_OPTIONS "$DB";
+  RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
+RC="$?"
+
+NEW_DB_INFO="$(ls -l "$DB" 2>/dev/null)"
+[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \
+  "$POLY" $DISCGARB_OPTIONS "$OUTFILE"
+[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
+
+exit "$RC"
--- a/lib/scripts/run-polyml-5.1	Thu Mar 06 19:21:25 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-#!/usr/bin/env bash
-#
-# $Id$
-# Author: Makarius
-#
-# Poly/ML startup script (for 5.1)
-
-export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
-
-
-## diagnostics
-
-function fail_out()
-{
-  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
-  exit 2
-}
-
-function check_file()
-{
-  if [ ! -f "$1" ]; then
-    echo "Unable to locate $1" >&2
-    echo "Please check your ML system settings!" >&2
-    exit 2
-  fi
-}
-
-
-## compiler executables and libraries
-
-POLY="$ML_HOME/poly"
-check_file "$POLY"
-
-if [ "$(basename "$ML_HOME")" = bin ]; then
-  POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)"
-else
-  POLYLIB="$ML_HOME"
-fi
-
-export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH"
-export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH"
-
-
-## prepare databases
-
-if [ -z "$INFILE" ]; then
-  INIT=""
-  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
-else
-  check_file "$INFILE"
-  INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle Fail msg => (TextIO.output (TextIO.stdErr, msg ^ \"\\n\"); OS.Process.exit OS.Process.failure));"
-  EXIT=""
-fi
-
-if [ -z "$OUTFILE" ]; then
-  COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
-else
-  if [ -z "$COMPRESS" ]; then
-    COMMIT="fun commit () = (TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);"
-  else
-    COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);"
-  fi
-  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
-fi
-
-
-## run it!
-
-MLTEXT="$INIT $EXIT $COMMIT $MLTEXT"
-MLEXIT="commit();"
-
-if [ -z "$TERMINATE" ]; then
-  FEEDER_OPTS=""
-else
-  FEEDER_OPTS="-q"
-fi
-
-"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
-  { read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
-RC="$?"
-
-[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
-
-exit "$RC"
--- a/src/Pure/ML-Systems/polyml-4.1.3.ML	Thu Mar 06 19:21:25 2008 +0100
+++ b/src/Pure/ML-Systems/polyml-4.1.3.ML	Thu Mar 06 19:21:26 2008 +0100
@@ -4,5 +4,5 @@
 Compatibility wrapper for Poly/ML 4.1.3.
 *)
 
-use "ML-Systems/polyml-old-basis.ML";
-use "ML-Systems/polyml.ML";
+use "ML-Systems/polyml_old_basis.ML";
+use "ML-Systems/polyml_common.ML";
--- a/src/Pure/ML-Systems/polyml-4.1.4.ML	Thu Mar 06 19:21:25 2008 +0100
+++ b/src/Pure/ML-Systems/polyml-4.1.4.ML	Thu Mar 06 19:21:26 2008 +0100
@@ -4,5 +4,5 @@
 Compatibility wrapper for Poly/ML 4.1.4.
 *)
 
-use "ML-Systems/polyml-old-basis.ML";
-use "ML-Systems/polyml.ML";
+use "ML-Systems/polyml_old_basis.ML";
+use "ML-Systems/polyml_common.ML";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/ML-Systems/polyml-4.2.0.ML	Thu Mar 06 19:21:26 2008 +0100
@@ -0,0 +1,7 @@
+(*  Title:      Pure/ML-Systems/polyml-4.2.0.ML
+    ID:         $Id$
+
+Compatibility wrapper for Poly/ML 4.2.0.
+*)
+
+use "ML-Systems/polyml_common.ML";
--- a/src/Pure/ML-Systems/polyml-5.0.ML	Thu Mar 06 19:21:25 2008 +0100
+++ b/src/Pure/ML-Systems/polyml-5.0.ML	Thu Mar 06 19:21:26 2008 +0100
@@ -4,7 +4,7 @@
 Compatibility wrapper for Poly/ML 5.0.
 *)
 
-use "ML-Systems/polyml.ML";
+use "ML-Systems/polyml_common.ML";
 
 val pointer_eq = PolyML.pointerEq;
 
--- a/src/Pure/ML-Systems/polyml-5.1.ML	Thu Mar 06 19:21:25 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-(*  Title:      Pure/ML-Systems/polyml-5.1.ML
-    ID:         $Id$
-
-Compatibility wrapper for Poly/ML 5.1.
-*)
-
-use "ML-Systems/polyml.ML";
-use "ML-Systems/multithreading_polyml.ML";
-
-val pointer_eq = PolyML.pointerEq;
-
-
-(* single-threaded profiling *)
-
-local val profile_orig = profile in
-
-fun profile 0 f x = f x
-  | profile n f x = NAMED_CRITICAL "profile" (fn () => profile_orig n f x);
-
-end;
-
-
-(* improved versions of use_text/file *)
-
-fun use_text (tune: string -> string) name (print, err) verbose txt =
-  let
-    val in_buffer = ref (explode (tune txt));
-    val out_buffer = ref ([]: string list);
-    fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs));
-
-    val line_no = ref 1;
-    fun line () = ! line_no;
-    fun get () =
-      (case ! in_buffer of
-        [] => ""
-      | c :: cs => (in_buffer := cs; if c = "\n" then line_no := ! line_no + 1 else (); c));
-    fun put s = out_buffer := s :: ! out_buffer;
-
-    fun exec () =
-      (case ! in_buffer of
-        [] => ()
-      | _ => (PolyML.compilerEx (get, put, line, name) (); exec ()));
-  in
-    exec () handle exn => (err (output ()); raise exn);
-    if verbose then print (output ()) else ()
-  end;
-
-fun use_file tune output verbose name =
-  let
-    val instream = TextIO.openIn name;
-    val txt = TextIO.inputAll instream before TextIO.closeIn instream;
-  in use_text tune name output verbose txt end;
--- a/src/Pure/ML-Systems/polyml.ML	Thu Mar 06 19:21:25 2008 +0100
+++ b/src/Pure/ML-Systems/polyml.ML	Thu Mar 06 19:21:26 2008 +0100
@@ -1,95 +1,26 @@
 (*  Title:      Pure/ML-Systems/polyml.ML
     ID:         $Id$
 
-Compatibility file for Poly/ML (version 4.1.3, 4.1.4, 4.2.0, also shared by 5.x).
+Compatibility wrapper for Poly/ML 5.1/5.2.
 *)
 
-use "ML-Systems/exn.ML";
-if List.exists (fn s => s = "Universal") (PolyML.Compiler.structureNames ()) then ()
-else use "ML-Systems/universal.ML";
-use "ML-Systems/multithreading.ML";
-use "ML-Systems/time_limit.ML";
+use "ML-Systems/polyml_common.ML";
+use "ML-Systems/multithreading_polyml.ML";
+
+val pointer_eq = PolyML.pointerEq;
 
 
-(** ML system and platform related **)
-
-(* Compiler options *)
-
-val ml_system_fix_ints = false;
+(* single-threaded profiling *)
 
-PolyML.Compiler.printInAlphabeticalOrder := false;
-PolyML.Compiler.maxInlineSize := 80;
-
-
-(* String compatibility *)
+local val profile_orig = profile in
 
-(*low-level pointer equality*)
-val pointer_eq = Address.wordEq;
-
-
-(* old Poly/ML emulation *)
+fun profile 0 f x = f x
+  | profile n f x = NAMED_CRITICAL "profile" (fn () => profile_orig n f x);
 
-local
-  val orig_exit = exit;
-in
-  open PolyML;
-  val exit = orig_exit;
-  fun quit () = exit 0;
 end;
 
 
-(* restore old-style character / string functions *)
-
-val ord = SML90.ord;
-val chr = SML90.chr;
-val explode = SML90.explode;
-val implode = SML90.implode;
-
-
-(* compiler-independent timing functions *)
-
-fun start_timing () =
-  let val CPUtimer = Timer.startCPUTimer();
-      val time = Timer.checkCPUTimer(CPUtimer)
-  in  (CPUtimer,time)  end;
-
-fun end_timing (CPUtimer, {sys,usr}) =
-  let open Time  (*...for Time.toString, Time.+ and Time.- *)
-      val {sys=sys2,usr=usr2} = Timer.checkCPUTimer(CPUtimer)
-  in  "User " ^ toString (usr2-usr) ^
-      "  All "^ toString (sys2-sys + usr2-usr) ^
-      " secs"
-      handle Time => ""
-  end;
-
-fun check_timer timer =
-  let
-    val {sys, usr} = Timer.checkCPUTimer timer;
-    val gc = Timer.checkGCTime timer;    (* FIXME already included in usr? *)
-  in (sys, usr, gc) end;
-
-
-(* prompts *)
-
-fun ml_prompts p1 p2 = (PolyML.Compiler.prompt1 := p1; PolyML.Compiler.prompt2 := p2);
-
-
-(* toplevel pretty printing (see also Pure/pure_setup.ML) *)
-
-fun make_pp _ pprint (str, blk, brk, en) _ _ obj =
-  pprint obj (str, fn ind => blk (ind, false), fn wd => brk (wd, 0),
-    fn () => brk (99999, 0), en);
-
-(*print depth*)
-local
-  val depth = ref 10;
-in
-  fun get_print_depth () = ! depth;
-  fun print_depth n = (depth := n; PolyML.print_depth n);
-end;
-
-
-(* ML command execution -- 'eval' *)
+(* improved versions of use_text/file *)
 
 fun use_text (tune: string -> string) name (print, err) verbose txt =
   let
@@ -97,19 +28,20 @@
     val out_buffer = ref ([]: string list);
     fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs));
 
+    val line_no = ref 1;
+    fun line () = ! line_no;
     fun get () =
       (case ! in_buffer of
         [] => ""
-      | c :: cs => (in_buffer := cs; c));
+      | c :: cs => (in_buffer := cs; if c = "\n" then line_no := ! line_no + 1 else (); c));
     fun put s = out_buffer := s :: ! out_buffer;
 
     fun exec () =
       (case ! in_buffer of
         [] => ()
-      | _ => (PolyML.compiler (get, put) (); exec ()));
+      | _ => (PolyML.compilerEx (get, put, line, name) (); exec ()));
   in
-    exec () handle exn =>
-      (err ((if name = "" then "" else "Error in " ^ name ^ "\n") ^ output ()); raise exn);
+    exec () handle exn => (err (output ()); raise exn);
     if verbose then print (output ()) else ()
   end;
 
@@ -118,105 +50,3 @@
     val instream = TextIO.openIn name;
     val txt = TextIO.inputAll instream before TextIO.closeIn instream;
   in use_text tune name output verbose txt end;
-
-
-(*eval command line arguments*)
-local
-  fun println s =
-    (TextIO.output (TextIO.stdOut, s ^ "\n"); TextIO.flushOut TextIO.stdOut);
-  fun eval "-q" = ()
-    | eval txt = use_text (fn x => x) "" (println, println) false txt;
-in
-  val _ = PolyML.onEntry (fn () =>
-   (Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ()));
-    app eval (CommandLine.arguments ())));
-end;
-
-
-
-(** interrupts **)
-
-exception Interrupt = SML90.Interrupt;
-
-local
-
-val sig_int = 2;
-val default_handler = Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ());
-
-val _ = Signal.signal (sig_int, default_handler);
-
-fun change_signal new_handler f x =
-  let
-    (*RACE wrt. other signals!*)
-    val old_handler = Signal.signal (sig_int, new_handler);
-    val result = Exn.capture (f old_handler) x;
-    val _ = Signal.signal (sig_int, old_handler);
-  in Exn.release result end;
-
-in
-
-fun interruptible f = change_signal default_handler (fn _ => f);
-
-fun uninterruptible f =
-  change_signal Signal.SIG_IGN
-    (fn old_handler => f (fn g => change_signal old_handler (fn _ => g)));
-
-end;
-
-
-
-(** OS related **)
-
-use "ML-Systems/polyml-posix.ML";
-
-
-(* current directory *)
-
-val cd = OS.FileSys.chDir;
-val pwd = OS.FileSys.getDir;
-
-
-(* system command execution *)
-
-(*execute Unix command which doesn't take any input from stdin and
-  sends its output to stdout; could be done more easily by Unix.execute,
-  but that function doesn't use the PATH*)
-fun execute command =
-  let
-    val tmp_name = OS.FileSys.tmpName ();
-    val is = (OS.Process.system (command ^ " > " ^ tmp_name); TextIO.openIn tmp_name);
-    val result = TextIO.inputAll is;
-  in
-    TextIO.closeIn is;
-    OS.FileSys.remove tmp_name;
-    result
-  end;
-
-(*plain version; with return code*)
-fun system cmd =
-  if OS.Process.isSuccess (OS.Process.system cmd) then 0 else 1;
-
-
-(*Convert a process ID to a decimal string (chiefly for tracing)*)
-fun string_of_pid pid =
-  Word.fmt StringCvt.DEC (Word.fromLargeWord (Posix.Process.pidToWord pid));
-
-
-(* getenv *)
-
-fun getenv var =
-  (case OS.Process.getEnv var of
-    NONE => ""
-  | SOME txt => txt);
-
-
-(* profile execution *)
-
-fun profile 0 f x = f x
-  | profile n f x =
-      let
-        val _ = RunCall.run_call1 RuntimeCalls.POLY_SYS_profiler n;
-        val res = Exn.capture f x;
-        val _ = RunCall.run_call1 RuntimeCalls.POLY_SYS_profiler 0;
-      in Exn.release res end;
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/ML-Systems/polyml_common.ML	Thu Mar 06 19:21:26 2008 +0100
@@ -0,0 +1,236 @@
+(*  Title:      Pure/ML-Systems/polyml_common.ML
+    ID:         $Id$
+
+Compatibility file for Poly/ML -- common part for 4.x and 5.x.
+*)
+
+use "ML-Systems/exn.ML";
+if List.exists (fn s => s = "Universal") (PolyML.Compiler.structureNames ()) then ()
+else use "ML-Systems/universal.ML";
+use "ML-Systems/multithreading.ML";
+use "ML-Systems/time_limit.ML";
+
+
+(** ML system and platform related **)
+
+(* Compiler options *)
+
+val ml_system_fix_ints = false;
+
+PolyML.Compiler.printInAlphabeticalOrder := false;
+PolyML.Compiler.maxInlineSize := 80;
+
+
+(* String compatibility *)
+
+(*low-level pointer equality*)
+val pointer_eq = Address.wordEq;
+
+
+(* old Poly/ML emulation *)
+
+local
+  val orig_exit = exit;
+in
+  open PolyML;
+  val exit = orig_exit;
+  fun quit () = exit 0;
+end;
+
+
+(* restore old-style character / string functions *)
+
+val ord = SML90.ord;
+val chr = SML90.chr;
+val explode = SML90.explode;
+val implode = SML90.implode;
+
+
+(* compiler-independent timing functions *)
+
+fun start_timing () =
+  let val CPUtimer = Timer.startCPUTimer();
+      val time = Timer.checkCPUTimer(CPUtimer)
+  in  (CPUtimer,time)  end;
+
+fun end_timing (CPUtimer, {sys,usr}) =
+  let open Time  (*...for Time.toString, Time.+ and Time.- *)
+      val {sys=sys2,usr=usr2} = Timer.checkCPUTimer(CPUtimer)
+  in  "User " ^ toString (usr2-usr) ^
+      "  All "^ toString (sys2-sys + usr2-usr) ^
+      " secs"
+      handle Time => ""
+  end;
+
+fun check_timer timer =
+  let
+    val {sys, usr} = Timer.checkCPUTimer timer;
+    val gc = Timer.checkGCTime timer;    (* FIXME already included in usr? *)
+  in (sys, usr, gc) end;
+
+
+(* prompts *)
+
+fun ml_prompts p1 p2 = (PolyML.Compiler.prompt1 := p1; PolyML.Compiler.prompt2 := p2);
+
+
+(* toplevel pretty printing (see also Pure/pure_setup.ML) *)
+
+fun make_pp _ pprint (str, blk, brk, en) _ _ obj =
+  pprint obj (str, fn ind => blk (ind, false), fn wd => brk (wd, 0),
+    fn () => brk (99999, 0), en);
+
+(*print depth*)
+local
+  val depth = ref 10;
+in
+  fun get_print_depth () = ! depth;
+  fun print_depth n = (depth := n; PolyML.print_depth n);
+end;
+
+
+(* ML command execution -- 'eval' *)
+
+fun use_text (tune: string -> string) name (print, err) verbose txt =
+  let
+    val in_buffer = ref (explode (tune txt));
+    val out_buffer = ref ([]: string list);
+    fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs));
+
+    fun get () =
+      (case ! in_buffer of
+        [] => ""
+      | c :: cs => (in_buffer := cs; c));
+    fun put s = out_buffer := s :: ! out_buffer;
+
+    fun exec () =
+      (case ! in_buffer of
+        [] => ()
+      | _ => (PolyML.compiler (get, put) (); exec ()));
+  in
+    exec () handle exn =>
+      (err ((if name = "" then "" else "Error in " ^ name ^ "\n") ^ output ()); raise exn);
+    if verbose then print (output ()) else ()
+  end;
+
+fun use_file tune output verbose name =
+  let
+    val instream = TextIO.openIn name;
+    val txt = TextIO.inputAll instream before TextIO.closeIn instream;
+  in use_text tune name output verbose txt end;
+
+
+(*eval command line arguments*)
+local
+  fun println s =
+    (TextIO.output (TextIO.stdOut, s ^ "\n"); TextIO.flushOut TextIO.stdOut);
+  fun eval "-q" = ()
+    | eval txt = use_text (fn x => x) "" (println, println) false txt;
+in
+  val _ = PolyML.onEntry (fn () =>
+   (Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ()));
+    app eval (CommandLine.arguments ())));
+end;
+
+
+
+(** interrupts **)
+
+exception Interrupt = SML90.Interrupt;
+
+local
+
+val sig_int = 2;
+val default_handler = Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ());
+
+val _ = Signal.signal (sig_int, default_handler);
+
+fun change_signal new_handler f x =
+  let
+    (*RACE wrt. other signals!*)
+    val old_handler = Signal.signal (sig_int, new_handler);
+    val result = Exn.capture (f old_handler) x;
+    val _ = Signal.signal (sig_int, old_handler);
+  in Exn.release result end;
+
+in
+
+fun interruptible f = change_signal default_handler (fn _ => f);
+
+fun uninterruptible f =
+  change_signal Signal.SIG_IGN
+    (fn old_handler => f (fn g => change_signal old_handler (fn _ => g)));
+
+end;
+
+
+
+(** OS related **)
+
+(* Posix patches *)
+
+(*This extension of the Poly/ML Signal structure is only necessary
+  because in SML/NJ, types Posix.Signal.signal and Signals.signal differ.*)
+structure IsaSignal =
+struct
+  open Signal
+  val usr1 = Posix.Signal.usr1
+  val usr2 = Posix.Signal.usr2
+  val alrm = Posix.Signal.alrm
+  val chld = Posix.Signal.chld
+  val cont = Posix.Signal.cont
+  val int  = Posix.Signal.int
+  val quit = Posix.Signal.quit
+end;
+
+
+(* current directory *)
+
+val cd = OS.FileSys.chDir;
+val pwd = OS.FileSys.getDir;
+
+
+(* system command execution *)
+
+(*execute Unix command which doesn't take any input from stdin and
+  sends its output to stdout; could be done more easily by Unix.execute,
+  but that function doesn't use the PATH*)
+fun execute command =
+  let
+    val tmp_name = OS.FileSys.tmpName ();
+    val is = (OS.Process.system (command ^ " > " ^ tmp_name); TextIO.openIn tmp_name);
+    val result = TextIO.inputAll is;
+  in
+    TextIO.closeIn is;
+    OS.FileSys.remove tmp_name;
+    result
+  end;
+
+(*plain version; with return code*)
+fun system cmd =
+  if OS.Process.isSuccess (OS.Process.system cmd) then 0 else 1;
+
+
+(*Convert a process ID to a decimal string (chiefly for tracing)*)
+fun string_of_pid pid =
+  Word.fmt StringCvt.DEC (Word.fromLargeWord (Posix.Process.pidToWord pid));
+
+
+(* getenv *)
+
+fun getenv var =
+  (case OS.Process.getEnv var of
+    NONE => ""
+  | SOME txt => txt);
+
+
+(* profile execution *)
+
+fun profile 0 f x = f x
+  | profile n f x =
+      let
+        val _ = RunCall.run_call1 RuntimeCalls.POLY_SYS_profiler n;
+        val res = Exn.capture f x;
+        val _ = RunCall.run_call1 RuntimeCalls.POLY_SYS_profiler 0;
+      in Exn.release res end;
+