-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgloc_js.html
47 lines (40 loc) · 907 Bytes
/
gloc_js.html
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
<html>
<body>
<script type="text/javascript">
var MissingEnvVar = function(name) {
this.message = "Missing environment variable '"+name+"'";
this.name = name;
};
function caml_sys_getenv(env) {
if (env.fullBytes=="TMPDIR") return new MlString("/tmp");
if (env.fullBytes=="TEMP") return new MlString("/tmp");
console.dir(env);
throw (new MissingEnvVar(env.string));
}
var ocaml = {};
var register_ocaml_fn = (function(m) {
return function(name, fn) { m[name] = fn; };
})(ocaml);
function gloc_stdout(s) {
alert("stdout:\n"+s);
}
function gloc_stderr(s) {
alert("stderr:\n"+s);
}
function gloc_stdin() {
return prompt("stdin");
}
function gloc_fs_read(fn) {
return prompt(fn);
}
function gloc_fs_write(fn, s) {
alert(fn+":\n"+s);
}
</script>
<script src="_build/gloc_js.d.js"></script>
<script>
var args = prompt("gloc ").split(" ");
ocaml.gloc(args);
</script>
</body>
</html>