-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_polyml.sh
executable file
·92 lines (82 loc) · 2.17 KB
/
build_polyml.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# Builds the PolyML's build.sml file from the smlgen.mlb file.
cat > build.sml <<EOL
structure Unsafe =
struct
structure Basis =
struct
structure Array = Array
structure Vector = Vector
structure CharArray = CharArray
structure CharVector = CharVector
structure Word8Array = Word8Array
structure Word8Vector = Word8Vector
end
structure Vector = struct val sub = Basis.Vector.sub end
structure Array =
struct
val sub = Basis.Array.sub
val update = Basis.Array.update
val create = Basis.Array.array
end
structure CharArray =
struct
open Basis.CharArray
fun create i =
array (i, chr 0)
end
structure CharVector =
struct
open Basis.CharVector
fun create i =
Basis.CharArray.vector (Basis.CharArray.array (i, chr 0))
fun update (vec, i, el) =
raise Fail "Unimplemented: Unsafe.CharVector.update"
end
structure Word8Array =
struct
open Basis.Word8Array
fun create i = array (i, 0w0)
end
structure Word8Vector =
struct
open Basis.Word8Vector
fun create i =
Basis.Word8Array.vector (Basis.Word8Array.array (i, 0w0))
fun update (vec, i, el) =
raise Fail "Unimplemented: Unsafe.Word8Vector.update"
end
structure Real64Array =
struct
open Basis.Array
type elem = Real.real
type array = elem array
fun create i = array (i, 0.0)
end
end;
fun useProject root' file =
let val root = OS.FileSys.getDir ()
in
OS.FileSys.chDir root';
use file;
OS.FileSys.chDir root
end;
(* Uncomment this and put library files in here to prevent reloading them each time. *)
(*
PolyML.SaveState.loadState "save" handle _ => (
PolyML.SaveState.saveState "save" );
*)
EOL
mlton -stop f smlgen.mlb \
| grep -v ".mlb" \
| grep -v "/usr/local/lib/mlton/sml/basis/" \
| grep -v "/usr/local/lib/mlton/targets/" \
| grep -v "^main.sml" \
| while read line ; do \
if [ -f "${line/%.mlton.sml/.polyml.sml}" ]; then \
echo "use \"${line/%.mlton.sml/.polyml.sml}\";" ; \
elif [ -f "${line/%.mlton.sml/.smlnj.sml}" ]; then \
echo "use \"${line/%.mlton.sml/.smlnj.sml}\";" ; \
fi \
done \
>> build.sml