src/Pure/RAW/ROOT_polyml.ML
author wenzelm
Sun, 28 Feb 2016 21:25:55 +0100
changeset 62460 4b2018eb92e8
parent 62459 7a5d88dd8cc9
child 62467 c1b88e647e2f
permissions -rw-r--r--
clarified;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62077
e8ae72c26025 clarified ROOT files;
wenzelm
parents: 61925
diff changeset
     1
(*  Title:      Pure/RAW/ROOT_polyml.ML
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
     2
    Author:     Makarius
29714
6cef6700c841 Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff changeset
     3
50910
54f06ba192ef tuned comments;
wenzelm
parents: 50909
diff changeset
     4
Compatibility wrapper for Poly/ML.
29714
6cef6700c841 Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff changeset
     5
*)
6cef6700c841 Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff changeset
     6
60953
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
     7
(* initial ML name space *)
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
     8
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
     9
use "RAW/ml_system.ML";
61715
5dc95d957569 speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents: 60993
diff changeset
    10
5dc95d957569 speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents: 60993
diff changeset
    11
if ML_System.name = "polyml-5.6"
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    12
then use "RAW/ml_name_space_polyml-5.6.ML"
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    13
else use "RAW/ml_name_space_polyml.ML";
61715
5dc95d957569 speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents: 60993
diff changeset
    14
62387
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
    15
