author | wenzelm |
Sat, 19 Dec 2015 19:52:52 +0100 | |
changeset 61869 | ba466ac335e3 |
parent 61864 | 3a5992c3410c |
permissions | -rw-r--r-- |
33538
edf497b5b5d2
setup for official Poly/ML 5.3.0, which is now the default;
wenzelm
parents:
32778
diff
changeset
|
1 |
(* Title: Pure/ML-Systems/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 | 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 |
|
61715
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
9 |
use "ML-Systems/ml_system.ML"; |
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" |
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
12 |
then use "ML-Systems/ml_name_space_polyml-5.6.ML" |
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
13 |
else use "ML-Systems/ml_name_space_polyml.ML"; |
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
14 |
|
60953
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
15 |
structure ML_Name_Space = |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
16 |
struct |
61715
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
17 |
open ML_Name_Space; |
60953
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
18 |
val initial_val = |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
19 |
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
|
20 |
(#allVal global ()); |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
21 |
val initial_type = #allType global (); |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
22 |
val initial_fixity = #allFix global (); |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
23 |
val initial_structure = #allStruct global (); |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
24 |
val initial_signature = #allSig global (); |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
25 |
val initial_functor = #allFunct global (); |
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
26 |
end; |
56275
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
54723
diff
changeset
|
27 |
|
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
54723
diff
changeset
|
28 |
|
54717 | 29 |
(* ML system operations *) |
30 |
||
31 |
if ML_System.name = "polyml-5.3.0" |
|
32 |
then use "ML-Systems/share_common_data_polyml-5.3.0.ML" |
|
33 |
else (); |
|
34 |
||
60964
fdb82e722f8a
keep native CInterface to make SHA1 work properly;
wenzelm
parents:
60962
diff
changeset
|
35 |
fun ml_platform_path (s: string) = s; |
60965 | 36 |
fun ml_standard_path (s: string) = s; |
37 |
||
60993 | 38 |
if ML_System.platform_is_windows then use "ML-Systems/windows_path.ML" else (); |
60962
faa452d8e265
basic setup for native Windows (RAW session without image);
wenzelm
parents:
60956
diff
changeset
|
39 |
|
54717 | 40 |
structure ML_System = |
41 |
struct |
|
60967
eb87fc42825c
proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents:
60965
diff
changeset
|
42 |
open ML_System; |
eb87fc42825c
proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents:
60965
diff
changeset
|
43 |
fun share_common_data () = PolyML.shareCommonData PolyML.rootFunction; |
eb87fc42825c
proper platform path for intial PolyML.SaveState.loadState;
wenzelm
parents:
60965
diff
changeset
|
44 |
val save_state = PolyML.SaveState.saveState o ml_platform_path; |
54717 | 45 |
end; |
46 |
||
47 |
||
47980
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
48 |
(* exceptions *) |
30673 | 49 |
|
31427
5a07cc86675d
reraise exceptions to preserve original position (ML system specific);
wenzelm
parents:
31318
diff
changeset
|
50 |
fun reraise exn = |
5a07cc86675d
reraise exceptions to preserve original position (ML system specific);
wenzelm
parents:
31318
diff
changeset
|
51 |
(case PolyML.exceptionLocation exn of |
5a07cc86675d
reraise exceptions to preserve original position (ML system specific);
wenzelm
parents:
31318
diff
changeset
|
52 |
NONE => raise exn |
5a07cc86675d
reraise exceptions to preserve original position (ML system specific);
wenzelm
parents:
31318
diff
changeset
|
53 |
| SOME location => PolyML.raiseWithLocation (exn, location)); |
5a07cc86675d
reraise exceptions to preserve original position (ML system specific);
wenzelm
parents:
31318
diff
changeset
|
54 |
|
47980
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
55 |
exception Interrupt = SML90.Interrupt; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
56 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
57 |
use "General/exn.ML"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
58 |
|
59470 | 59 |
fun print_exception_trace (_: exn -> string) (_: string -> unit) = PolyML.exception_trace; |
60 |
||
61 |
if ML_System.name = "polyml-5.5.1" |
|
62 |
orelse ML_System.name = "polyml-5.5.2" |
|
61715
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
63 |
orelse ML_System.name = "polyml-5.6" |
59470 | 64 |
then use "ML-Systems/exn_trace_polyml-5.5.1.ML" |
65 |
else (); |
|
66 |
||
47980
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
67 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
68 |
(* multithreading *) |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
69 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
70 |
val seconds = Time.fromReal; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
71 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
72 |
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
|
73 |
then () |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
74 |
else use "ML-Systems/single_assignment_polyml.ML"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
75 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
76 |
open Thread; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
77 |
use "ML-Systems/multithreading.ML"; |
29714
6cef6700c841
Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff
changeset
|
78 |
use "ML-Systems/multithreading_polyml.ML"; |
47980
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
79 |
|
61794
4c232a2ddeab
discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents:
61715
diff
changeset
|
80 |
if ML_System.name = "polyml-5.6" |
4c232a2ddeab
discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents:
61715
diff
changeset
|
81 |
then use "ML-Systems/ml_stack_polyml-5.6.ML" |
60923 | 82 |
else use "ML-Systems/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
|
83 |
|
39616
8052101883c3
renamed setmp_noncritical to Unsynchronized.setmp to emphasize its meaning;
wenzelm
parents:
38470
diff
changeset
|
84 |
use "ML-Systems/unsynchronized.ML"; |
8052101883c3
renamed setmp_noncritical to Unsynchronized.setmp to emphasize its meaning;
wenzelm
parents:
38470
diff
changeset
|
85 |
val _ = PolyML.Compiler.forgetValue "ref"; |
8052101883c3
renamed setmp_noncritical to Unsynchronized.setmp to emphasize its meaning;
wenzelm
parents:
38470
diff
changeset
|
86 |
val _ = PolyML.Compiler.forgetType "ref"; |
29714
6cef6700c841
Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff
changeset
|
87 |
|
47980
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 |
(* pervasive environment *) |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
90 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
91 |
val _ = PolyML.Compiler.forgetValue "isSome"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
92 |
val _ = PolyML.Compiler.forgetValue "getOpt"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
93 |
val _ = PolyML.Compiler.forgetValue "valOf"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
94 |
val _ = PolyML.Compiler.forgetValue "foldl"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
95 |
val _ = PolyML.Compiler.forgetValue "foldr"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
96 |
val _ = PolyML.Compiler.forgetValue "print"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
97 |
val _ = PolyML.Compiler.forgetValue "explode"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
98 |
val _ = PolyML.Compiler.forgetValue "concat"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
99 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
100 |
val ord = SML90.ord; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
101 |
val chr = SML90.chr; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
102 |
val raw_explode = SML90.explode; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
103 |
val implode = SML90.implode; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
104 |
|
54342
fbcaa9f08879
avoid non-portable int constant -- make SML/NJ happy;
wenzelm
parents:
53709
diff
changeset
|
105 |
val io_buffer_size = 4096; |
fbcaa9f08879
avoid non-portable int constant -- make SML/NJ happy;
wenzelm
parents:
53709
diff
changeset
|
106 |
|
47980
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
107 |
fun quit () = exit 0; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
108 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
109 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
110 |
(* ML runtime system *) |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
111 |
|
61715
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
112 |
if ML_System.name = "polyml-5.6" |
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
113 |
then use "ML-Systems/ml_profiling_polyml-5.6.ML" |
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
114 |
else use "ML-Systems/ml_profiling_polyml.ML"; |
47980
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
115 |
|
29714
6cef6700c841
Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff
changeset
|
116 |
val pointer_eq = PolyML.pointerEq; |
6cef6700c841
Compatibility wrapper for experimental versions of Poly/ML after 5.2.1.
wenzelm
parents:
diff
changeset
|
117 |
|
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 |
(* ML toplevel pretty printing *) |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
120 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
121 |
use "ML-Systems/ml_pretty.ML"; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
122 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
123 |
local |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
124 |
val depth = Unsynchronized.ref 10; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
125 |
in |
56281 | 126 |
fun get_default_print_depth () = ! depth; |
56285 | 127 |
fun default_print_depth n = (depth := n; PolyML.print_depth n); |
128 |
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
|
129 |
end; |
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
130 |
|
c81801f881b3
simplified Poly/ML setup -- 5.3.0 is now the common base-line;
wenzelm
parents:
44249
diff
changeset
|
131 |
val error_depth = PolyML.error_depth; |
30626 | 132 |
|
30676
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
133 |
val pretty_ml = |
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
134 |
let |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
61794
diff
changeset
|
135 |
fun convert _ (PolyML.PrettyBreak (width, offset)) = ML_Pretty.Break (false, width, offset) |
54718 | 136 |
| 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
|
137 |
[PolyML.ContextProperty ("fbrk", _)], [PolyML.PrettyString " "])) = |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
61794
diff
changeset
|
138 |
ML_Pretty.Break (true, 1, 0) |
61864 | 139 |
| 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
|
140 |
let |
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
141 |
fun property name default = |
31318 | 142 |
(case List.find (fn PolyML.ContextProperty (a, _) => name = a | _ => false) context of |
143 |
SOME (PolyML.ContextProperty (_, b)) => b |
|
54718 | 144 |
| _ => default); |
30676
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
145 |
val bg = property "begin" ""; |
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
146 |
val en = property "end" ""; |
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
147 |
val len' = property "length" len; |
61869 | 148 |
in ML_Pretty.Block ((bg, en), consistent, ind, map (convert len') prts) end |
31318 | 149 |
| convert len (PolyML.PrettyString s) = |
30676
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
150 |
ML_Pretty.String (s, case Int.fromString len of SOME i => i | NONE => size s) |
edca392a2abb
pretty_ml/ml_pretty: proper handling of markup and string length;
wenzelm
parents:
30673
diff
changeset
|
151 |
in convert "" end; |
30638 | 152 |
|
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
61794
diff
changeset
|
153 |
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
|
154 |
| 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
|
155 |
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
|
156 |
[PolyML.PrettyString " "]) |
61869 | 157 |
| ml_pretty (ML_Pretty.Block ((bg, en), consistent, ind, prts)) = |
30679 | 158 |
let val context = |
31318 | 159 |
(if bg = "" then [] else [PolyML.ContextProperty ("begin", bg)]) @ |
160 |
(if en = "" then [] else [PolyML.ContextProperty ("end", en)]) |
|
61864 | 161 |
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
|
162 |
| ml_pretty (ML_Pretty.String (s, len)) = |
31318 | 163 |
if len = size s then PolyML.PrettyString s |
164 |
else 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
|
165 |
(0, false, [PolyML.ContextProperty ("length", Int.toString len)], [PolyML.PrettyString s]); |
30626 | 166 |
|
60897 | 167 |
|
168 |
(* ML compiler *) |
|
169 |
||
170 |
structure ML_Name_Space = |
|
171 |
struct |
|
60953
87f0f707a5f8
clarified initial ML name space (amending 7aad4be8a48e);
wenzelm
parents:
60923
diff
changeset
|
172 |
open ML_Name_Space; |
61715
5dc95d957569
speculative support for polyml-5.6, according to git commit 3527f4ba7b8b;
wenzelm
parents:
60993
diff
changeset
|
173 |
val display_val = pretty_ml o displayVal; |
60897 | 174 |
end; |
175 |
||
60956 | 176 |
use "ML-Systems/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
|
177 |
if ML_System.name = "polyml-5.6" |
4c232a2ddeab
discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents:
61715
diff
changeset
|
178 |
then use "ML-Systems/ml_compiler_parameters_polyml-5.6.ML" else (); |
60956 | 179 |
|
60897 | 180 |
use "ML-Systems/use_context.ML"; |
181 |
use "ML-Systems/ml_positions.ML"; |
|
182 |
use "ML-Systems/compiler_polyml.ML"; |
|
183 |
||
184 |
PolyML.Compiler.reportUnreferencedIds := true; |
|
185 |
PolyML.Compiler.printInAlphabeticalOrder := false; |
|
186 |
PolyML.Compiler.maxInlineSize := 80; |
|
187 |
||
188 |
fun ml_prompts p1 p2 = (PolyML.Compiler.prompt1 := p1; PolyML.Compiler.prompt2 := p2); |
|
189 |
||
190 |
use "ML-Systems/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
|
191 |
if ML_System.name = "polyml-5.6" |
4c232a2ddeab
discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents:
61715
diff
changeset
|
192 |
then use "ML-Systems/ml_parse_tree_polyml-5.6.ML" else (); |
60897 | 193 |
|
30673 | 194 |
fun toplevel_pp context (_: string list) pp = |
60956 | 195 |
use_text context {line = 1, file = "pp", verbose = false, debug = false} |
31318 | 196 |
("PolyML.addPrettyPrinter (fn _ => fn _ => ml_pretty o Pretty.to_ML o (" ^ pp ^ "))"); |
30626 | 197 |
|
59127
723b11f8ffbf
more careful handling of auxiliary environment structure -- allow nested ML evaluation;
wenzelm
parents:
59055
diff
changeset
|
198 |
fun ml_make_string struct_name = |
723b11f8ffbf
more careful handling of auxiliary environment structure -- allow nested ML evaluation;
wenzelm
parents:
59055
diff
changeset
|
199 |
"(fn x => Pretty.string_of (Pretty.from_ML (pretty_ml (PolyML.prettyRepresentation (x, " ^ |
723b11f8ffbf
more careful handling of auxiliary environment structure -- allow nested ML evaluation;
wenzelm
parents:
59055
diff
changeset
|
200 |
struct_name ^ ".ML_print_depth ())))))"; |
60897 | 201 |
|
202 |
||
203 |
(* ML debugger *) |
|
204 |
||
61794
4c232a2ddeab
discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents:
61715
diff
changeset
|
205 |
if ML_System.name = "polyml-5.6" |
4c232a2ddeab
discontinued intermediate polyml-5.5.3, assuming the coming release will be polyml-5.6;
wenzelm
parents:
61715
diff
changeset
|
206 |
then use "ML-Systems/ml_debugger_polyml-5.6.ML" |
60954
eeee8349e9eb
abstract exn_id based on getExnId in polyml/basis/FinalPolyML.sml (NB: the mutable machine word cannot be inspected in ML, e.g. toplevel pp dumps core);
wenzelm
parents:
60953
diff
changeset
|
207 |
else use "ML-Systems/ml_debugger.ML"; |