Newer
Older
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
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
//----------------------------------------------------------------------------
// var print = function (x) { console.log(x) }
// var stuck = function (msg) { throw {type:'stuck', msg:msg} }
// var to_string = function (x) { return String(x) }
//----------------------------------------------------------------------------
/* automatically dealt with js_of_ast.ml
val ( + ) : int -> int -> int
val ( - ) : int -> int -> int
val ( * ) : int -> int -> int
val ( / ) : int -> int -> int
val ( +. ) : float -> float -> float
val ( -. ) : float -> float -> float
val ( *. ) : float -> float -> float
val ( /. ) : float -> float -> float
val ( = ) : float -> float -> bool
val ( < ) : float -> float -> bool
val ( > ) : float -> float -> bool
val ( <= ) : float -> float -> bool
val ( >= ) : float -> float -> bool
*/
//----------------------------------------------------------------------------
var nat_eq = function(x, y) { return x === y; };
var int_eq = function(x, y) { return x === y; };
var int_ge = function(x, y) { return x >= y; };
//----------------------------------------------------------------------------
var int_of_float = function(x) { return x; };
var number_of_int = function(x) { return x; };
var of_int = function(x) { return x; };
//----------------------------------------------------------------------------
var number_comparable = function(x, y) {
if (typeof(x) != "number" || typeof(y) != "number")
throw "string_eq invalid arguments";
return x === y;
};
//----------------------------------------------------------------------------
var bool_eq = function(x, y) { return x === y; };
var not = function(x) { return !x; };
//----------------------------------------------------------------------------
var string_eq = function(x, y) {
if (typeof(x) != "string" || typeof(y) != "string")
throw "string_eq invalid arguments";
return x === y;
};
var strappend = function(x, y) {
if (typeof(x) != "string" || typeof(y) != "string")
throw "strappend invalid arguments";
return x + y;
};
var strlength = function(x) {
if (typeof(x) != "string")
throw "strlength invalid arguments";
return x.length;
};
var substring = function(n, m, s) {
if (typeof(s) != "string")
throw "strlength invalid arguments";
return s.slice(n, n+m);
};
//----------------------------------------------------------------------------
/*
(* We use this to compare types that are not known by stdlib, like Native_error;
should be implemented in JS by comparing the objects, to see if they have the same
"tag" fields (there should be no other fields, except perhaps "type") *)
val ( === ) : 'a -> 'a -> bool (* becomes === in js *)
*/
//----------------------------------------------------------------------------
var __LOC__ = "___LOC___"
var raise = function(x) { throw "Not_found"; };