if List.exists (fn (a, _) => a = "FixedInt") (#allStruct ML_Name_Space.global ()) then ()
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
    16
else use "RAW/fixed_int_dummy.ML";
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
    17
60953
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    18
structure ML_Name_Space =
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    19
struct
61715
5dc95d957569 speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents: 60993
diff changeset
    20
  open ML_Name_Space;
60953
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    21
  val initial_val =
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    22
    List.filter (fn (a, _) => a <> "use" andalso a <> "exit" andalso a <> "commit")
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    23
      (#allVal global ());
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    24
  val initial_type = #allType global ();
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    25
  val initial_fixity = #allFix global ();
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    26
  val initial_structure = #allStruct global ();
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    27
  val initial_signature = #allSig global ();
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    28
  val initial_functor = #allFunct global ();
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
    29
end;
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 54723
diff changeset
    30
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 54723
diff changeset
    31
54717
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    32
(* ML system operations *)
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    33
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    34
if ML_System.name = "polyml-5.3.0"
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    35
then use "RAW/share_common_data_polyml-5.3.0.ML"
54717
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    36
else ();
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    37
60964
fdb82e722f8a keep native CInterface to make SHA1 work properly;
wenzelm
parents: 60962
diff changeset
    38
fun ml_platform_path (s: string) = s;
60965
49c797cb9f46 tuned signature;
wenzelm
parents: 60964
diff changeset
    39
fun ml_standard_path (s: string) = s;
49c797cb9f46 tuned signature;
wenzelm
parents: 60964
diff changeset
    40
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    41
if ML_System.platform_is_windows then use "RAW/windows_path.ML" else ();
60962
faa452d8e265 basic setup for native Windows (RAW session without image);
wenzelm
parents: 60956
diff changeset
    42
54717
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    43
structure ML_System =
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    44
struct
60967
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60965
diff changeset
    45
  open ML_System;
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60965
diff changeset
    46
  fun share_common_data () = PolyML.shareCommonData PolyML.rootFunction;
eb87fc42825c proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents: 60965
diff changeset
    47
  val save_state = PolyML.SaveState.saveState o ml_platform_path;
54717
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    48
end;
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    49
42c209a6c225 support for polml-5.5.2;
wenzelm
parents: 54342
diff changeset
    50
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    51
(* exceptions *)
30673
60568c168040 more systematic type use_context;
wenzelm
parents: 30638
diff changeset
    52
31427
5a07cc86675d reraise exceptions to preserve original position (ML system specific);
wenzelm
parents: 31318
diff changeset
    53
fun reraise exn =
5a07cc86675d reraise exceptions to preserve original position (ML system specific);
wenzelm
parents: 31318
diff changeset
    54
  (case PolyML.exceptionLocation exn of
5a07cc86675d reraise exceptions to preserve original position (ML system specific);
wenzelm
parents: 31318
diff changeset
    55
    NONE => raise exn
5a07cc86675d reraise exceptions to preserve original position (ML system specific);
wenzelm
parents: 31318
diff changeset
    56
  | SOME location => PolyML.raiseWithLocation (exn, location));
5a07cc86675d reraise exceptions to preserve original position (ML system specific);
wenzelm
parents: 31318
diff changeset
    57
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    58
exception Interrupt = SML90.Interrupt;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    59
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    60
use "RAW/exn.ML";
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    61
62459
7a5d88dd8cc9 support only polyml-5.3.0 and polyml-5.6;
wenzelm
parents: 62387
diff changeset
    62
if ML_System.name = "polyml-5.6"
7a5d88dd8cc9 support only polyml-5.3.0 and polyml-5.6;
wenzelm
parents: 62387
diff changeset
    63
then use "RAW/exn_trace.ML"
62460
4b2018eb92e8 clarified;
wenzelm
parents: 62459
diff changeset
    64
else use "RAW/exn_trace_raw.ML";
59470
31d810570879 tuned bootstrap;
wenzelm
parents: 59468
diff changeset
    65
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    66
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    67
(* multithreading *)
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    68
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    69
val seconds = Time.fromReal;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    70
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    71
if List.exists (fn s => s = "SingleAssignment") (PolyML.Compiler.structureNames ())
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    72
then ()
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    73
else use "RAW/single_assignment_polyml.ML";
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    74
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    75
open Thread;
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    76
use "RAW/multithreading.ML";
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    77
61794
4c232a2ddeab discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents: 61715
diff changeset
    78
if ML_System.name = "polyml-5.6"
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    79
then use "RAW/ml_stack_polyml-5.6.ML"
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    80
else use "RAW/ml_stack_dummy.ML";
59468
fe6651760643 explicit threads_stack_limit (for recent Poly/ML SVN versions), which leads to soft interrupt instead of exhaustion of virtual memory, which is particularly relevant for the bigger address space of x86_64;
wenzelm
parents: 59127
diff changeset
    81
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
    82
use "RAW/unsynchronized.ML";
39616
8052101883c3 renamed setmp_noncritical to Unsynchronized.setmp to emphasize its meaning;
wenzelm
parents: 38470
diff changeset
    83
val _ = PolyML.Compiler.forgetValue "ref";
8052101883c3 renamed setmp_noncritical to Unsynchronized.setmp to emphasize its meaning;
wenzelm
parents: 38470
diff changeset
    84
val _ = PolyML.Compiler.forgetType "ref";
29714
6cef6700c841 Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff changeset
    85
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    86
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    87
(* pervasive environment *)
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    88
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    89
val _ = PolyML.Compiler.forgetValue "isSome";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    90
val _ = PolyML.Compiler.forgetValue "getOpt";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    91
val _ = PolyML.Compiler.forgetValue "valOf";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    92
val _ = PolyML.Compiler.forgetValue "foldl";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    93
val _ = PolyML.Compiler.forgetValue "foldr";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    94
val _ = PolyML.Compiler.forgetValue "print";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    95
val _ = PolyML.Compiler.forgetValue "explode";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    96
val _ = PolyML.Compiler.forgetValue "concat";
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    97
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    98
val ord = SML90.ord;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
    99
val chr = SML90.chr;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   100
val raw_explode = SML90.explode;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   101
val implode = SML90.implode;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   102
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   103
fun quit () = exit 0;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   104
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   105
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   106
(* ML runtime system *)
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   107
61715
5dc95d957569 speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents: 60993
diff changeset
   108
if ML_System.name = "polyml-5.6"
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   109
then use "RAW/ml_profiling_polyml-5.6.ML"
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   110
else use "RAW/ml_profiling_polyml.ML";
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   111
29714
6cef6700c841 Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff changeset
   112
val pointer_eq = PolyML.pointerEq;
6cef6700c841 Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff changeset
   113
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   114
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   115
(* ML toplevel pretty printing *)
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   116
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   117
use "RAW/ml_pretty.ML";
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   118
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   119
local
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   120
  val depth = Unsynchronized.ref 10;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   121
in
56281
03c3d1a7c3b8 proper configuration option "ML_print_depth";
wenzelm
parents: 56275
diff changeset
   122
  fun get_default_print_depth () = ! depth;
56285
wenzelm
parents: 56283
diff changeset
   123
  fun default_print_depth n = (depth := n; PolyML.print_depth n);
wenzelm
parents: 56283
diff changeset
   124
  val _ = default_print_depth 10;
47980
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   125
end;
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   126
c81801f881b3 simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents: 44249
diff changeset
   127
val error_depth = PolyML.error_depth;
30626
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   128
30676
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   129
val pretty_ml =
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   130
  let
61862
e2a9e46ac0fb support pretty break indent, like underlying ML systems;
wenzelm
parents: 61794
diff changeset
   131
    fun convert _ (PolyML.PrettyBreak (width, offset)) = ML_Pretty.Break (false, width, offset)
54718
8c5221d698cd tuned patterns;
wenzelm
parents: 54717
diff changeset
   132
      | convert _ (PolyML.PrettyBlock (_, _,
51638
1275716f395b more defensive representation of forced break within PolyML.PrettyBreak -- avoid accidental blowup if low-level operations are used, notably PolyML.makestring or its variant General.exnMessage;
wenzelm
parents: 50911
diff changeset
   133
            [PolyML.ContextProperty ("fbrk", _)], [PolyML.PrettyString " "])) =
61862
e2a9e46ac0fb support pretty break indent, like underlying ML systems;
wenzelm
parents: 61794
diff changeset
   134
          ML_Pretty.Break (true, 1, 0)
61864
3a5992c3410c support for blocks with consistent breaks;
wenzelm
parents: 61862
diff changeset
   135
      | convert len (PolyML.PrettyBlock (ind, consistent, context, prts)) =
30676
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   136
          let
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   137
            fun property name default =
31318
133d1cfd6ae7 explicit PolyML qualification;
wenzelm
parents: 31312
diff changeset
   138
              (case List.find (fn PolyML.ContextProperty (a, _) => name = a | _ => false) context of
133d1cfd6ae7 explicit PolyML qualification;
wenzelm
parents: 31312
diff changeset
   139
                SOME (PolyML.ContextProperty (_, b)) => b
54718
8c5221d698cd tuned patterns;
wenzelm
parents: 54717
diff changeset
   140
              | _ => default);
30676
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   141
            val bg = property "begin" "";
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   142
            val en = property "end" "";
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   143
            val len' = property "length" len;
61869
ba466ac335e3 clarified underlying datatypes;
wenzelm
parents: 61864
diff changeset
   144
          in ML_Pretty.Block ((bg, en), consistent, ind, map (convert len') prts) end
31318
133d1cfd6ae7 explicit PolyML qualification;
wenzelm
parents: 31312
diff changeset
   145
      | convert len (PolyML.PrettyString s) =
62387
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   146
          ML_Pretty.String
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   147
            (s, FixedInt.fromInt (case Int.fromString len of SOME i => i | NONE => size s))
30676
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   148
  in convert "" end;
30638
15cc4ad0e6e9 added pretty_ml;
wenzelm
parents: 30626
diff changeset
   149
61862
e2a9e46ac0fb support pretty break indent, like underlying ML systems;
wenzelm
parents: 61794
diff changeset
   150
fun ml_pretty (ML_Pretty.Break (false, width, offset)) = PolyML.PrettyBreak (width, offset)
e2a9e46ac0fb support pretty break indent, like underlying ML systems;
wenzelm
parents: 61794
diff changeset
   151
  | ml_pretty (ML_Pretty.Break (true, _, _)) =
51638
1275716f395b more defensive representation of forced break within PolyML.PrettyBreak -- avoid accidental blowup if low-level operations are used, notably PolyML.makestring or its variant General.exnMessage;
wenzelm
parents: 50911
diff changeset
   152
      PolyML.PrettyBlock (0, false, [PolyML.ContextProperty ("fbrk", "")],
1275716f395b more defensive representation of forced break within PolyML.PrettyBreak -- avoid accidental blowup if low-level operations are used, notably PolyML.makestring or its variant General.exnMessage;
wenzelm
parents: 50911
diff changeset
   153
        [PolyML.PrettyString " "])
61869
ba466ac335e3 clarified underlying datatypes;
wenzelm
parents: 61864
diff changeset
   154
  | ml_pretty (ML_Pretty.Block ((bg, en), consistent, ind, prts)) =
30679
wenzelm
parents: 30676
diff changeset
   155
      let val context =
31318
133d1cfd6ae7 explicit PolyML qualification;
wenzelm
parents: 31312
diff changeset
   156
        (if bg = "" then [] else [PolyML.ContextProperty ("begin", bg)]) @
133d1cfd6ae7 explicit PolyML qualification;
wenzelm
parents: 31312
diff changeset
   157
        (if en = "" then [] else [PolyML.ContextProperty ("end", en)])
61864
3a5992c3410c support for blocks with consistent breaks;
wenzelm
parents: 61862
diff changeset
   158
      in PolyML.PrettyBlock (ind, consistent, context, map ml_pretty prts) end
30676
edca392a2abb pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents: 30673
diff changeset
   159
  | ml_pretty (ML_Pretty.String (s, len)) =
62387
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   160
      if len = FixedInt.fromInt (size s) then PolyML.PrettyString s
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   161
      else
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   162
        PolyML.PrettyBlock
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   163
          (0, false,
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   164
            [PolyML.ContextProperty ("length", FixedInt.toString len)], [PolyML.PrettyString s]);
30626
248de8dd839e adapted toplevel_pp to ML_Pretty.pretty;
wenzelm
parents: 30619
diff changeset
   165
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   166
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   167
(* ML compiler *)
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   168
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   169
structure ML_Name_Space =
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   170
struct
60953
87f0f707a5f8 clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents: 60923
diff changeset
   171
  open ML_Name_Space;
61715
5dc95d957569 speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents: 60993
diff changeset
   172
  val display_val = pretty_ml o displayVal;
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   173
end;
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   174
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   175
use "RAW/ml_compiler_parameters.ML";
61794
4c232a2ddeab discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents: 61715
diff changeset
   176
if ML_System.name = "polyml-5.6"
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   177
then use "RAW/ml_compiler_parameters_polyml-5.6.ML" else ();
60956
10d463883dc2 explicit debug flag for ML compiler;
wenzelm
parents: 60954
diff changeset
   178
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   179
use "RAW/use_context.ML";
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   180
use "RAW/ml_positions.ML";
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   181
use "RAW/compiler_polyml.ML";
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   182
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   183
PolyML.Compiler.reportUnreferencedIds := true;
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   184
PolyML.Compiler.printInAlphabeticalOrder := false;
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   185
PolyML.Compiler.maxInlineSize := 80;
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   186
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   187
fun ml_prompts p1 p2 = (PolyML.Compiler.prompt1 := p1; PolyML.Compiler.prompt2 := p2);
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   188
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   189
use "RAW/ml_parse_tree.ML";
61794
4c232a2ddeab discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents: 61715
diff changeset
   190
if ML_System.name = "polyml-5.6"
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   191
then use "RAW/ml_parse_tree_polyml-5.6.ML" else ();
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   192
59127
723b11f8ffbf more careful handling of auxiliary environment structure -- allow nested ML evaluation;
wenzelm
parents: 59055
diff changeset
   193
fun ml_make_string struct_name =
62387
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   194
  "(fn x => Pretty.string_of (Pretty.from_ML (pretty_ml (PolyML.prettyRepresentation (x, FixedInt.fromInt (" ^
ad3eb2889f9a support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents: 62359
diff changeset
   195
    struct_name ^ ".ML_print_depth ()))))))";
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   196
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   197
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   198
(* ML debugger *)
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60745
diff changeset
   199
61794
4c232a2ddeab discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents: 61715
diff changeset
   200
if ML_System.name = "polyml-5.6"
61925
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   201
then use "RAW/ml_debugger_polyml-5.6.ML"
ab52f183f020 clarified directory structure;
wenzelm
parents: 61869
diff changeset
   202
else use "RAW/ml_debugger.ML";