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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
|
// Js_of_ocaml runtime support
// http://www.ocsigen.org/js_of_ocaml/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, with linking exception;
// either version 2.1 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////// Array
//Provides: caml_array_sub mutable
function caml_array_sub(a, i, len) {
var a2 = new Array(len + 1);
a2[0] = 0;
for (var i2 = 1, i1 = i + 1; i2 <= len; i2++, i1++) {
a2[i2] = a[i1];
}
return a2;
}
//Provides: caml_floatarray_sub mutable
//Requires: caml_array_sub
//Version: >= 5.3
function caml_floatarray_sub(a, i, len) {
return caml_array_sub(a, i, len);
}
//Provides: caml_uniform_array_sub mutable
//Requires: caml_array_sub
//Version: >= 5.3
function caml_uniform_array_sub(a, i, len) {
return caml_array_sub(a, i, len);
}
//Provides: caml_array_append mutable
function caml_array_append(a1, a2) {
var l1 = a1.length,
l2 = a2.length;
var l = l1 + l2 - 1;
var a = new Array(l);
a[0] = 0;
var i = 1,
j = 1;
for (; i < l1; i++) a[i] = a1[i];
for (; i < l; i++, j++) a[i] = a2[j];
return a;
}
//Provides: caml_floatarray_append mutable
//Requires: caml_array_append
//Version: >= 5.3
function caml_floatarray_append(a1, a2) {
return caml_array_append(a1, a2);
}
//Provides: caml_uniform_array_append mutable
//Requires: caml_array_append
//Version: >= 5.3
function caml_uniform_array_append(a1, a2) {
return caml_array_append(a1, a2);
}
//Provides: caml_array_concat mutable
function caml_array_concat(l) {
var a = [0];
while (l !== 0) {
var b = l[1];
for (var i = 1; i < b.length; i++) a.push(b[i]);
l = l[2];
}
return a;
}
//Provides: caml_floatarray_concat mutable
//Version: >= 5.4
function caml_floatarray_concat(l) {
var a = [0];
while (l !== 0) {
var b = l[1];
for (var i = 1; i < b.length; i++) a.push(b[i]);
l = l[2];
}
return a;
}
//Provides: caml_uniform_array_concat mutable
//Version: >= 5.4
function caml_uniform_array_concat(l) {
var a = [0];
while (l !== 0) {
var b = l[1];
for (var i = 1; i < b.length; i++) a.push(b[i]);
l = l[2];
}
return a;
}
//Provides: caml_array_blit
function caml_array_blit(a1, i1, a2, i2, len) {
if (i2 <= i1) {
for (var j = 1; j <= len; j++) a2[i2 + j] = a1[i1 + j];
} else {
for (var j = len; j >= 1; j--) a2[i2 + j] = a1[i1 + j];
}
return 0;
}
//Provides: caml_floatarray_blit
//Requires: caml_array_blit
function caml_floatarray_blit(a1, i1, a2, i2, len) {
return caml_array_blit(a1, i1, a2, i2, len);
}
//Provides: caml_uniform_array_blit
//Requires: caml_array_blit
//Version: >= 5.3
function caml_uniform_array_blit(a1, i1, a2, i2, len) {
return caml_array_blit(a1, i1, a2, i2, len);
}
///////////// Pervasive
//Provides: caml_array_set (mutable, const, mutable)
//Requires: caml_array_bound_error
//Alias: caml_array_set_float
//Alias: caml_floatarray_set
//Alias: caml_array_set_addr
function caml_array_set(array, index, newval) {
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
array[index + 1] = newval;
return 0;
}
//Provides: caml_array_get mutable (mutable, const)
//Requires: caml_array_bound_error
//Alias: caml_array_get_float
//Alias: caml_floatarray_get
//Alias: caml_array_get_addr
function caml_array_get(array, index) {
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
return array[index + 1];
}
//Provides: caml_array_fill
function caml_array_fill(array, ofs, len, v) {
for (var i = 0; i < len; i++) {
array[ofs + i + 1] = v;
}
return 0;
}
//Provides: caml_floatarray_fill
//Requires: caml_array_fill
//Version: >= 5.3
function caml_floatarray_fill(array, ofs, len, v) {
return caml_array_fill(array, ofs, len, v);
}
//Provides: caml_floatarray_fill_unboxed
//Requires: caml_array_fill
//Version: >= 5.3
function caml_floatarray_fill_unboxed(array, ofs, len, v) {
return caml_array_fill(array, ofs, len, v);
}
//Provides: caml_uniform_array_fill
//Requires: caml_array_fill
//Version: >= 5.3
function caml_uniform_array_fill(array, ofs, len, v) {
return caml_array_fill(array, ofs, len, v);
}
//Provides: caml_check_bound (mutable, const)
//Requires: caml_array_bound_error
//Alias: caml_check_bound_gen
//Alias: caml_check_bound_float
function caml_check_bound(array, index) {
if (index >>> 0 >= array.length - 1) caml_array_bound_error();
return array;
}
//Provides: caml_array_make const (const, mutable)
//Requires: caml_array_bound_error
function caml_array_make(len, init) {
if (len >>> 0 >= ((0x7fffffff / 4) | 0)) caml_array_bound_error();
var len = (len + 1) | 0;
var b = new Array(len);
b[0] = 0;
for (var i = 1; i < len; i++) b[i] = init;
return b;
}
//Provides: caml_make_vect const (const, mutable)
//Requires: caml_array_make
function caml_make_vect(len, init) {
return caml_array_make(len, init);
}
//Provides: caml_make_float_vect const (const)
//Requires: caml_array_bound_error
function caml_make_float_vect(len) {
if (len >>> 0 >= ((0x7fffffff / 8) | 0)) caml_array_bound_error();
var len = (len + 1) | 0;
var b = new Array(len);
b[0] = 254;
for (var i = 1; i < len; i++) b[i] = 0;
return b;
}
//Provides: caml_array_create_float const (const)
//Requires: caml_array_bound_error
//Version: >= 5.3
function caml_array_create_float(len) {
if (len >>> 0 >= ((0x7fffffff / 8) | 0)) caml_array_bound_error();
var len = (len + 1) | 0;
var b = new Array(len);
b[0] = 254;
for (var i = 1; i < len; i++) b[i] = 0;
return b;
}
//Provides: caml_floatarray_create const (const)
//Requires: caml_array_bound_error
function caml_floatarray_create(len) {
if (len >>> 0 >= ((0x7fffffff / 8) | 0)) caml_array_bound_error();
var len = (len + 1) | 0;
var b = new Array(len);
b[0] = 254;
for (var i = 1; i < len; i++) b[i] = 0;
return b;
}
//Provides: caml_floatarray_make const (const)
//Requires: caml_array_bound_error
//Version: >= 5.3
function caml_floatarray_make(len, init) {
if (len >>> 0 >= ((0x7fffffff / 8) | 0)) caml_array_bound_error();
var len = (len + 1) | 0;
var b = new Array(len);
b[0] = 254;
for (var i = 1; i < len; i++) b[i] = init;
return b;
}
//Provides: caml_floatarray_make_unboxed const (const)
//Requires: caml_floatarray_make
//Version: >= 5.3
function caml_floatarray_make_unboxed(len, init) {
return caml_floatarray_make(len, init);
}
//Provides: caml_uniform_array_make const (const)
//Requires: caml_array_make
//Version: >= 5.3
function caml_uniform_array_make(len, init) {
return caml_array_make(len, init);
}
|