PageRenderTime 70ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/rts/rts-common.js

http://github.com/ghcjs/ghcjs
JavaScript | 2091 lines | 1948 code | 53 blank | 90 comment | 302 complexity | 287c2bad104200e94b55f94acb377b8f MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. var $hs_mkBool = function(b) {
  2. return b ? $$GHCziTypes_True:$$GHCziTypes_False;
  3. };
  4. var $hs_mulIntMayOflozh = function(a, b) {
  5. if(WORD_SIZE_IN_BITS==32) {
  6. var x = a * b;
  7. return x===(x|0)?0:1;
  8. }
  9. else {
  10. return goog.math.Long.fromBits(0,
  11. (a.isNegative()?a.negate():a).getHighBits() |
  12. (b.isNegative()?b.negate():b).getHighBits());
  13. }
  14. };
  15. var $hs_addIntCzh = function(a, b) {
  16. if(WORD_SIZE_IN_BITS==32) {
  17. var x = a + b;
  18. return [x|0, x===(x|0)?0:1];
  19. }
  20. else {
  21. var x = goog.math.Integer.fromBits([a.getLowBits(), a.getHighBits()])
  22. .add(goog.math.Integer.fromBits([b.getLowBits(), b.getHighBits()]));
  23. return [goog.math.Long.fromBits(x.getBits(0), x.getBits(1)),
  24. x.sign_===x.getBits(2)?0:1];
  25. }
  26. };
  27. var $hs_subIntCzh = function(a, b) {
  28. if(WORD_SIZE_IN_BITS==32) {
  29. var x = a - b;
  30. return [x|0, x===(x|0)?0:1];
  31. }
  32. else {
  33. var x = goog.math.Integer.fromBits([a.getLowBits(), a.getHighBits()])
  34. .subtract(goog.math.Integer.fromBits([b.getLowBits(), b.getHighBits()]));
  35. return [goog.math.Long.fromBits(x.getBits(0), x.getBits(1)),
  36. x.sign_===x.getBits(2)?0:1];
  37. }
  38. };
  39. var $hs_ordzh = function(a) {
  40. if(WORD_SIZE_IN_BITS==32) {
  41. return a.charCodeAt();
  42. }
  43. else {
  44. return goog.math.Long.fromNumber(a.charCodeAt());
  45. }
  46. };
  47. var $hs_chrzh = function(a) {
  48. if(WORD_SIZE_IN_BITS==32) {
  49. return String.fromCharCode(a);
  50. }
  51. else {
  52. return String.fromCharCode(a.toNumber());
  53. }
  54. };
  55. var $hs_popCntTab =
  56. [0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
  57. 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
  58. 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
  59. 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
  60. 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
  61. 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
  62. 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
  63. 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8];
  64. var $hs_popCnt8 = function(a) {
  65. return $hs_popCntTab[a & 0xFF];
  66. };
  67. var $hs_popCnt8zh = function(a) {
  68. if(WORD_SIZE_IN_BITS==32) {
  69. return $hs_popCnt8(a);
  70. }
  71. else {
  72. return goog.math.Long.fromNumber(
  73. $hs_popCnt8(a.getLowBits()));
  74. }
  75. };
  76. var $hs_popCnt16zh = function(a) {
  77. if(WORD_SIZE_IN_BITS==32) {
  78. return $hs_popCnt8(a) + $hs_popCnt8(a>>>8);
  79. }
  80. else {
  81. return goog.math.Long.fromNumber(
  82. $hs_popCnt8(a.getLowBits())+$hs_popCnt8(a.getLowBits()>>>8));
  83. }
  84. };
  85. var $hs_popCnt32zh = function(a) {
  86. if(WORD_SIZE_IN_BITS==32) {
  87. return $hs_popCnt8(a) + $hs_popCnt8(a>>>8) + $hs_popCnt8(a>>>16) + $hs_popCnt8(a>>>24);
  88. }
  89. else {
  90. var l = a.getLowBits();
  91. return goog.math.Long.fromNumber(
  92. $hs_popCnt8(l)+$hs_popCnt8(l>>>8) + $hs_popCnt8(l>>>16) + $hs_popCnt8(l>>>24));
  93. }
  94. };
  95. var $hs_popCnt64zh = function(a) {
  96. var l = a.getLowBits();
  97. var h = a.getHighBits();
  98. var result =
  99. $hs_popCnt8(l)+$hs_popCnt8(l>>>8) + $hs_popCnt8(l>>>16) + $hs_popCnt8(l>>>24) +
  100. $hs_popCnt8(h)+$hs_popCnt8(h>>>8) + $hs_popCnt8(h>>>16) + $hs_popCnt8(h>>>24);
  101. if(WORD_SIZE_IN_BITS==32) {
  102. return result;
  103. }
  104. else {
  105. return goog.math.Long.fromNumber(result);
  106. }
  107. };
  108. var $hs_popCntzh = WORD_SIZE_IN_BITS==32 ? $hs_popCnt32zh : $hs_popCnt64zh;
  109. var $hs_expDoublezh = function(a) {
  110. return Math.exp(a);
  111. };
  112. var $hs_logDoublezh = function(a) {
  113. return Math.log(a);
  114. };
  115. var $hs_sqrtDoublezh = function(a) {
  116. return Math.sqrt(a);
  117. };
  118. var $hs_sinDoublezh = function(a) {
  119. return Math.sin(a);
  120. };
  121. var $hs_cosDoublezh = function(a) {
  122. return Math.cos(a);
  123. };
  124. var $hs_tanDoublezh = function(a) {
  125. return Math.tan(a);
  126. };
  127. var $hs_asinDoublezh = function(a) {
  128. return Math.asin(a);
  129. };
  130. var $hs_acosDoublezh = function(a) {
  131. return Math.acos(a);
  132. };
  133. var $hs_atanDoublezh = function(a) {
  134. return Math.atan(a);
  135. };
  136. var $hs_sinhDoublezh = function(a) {
  137. return (Math.exp(a) - Math.exp(-a)) / 2;
  138. };
  139. var $hs_coshDoublezh = function(a) {
  140. return (Math.exp(a) + Math.exp(-a)) / 2;
  141. };
  142. var $hs_tanhDoublezh = function(a) {
  143. var expA = Math.exp(a);
  144. var expNegA = Math.exp(-a);
  145. return (expA - expNegA) / (expA + expNegA);
  146. };
  147. var $hs_ztztzhzh = function(a, b) {
  148. return Math.pow(a,b);
  149. };
  150. var $hs_decodeDoublezu2Intzh = function(x) {
  151. if( x < 0 ) {
  152. var result = $hs_decodeDoublezu2Intzh(-x);
  153. return [-1, result[1], result[2], result[3]];
  154. }
  155. var negExponent = 52-Math.floor(Math.log(x) * 1.4426950408889634); // 1/log(2)
  156. var mantissa = goog.math.Long.fromNumber(x * Math.pow(2, negExponent));
  157. return [1, mantissa.getHighBits(), mantissa.getLowBits(), -negExponent];
  158. };
  159. var $hs_expFloatzh = function(a) {
  160. return Math.exp(a);
  161. };
  162. var $hs_logFloatzh = function(a) {
  163. return Math.log(a);
  164. };
  165. var $hs_sqrtFloatzh = function(a) {
  166. return Math.sqrt(a);
  167. };
  168. var $hs_sinFloatzh = function(a) {
  169. return Math.sin(a);
  170. };
  171. var $hs_cosFloatzh = function(a) {
  172. return Math.cos(a);
  173. };
  174. var $hs_tanFloatzh = function(a) {
  175. return Math.tan(a);
  176. };
  177. var $hs_asinFloatzh = function(a) {
  178. return Math.asin(a);
  179. };
  180. var $hs_acosFloatzh = function(a) {
  181. return Math.acos(a);
  182. };
  183. var $hs_atanFloatzh = function(a) {
  184. return Math.atan(a);
  185. };
  186. var $hs_sinhFloatzh = function(a) {
  187. return (Math.exp(a) - Math.exp(-a)) / 2;
  188. };
  189. var $hs_coshFloatzh = function(a) {
  190. return (Math.exp(a) + Math.exp(-a)) / 2;
  191. };
  192. var $hs_tanhFloatzh = function(a) {
  193. var expA = Math.exp(a);
  194. var expNegA = Math.exp(-a);
  195. return (expA - expNegA) / (expA + expNegA);
  196. };
  197. var $hs_powerFloatzh = function(a, b) {
  198. return Math.pow(a, b);
  199. };
  200. var $hs_decodeFloatzuIntzh = function(x) {
  201. // This probably gives unexpected results.
  202. // In particular we need to check...
  203. // * NaN
  204. // * Infinity
  205. if( x < 0 ) {
  206. var result = $hs_decodeFloatzuIntzh(-x);
  207. return [-result[0], result[1]];
  208. }
  209. var negExponent = 23-Math.floor(Math.log(x) * 1.4426950408889634); // 1/log(2)
  210. return [(x * Math.pow(2, negExponent))|0, -negExponent];
  211. };
  212. var isDoubleNegativeZero = function(a) {
  213. return (a==-0.0)?1:0;
  214. };
  215. var isDoubleNaN = function(a) {
  216. return (isNaN(a))?1:0;
  217. };
  218. var isDoubleInfinite = function(a) {
  219. return (isFinite(a)||isNaN(a))?0:1;
  220. };
  221. var isFloatNegativeZero = function(a) { // fixme switch to proper 32 bit floats
  222. return (a==-0.0)?1:0;
  223. };
  224. var isFloatNaN = function(a) {
  225. return (isNaN(a))?1:0;
  226. };
  227. var isFloatInfinite = function(a) {
  228. return (isFinite(a)||isNaN(a))?0:1;
  229. };
  230. var integer_cbits_encodeDouble = function(s, bits, e) {
  231. var g = $hs_gmpToGoog(s, bits);
  232. return Math.pow(2,e)*g.toNumber();
  233. };
  234. var __int_encodeDouble = function(b, e) {
  235. return Math.pow(2,e) * b;
  236. };
  237. var rintDouble = function(a) {
  238. return Math.round(a);
  239. };
  240. var $hs_newMutVarzh = function(a, s) {
  241. return [s, {value : a}];
  242. };
  243. var $hs_readMutVarzh = function (a, s) {
  244. return [s, a.value];
  245. };
  246. var $hs_writeMutVarzh = function (a, b, s) {
  247. a.value = b;
  248. return s;
  249. };
  250. var $hs_sameMutVarzh = function (a, b) {
  251. return a === b;
  252. };
  253. var $hs_newArrayzh = function(n, a, s) {
  254. var result = [];
  255. for (var x = 0; x != n; x++)
  256. result[x] = a;
  257. return [s, result];
  258. };
  259. var $hs_sameMutableArrayzh = function (a, b) {
  260. return a === b;
  261. };
  262. var $hs_readArrayzh = function (a, n, s) {
  263. return [s, a[n]];
  264. };
  265. var $hs_writeArrayzh = function (a, n, b, s) {
  266. a[n] = b;
  267. return s;
  268. };
  269. var $hs_sizeofArrayzh = function (a, s) {
  270. return [s, a.length];
  271. };
  272. var $hs_sizeofMutableArrayzh = function (a, s) {
  273. return [s, a.length];
  274. };
  275. var $hs_indexArrayzh = function (a, n) {
  276. return [a[n]]; // Unboxed singleton
  277. };
  278. var $hs_unsafeFreezzeArrayzh = function (a, s) {
  279. return [s, a];
  280. };
  281. var $hs_unsafeThawArrayzh = function (a, s) {
  282. return [s, a];
  283. };
  284. // ByteArray support
  285. var $hs_ptrBase = 0;
  286. /**
  287. * @param {!number} n
  288. * @param {Object=} s
  289. */
  290. var $hs_newByteArrayzh = function (n, s) {
  291. var result = [new ArrayBuffer(n), 0, $hs_ptrBase];
  292. result[0].ptrs=[];
  293. $hs_ptrBase += n;
  294. return [s, result];
  295. };
  296. /**
  297. * @param {!number} n
  298. * @param {Object=} s
  299. */
  300. var $hs_newPinnedByteArrayzh = function (n, s) {
  301. var result = [new ArrayBuffer(n), 0, $hs_ptrBase];
  302. result[0].ptrs=[];
  303. $hs_ptrBase += n;
  304. return [s, result];
  305. };
  306. /**
  307. * @param {!number} n
  308. * @param {Object=} s
  309. */
  310. var $hs_newAlignedPinnedByteArrayzh = function (n, k, s) {
  311. $hs_ptrBase += $hs_ptrBase%k;
  312. var result = [new ArrayBuffer(n), 0, $hs_ptrBase];
  313. result[0].ptrs=[];
  314. $hs_ptrBase += n;
  315. return [s, result];
  316. };
  317. var $hs_byteArrayContentszh = function (a) {
  318. return a;
  319. };
  320. var $hs_sameMutableByteArrayzh = function (a, b) {
  321. return a[2] === b[2];
  322. };
  323. var $hs_unsafeFreezzeByteArrayzh = function (a, s) {
  324. return [s, a];
  325. };
  326. var $hs_sizeofByteArrayzh = function (a) {
  327. return new Uint8Array(a[0]).length;
  328. };
  329. var $hs_sizeofMutableByteArrayzh = function (a) {
  330. return new Uint8Array(a[0]).length;
  331. };
  332. var $hs_indexCharArrayzh = function (a, n) {
  333. return String.fromCharCode(new Uint8Array(a[0])[n]);
  334. };
  335. var $hs_indexWideCharArrayzh = function (a, n) {
  336. return String.fromCharCode(new Uint32Array(a[0])[n]);
  337. };
  338. // --- goog.math.Integer and (# Int#, ByteArray# #) mapping
  339. //
  340. // Unfortunately goog.math.Integer.bits_ are the bits of a signed in.
  341. // goog.math.Integer.sign_ is the value of the rest of the infinite list.
  342. //
  343. // We want (s, bits) where bits is the ByteArray of the bits of the
  344. // absolute value. And s is
  345. // | n == 0 -> 0
  346. // | n > 0 -> length bits
  347. // | n < 0 -> -(length bits)
  348. //
  349. // For performance we will store the goog.math.Integer as the ByteArray
  350. // and spin up a cached positive version to work out the correct bits.
  351. //
  352. // When constructing the goog.math.Integer in most cases ByteArray
  353. // will be the desired number.
  354. var $hs_fastNegate = function(a) {
  355. if(a.negateCache_ === undefined) {
  356. a.negateCache_ = a.negate();
  357. a.negateCache_.negateCache_ = a;
  358. }
  359. return a.negateCache_;
  360. };
  361. var $hs_absolute = function(a) {
  362. if(a.isNegative()) {
  363. return $hs_fastNegate(a);
  364. }
  365. return a;
  366. };
  367. var $hs_googToGMP = function(a) {
  368. var bits = $hs_absolute(a).bits_;
  369. var s = bits.length;
  370. while(s !== 0 && bits[s-1] === 0)
  371. s--;
  372. s = a.isNegative() ? -s : s;
  373. return [WORD_SIZE_IN_BITS==32 ? s : goog.math.Long.fromNumber(s), a];
  374. };
  375. var $hs_gmpToGoog = function(s,bits) {
  376. s = WORD_SIZE_IN_BITS==32 ? s : s.toNumber();
  377. // If s is 0 then the number we want is 0
  378. if(s===0) {
  379. return goog.math.Integer.ZERO;
  380. }
  381. // We are going to need to know long the bits array should be
  382. var len = s < 0 ? -s : s;
  383. // Try to avoid making a new integer if we can
  384. if(bits instanceof goog.math.Integer) {
  385. var current = $hs_googToGMP(bits);
  386. // Make sure we do not have too many bits
  387. if(len >= current[0]) {
  388. if((s<0) === bits.isNegative()) {
  389. // Both same sign so just return bits
  390. return bits;
  391. }
  392. else {
  393. // Only the sign is changed
  394. return $hs_fastNegate(bits);
  395. }
  396. }
  397. }
  398. // Ok lets build a new one
  399. var newBits = [];
  400. for(var n = 0; n !== len; n++) {
  401. newBits[n] = $hs_indexIntArrayzh(bits, n);
  402. }
  403. var i = new goog.math.Integer(newBits, 0);
  404. return s < 0 ? $hs_fastNegate(i) : i;
  405. };
  406. var $hs_indexIntArrayzh = function (a, n) {
  407. if(WORD_SIZE_IN_BITS==32) {
  408. if(a instanceof goog.math.Integer) {
  409. return $hs_absolute(a).getBits(n);
  410. }
  411. return new Int32Array(a[0])[n];
  412. }
  413. else {
  414. var n2 = n.toNumber()<<1;
  415. if(a instanceof goog.math.Integer) {
  416. var positive = $hs_absolute(a);
  417. return goog.math.Long.fromBits(positive.getBits(n2), positive.getBits(n2+1));
  418. }
  419. var x = new Int32Array(a[0]);
  420. return goog.math.Long.fromBits(x[n2], x[n2+1]);
  421. }
  422. };
  423. var $hs_indexWordArrayzh = function (a, n) {
  424. if(WORD_SIZE_IN_BITS==32) {
  425. // fixme there should be something better than checking this manually
  426. if(a instanceof goog.math.Integer) return $hs_absolute(a).getBits(n);
  427. else return new Uint32Array(a[0])[n];
  428. }
  429. else {
  430. var x = new Int32Array(a[0], n.toNumber()<<3);
  431. return goog.math.Long.fromBits(x[0], x[1]);
  432. }
  433. };
  434. var $hs_indexAddrArrayzh = function (a, n) {
  435. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  436. var res = a[0].ptrs[n];
  437. if(HS_DEBUG && res[2] !== new Uint32Array(a[0])[n])
  438. throw "Array Pointer Error";
  439. return res;
  440. };
  441. var $hs_indexFloatArrayzh = function (a, n) {
  442. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  443. return new Float32Array(a[0])[n];
  444. };
  445. var $hs_indexDoubleArrayzh = function (a, n) {
  446. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  447. return new Float64Array(a[0])[n];
  448. };
  449. var $hs_indexStablePtrArrayzh = function (a, n) {
  450. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  451. var res = a[0].ptrs[n];
  452. if(HS_DEBUG && res[2] !== new Uint32Array(a[0])[n])
  453. throw "Array Pointer Error";
  454. return res;
  455. };
  456. var $hs_indexInt8Arrayzh = function (a, n) {
  457. if(WORD_SIZE_IN_BITS == 32) {
  458. return new Int8Array(a[0])[n];
  459. } else {
  460. return goog.math.Long.fromNumber(new Int8Array(a[0])[n.toNumber()]);
  461. }
  462. };
  463. var $hs_indexInt16Arrayzh = function (a, n) {
  464. if(WORD_SIZE_IN_BITS == 32) {
  465. return new Int16Array(a[0])[n];
  466. } else {
  467. return goog.math.Long.fromNumber(new Int16Array(a[0])[n.toNumber()]);
  468. }
  469. };
  470. var $hs_indexInt32Arrayzh = function (a, n) {
  471. if(WORD_SIZE_IN_BITS == 32) {
  472. return new Int32Array(a[0])[n];
  473. } else {
  474. return goog.math.Long.fromNumber(new Int32Array(a[0])[n.toNumber()]);
  475. }
  476. };
  477. var $hs_indexInt64Arrayzh = function (a, n) {
  478. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  479. var x = new Int32Array(a[0], n<<3);
  480. return goog.math.Long.fromBits(x[0], x[1]);
  481. };
  482. var $hs_indexWord8Arrayzh = function (a, n) {
  483. if(WORD_SIZE_IN_BITS == 32) {
  484. return new Uint8Array(a[0])[n];
  485. } else {
  486. return goog.math.Long.fromBits(new Uint8Array(a[0])[n.toNumber()], 0);
  487. }
  488. };
  489. var $hs_indexWord16Arrayzh = function (a, n) {
  490. if(WORD_SIZE_IN_BITS == 32) {
  491. return new Uint16Array(a[0])[n];
  492. } else {
  493. return goog.math.Long.fromBits(new Uint16Array(a[0])[n.toNumber()], 0);
  494. }
  495. };
  496. var $hs_indexWord32Arrayzh = function (a, n) {
  497. if(WORD_SIZE_IN_BITS == 32) {
  498. return new Uint32Array(a[0])[n];
  499. } else {
  500. return goog.math.Long.fromBits(new Uint32Array(a[0])[n.toNumber()], 0);
  501. }
  502. };
  503. var $hs_indexWord64Arrayzh = function (a, n) {
  504. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  505. var x = new Int32Array(a[0], n<<3);
  506. return goog.math.Long.fromBits(x[0], x[1]);
  507. };
  508. var $hs_readCharArrayzh = function (a, n, s) {
  509. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  510. return [s, String.fromCharCode(new Uint8Array(a[0])[n])];
  511. };
  512. var $hs_readWideCharArrayzh = function (a, n, s) {
  513. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  514. return [s, String.fromCharCode(new Uint32Array(a[0])[n])];
  515. };
  516. var $hs_readIntArrayzh = function (a, n, s) {
  517. if(WORD_SIZE_IN_BITS==32) {
  518. return [s, new Int32Array(a[0])[n]];
  519. }
  520. else {
  521. var x = new Int32Array(a[0], n.toNumber()<<3);
  522. return [s, goog.math.Long.fromBits(x[0], x[1])];
  523. }
  524. };
  525. var $hs_readWordArrayzh = function (a, n, s) {
  526. if(WORD_SIZE_IN_BITS==32) {
  527. return [s, new Uint32Array(a[0])[n]];
  528. }
  529. else {
  530. var x = new Int32Array(a[0], n.toNumber()<<3);
  531. return [s, goog.math.Long.fromBits(x[0], x[1])];
  532. }
  533. };
  534. var $hs_readAddrArrayzh = function (a, n, s) {
  535. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  536. var res = a[0].ptrs[n];
  537. if(HS_DEBUG && res[2] !== new Uint32Array(a[0])[n])
  538. throw "Array Pointer Error";
  539. return [s, res];
  540. };
  541. var $hs_readFloatArrayzh = function (a, n, s) {
  542. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  543. return [s, new Float32Array(a[0])[n]];
  544. };
  545. var $hs_readDoubleArrayzh = function (a, n, s) {
  546. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  547. return [s, new Float64Array(a[0])[n]];
  548. };
  549. var $hs_readStablePtrArrayzh = function (a, n, s) {
  550. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  551. var res = a[0].ptrs[n];
  552. if(HS_DEBUG && res[2] !== new Uint32Array(a[0])[n])
  553. throw "Array Pointer Error";
  554. return [s, res];
  555. };
  556. var $hs_readInt8Arrayzh = function (a, n, s) {
  557. if(WORD_SIZE_IN_BITS == 32) {
  558. return [s, new Int8Array(a[0])[n]];
  559. } else {
  560. return [s, goog.math.Long.fromNumber(new Int8Array(a[0])[n.toNumber()])];
  561. }
  562. };
  563. var $hs_readInt16Arrayzh = function (a, n, s) {
  564. if(WORD_SIZE_IN_BITS == 32) {
  565. return [s, new Int16Array(a[0])[n]];
  566. } else {
  567. return [s, goog.math.Long.fromNumber(new Int16Array(a[0])[n.toNumber()])];
  568. }
  569. };
  570. var $hs_readInt32Arrayzh = function (a, n, s) {
  571. if(WORD_SIZE_IN_BITS == 32) {
  572. return [s, new Int32Array(a[0])[n]];
  573. } else {
  574. return [s, goog.math.Long.fromNumber(new Int32Array(a[0])[n.toNumber()])];
  575. }
  576. };
  577. var $hs_readInt64Arrayzh = function (a, n, s) {
  578. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  579. var x = new Int32Array(a[0], n<<3);
  580. return [s, goog.math.Long.fromBits(x[0], x[1])];
  581. };
  582. var $hs_readWord8Arrayzh = function (a, n, s) {
  583. if(WORD_SIZE_IN_BITS == 32) {
  584. return [s, new Uint8Array(a[0])[n]];
  585. } else {
  586. return [s, goog.math.Long.fromBits(new Uint8Array(a[0])[n.toNumber()], 0)];
  587. }
  588. };
  589. var $hs_readWord16Arrayzh = function (a, n, s) {
  590. if(WORD_SIZE_IN_BITS == 32) {
  591. return [s, new Uint16Array(a[0])[n]];
  592. } else {
  593. return [s, goog.math.Long.fromBits(new Uint16Array(a[0])[n.toNumber()], 0)];
  594. }
  595. };
  596. var $hs_readWord32Arrayzh = function (a, n, s) {
  597. if(WORD_SIZE_IN_BITS == 32) {
  598. return [s, new Uint32Array(a[0])[n]];
  599. } else {
  600. return [s, goog.math.Long.fromBits(new Uint32Array(a[0])[n.toNumber()], 0)];
  601. }
  602. };
  603. var $hs_readWord64Arrayzh = function (a, n, s) {
  604. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  605. var x = new Int32Array(a[0], n<<3);
  606. return [s, goog.math.Long.fromBits(x[0], x[1])];
  607. };
  608. var $hs_writeCharArrayzh = function (a, n, v, s) {
  609. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  610. new Uint8Array(a[0])[n] = v.charCodeAt();
  611. return s;
  612. };
  613. var $hs_writeWideCharArrayzh = function (a, n, v, s) {
  614. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  615. new Uint32Array(a[0])[n] = v.charCodeAt();
  616. return s;
  617. };
  618. var $hs_writeIntArrayzh = function (a, n, v, s) {
  619. if(WORD_SIZE_IN_BITS==32) {
  620. new Int32Array(a[0])[n] = v;
  621. return s;
  622. }
  623. else {
  624. var x = new Int32Array(a[0], n.toNumber()<<3);
  625. x[0] = v.getLowBits();
  626. x[1] = v.getHighBits();
  627. return s;
  628. }
  629. };
  630. var $hs_writeWordArrayzh = function (a, n, v, s) {
  631. if(WORD_SIZE_IN_BITS==32) {
  632. new Uint32Array(a[0])[n] = v;
  633. return s;
  634. }
  635. else {
  636. var x = new Int32Array(a[0], n.toNumber()<<3);
  637. x[0] = v.getLowBits();
  638. x[1] = v.getHighBits();
  639. return s;
  640. }
  641. };
  642. var $hs_writeAddrArrayzh = function (a, n, v, s) {
  643. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  644. a[0].ptrs[n] = v;
  645. new Uint32Array(a[0])[n] = v[2];
  646. return s;
  647. };
  648. var $hs_writeFloatArrayzh = function (a, n, v, s) {
  649. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  650. new Float32Array(a[0])[n] = v;
  651. return s;
  652. };
  653. var $hs_writeDoubleArrayzh = function (a, n, v, s) {
  654. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  655. new Float64Array(a[0])[n] = v;
  656. return s;
  657. };
  658. var $hs_writeStablePtrArrayzh = function (a, n, v, s) {
  659. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  660. a[0].ptrs[n] = v;
  661. new Uint32Array(a[0])[n] = v[2];
  662. return s;
  663. };
  664. var $hs_writeInt8Arrayzh = function (a, n, v, s) {
  665. if(WORD_SIZE_IN_BITS==32) {
  666. new Int8Array(a[0])[n] = v;
  667. }
  668. else {
  669. new Int8Array(a[0])[n.toNumber()] = v.getLowBits();
  670. }
  671. return s;
  672. };
  673. var $hs_writeInt16Arrayzh = function (a, n, v, s) {
  674. if(WORD_SIZE_IN_BITS==32) {
  675. new Int16Array(a[0])[n] = v;
  676. }
  677. else {
  678. new In16Array(a[0])[n.toNumber()] = v.getLowBits();
  679. }
  680. return s;
  681. };
  682. var $hs_writeInt32Arrayzh = function (a, n, v, s) {
  683. if(WORD_SIZE_IN_BITS==32) {
  684. new Int32Array(a[0])[n] = v;
  685. }
  686. else {
  687. new Int32Array(a[0])[n.toNumber()] = v.getLowBits();
  688. }
  689. return s;
  690. };
  691. var $hs_writeInt64Arrayzh = function (a, n, v, s) {
  692. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  693. var x = new Int32Array(a[0], n<<3);
  694. x[0] = v.getLowBits();
  695. x[1] = v.getHighBits();
  696. return s;
  697. };
  698. var $hs_writeWord8Arrayzh = function (a, n, v, s) {
  699. if(WORD_SIZE_IN_BITS==32) {
  700. new Uint8Array(a[0])[n] = v;
  701. }
  702. else {
  703. new Uint8Array(a[0])[n.toNumber()] = v.getLowBits();
  704. }
  705. return s;
  706. };
  707. var $hs_writeWord16Arrayzh = function (a, n, v, s) {
  708. if(WORD_SIZE_IN_BITS==32) {
  709. new Uint16Array(a[0])[n] = v;
  710. }
  711. else {
  712. new Uint16Array(a[0])[n.toNumber()] = v.getLowBits();
  713. }
  714. return s;
  715. };
  716. var $hs_writeWord32Arrayzh = function (a, n, v, s) {
  717. if(WORD_SIZE_IN_BITS==32) {
  718. new Uint32Array(a[0])[n] = v;
  719. }
  720. else {
  721. new Uint32Array(a[0])[n.toNumber()] = v.getLowBits();
  722. }
  723. return s;
  724. };
  725. var $hs_writeWord64Arrayzh = function (a, n, v, s) {
  726. n = WORD_SIZE_IN_BITS==32 ? n : n.toNumber();
  727. var x = new Int32Array(a[0], n<<3);
  728. x[0] = v.getLowBits();
  729. x[1] = v.getHighBits();
  730. return s;
  731. };
  732. var $hs_copyByteArrayzh = function (src, soff, dest, doff, count, s) {
  733. var srcarray = new Uint8Array(src[0]);
  734. var destarray = new Uint8Array(dest[0]);
  735. while(count != 0) {
  736. destarray[doff] = srcarray[soff];
  737. soff++;
  738. doff++;
  739. count--;
  740. }
  741. return s;
  742. };
  743. var $hs_copyMutableByteArrayzh = function (src, soff, dest, doff, count, s) {
  744. var srcarray = new Uint8Array(src[0]);
  745. var destarray = new Uint8Array(dest[0]);
  746. while(count != 0) {
  747. destarray[doff] = srcarray[soff];
  748. soff++;
  749. doff++;
  750. count--;
  751. }
  752. return s;
  753. };
  754. var $hs_plusAddrzh = function (a, n) {
  755. if(typeof(a) === 'string')
  756. return [a, n, n];
  757. else
  758. return [a[0],a[1]+n,a[2]+n];
  759. };
  760. var $hs_minusAddrzh = function (a, b) {
  761. return a[1]-b[1];
  762. };
  763. var $hs_remAddrzh = function (a, b) {
  764. return a[1]%b;
  765. };
  766. var $hs_gtAddrzh = function (a, b) {
  767. return $hs_mkBool(
  768. (a===null&&b===null)?false:
  769. ((a===null&&b!==null)?false:
  770. ((a!==null&&b===null)?true:(a[2]>b[2]))));
  771. };
  772. var $hs_geAddrzh = function (a, b) {
  773. return $hs_mkBool(
  774. (a===null&&b===null)?true:
  775. ((a===null&&b!==null)?false:
  776. ((a!==null&&b===null)?true:(a[2]>=b[2]))));
  777. };
  778. var $hs_eqAddrzh = function (a, b) {
  779. return $hs_mkBool(
  780. (a===null&&b===null)?true:
  781. ((a===null&&b!==null)?false:
  782. ((a!==null&&b===null)?false:(a[2]===b[2]))));
  783. };
  784. var $hs_neAddrzh = function (a, b) {
  785. return $hs_mkBool(
  786. (a===null&&b===null)?false:
  787. ((a===null&&b!==null)?true:
  788. ((a!==null&&b===null)?true:(a[2]!==b[2]))));
  789. };
  790. var $hs_ltAddrzh = function (a, b) {
  791. return $hs_mkBool(
  792. (a===null&&b===null)?false:
  793. ((a===null&&b!==null)?true:
  794. ((a!==null&&b===null)?false:(a[2]<b[2]))));
  795. };
  796. var $hs_leAddrzh = function (a, b) {
  797. return $hs_mkBool(
  798. (a===null&&b===null)?true:
  799. ((a===null&&b!==null)?true:
  800. ((a!==null&&b===null)?false:(a[2]<=b[2]))));
  801. };
  802. var $hs_indexCharOffAddrzh = function (a, n) {
  803. if(typeof(a) === 'string')
  804. return n==a.length?'\x00':a.charAt(n);
  805. else if(typeof(a[0]) === 'string')
  806. return n==a[0].length?'\x00':a[0].charAt(a[1]+n);
  807. else
  808. return String.fromCharCode(new Uint8Array(a[0],a[1]+n)[0]);
  809. };
  810. var $hs_indexWideCharOffAddrzh = function (a, n) {
  811. return String.fromCharCode(new Uint32Array(a[0],a[1]+(n<<2))[0]);
  812. };
  813. var $hs_indexIntOffAddrzh = function (a, n) {
  814. if(WORD_SIZE_IN_BITS==32) {
  815. return new Int32Array(a[0],a[1]+(n<<2))[0];
  816. }
  817. else {
  818. var x = new Int32Array(a[0], a[1] + (n<<3));
  819. return goog.math.Long.fromBits(x[0], x[1]);
  820. }
  821. };
  822. var $hs_indexWordOffAddrzh = function (a, n) {
  823. if(WORD_SIZE_IN_BITS==32) {
  824. return new Uint32Array(a[0],a[1]+(n<<2))[0];
  825. }
  826. else {
  827. var x = new Int32Array(a[0], a[1] + (n<<3));
  828. return goog.math.Long.fromBits(x[0], x[1]);
  829. }
  830. };
  831. var $hs_indexAddrOffAddrzh = function (a, n) {
  832. var res = a[0].ptrs[a[1]+(n<<2)];
  833. if(HS_DEBUG && res[2] !== new Uint32Array(a[0],a[1]+(n<<2))[0])
  834. throw "Array Pointer Error";
  835. return res;
  836. };
  837. var $hs_indexFloatOffAddrzh = function (a, n) {
  838. return new Float32Array(a[0],a[1]+(n<<2))[0];
  839. };
  840. var $hs_indexDoubleOffAddrzh = function (a, n) {
  841. return new Float64Array(a[0],a[1]+(n<<3))[0];
  842. };
  843. var $hs_indexStablePtrOffAddrzh = function (a, n) {
  844. var res = a[0].ptrs[a[1]+(n<<2)];
  845. if(HS_DEBUG && res[2] !== new Uint32Array(a[0],a[1]+(n<<2))[0])
  846. throw "Array Pointer Error";
  847. return res;
  848. };
  849. var $hs_indexInt8OffAddrzh = function (a, n) {
  850. if(WORD_SIZE_IN_BITS==32) {
  851. return new Int8Array(a[0],a[1]+n)[0];
  852. }
  853. else {
  854. return goog.math.Long.fromNumber(new Int8Array(a[0],a[1]+n)[0]);
  855. }
  856. };
  857. var $hs_indexInt16OffAddrzh = function (a, n) {
  858. if(WORD_SIZE_IN_BITS==32) {
  859. return new Int16Array(a[0],a[1]+(n<<1))[0];
  860. }
  861. else {
  862. return goog.math.Long.fromNumber(new Int16Array(a[0],a[1]+(n<<1))[0]);
  863. }
  864. };
  865. var $hs_indexInt32OffAddrzh = function (a, n) {
  866. if(WORD_SIZE_IN_BITS==32) {
  867. return new Int32Array(a[0],a[1]+(n<<2))[0];
  868. }
  869. else {
  870. return goog.math.Long.fromNumber(new Int32Array(a[0],a[1]+(n<<2))[0]);
  871. }
  872. };
  873. var $hs_indexInt64OffAddrzh = function (a, n) {
  874. var x = new Uint32Array(a[0],a[1]+(n<<3));
  875. return goog.math.Long.fromBits(x[0], x[1]);
  876. };
  877. var $hs_indexWord8OffAddrzh = function (a, n) {
  878. if(typeof(a) === 'string')
  879. var res = n==a.length?0:a.charCodeAt(n);
  880. else if(typeof(a[0]) === 'string')
  881. var res = n==a[0].length?0:a[0].charCodeAt(a[1]+n);
  882. else
  883. var res = new Uint8Array(a[0],a[1]+n)[0];
  884. return WORD_SIZE_IN_BITS==32 ? res : goog.math.Long.fromBits(res);
  885. };
  886. var $hs_indexWord16OffAddrzh = function (a, n) {
  887. if(WORD_SIZE_IN_BITS==32) {
  888. return new Uint16Array(a[0],a[1]+(n<<1))[0];
  889. }
  890. else {
  891. return goog.math.Long.fromBits(new Uint16Array(a[0],a[1]+(n<<1))[0], 0);
  892. }
  893. };
  894. var $hs_indexWord32OffAddrzh = function (a, n) {
  895. if(WORD_SIZE_IN_BITS==32) {
  896. return new Uint32Array(a[0],a[1]+(n<<2))[0];
  897. }
  898. else {
  899. return goog.math.Long.fromBits(new Uint32Array(a[0],a[1]+(n<<2))[0], 0);
  900. }
  901. };
  902. var $hs_indexWord64OffAddrzh = function (a, n) {
  903. var x = new Int32Array(a[0],a[1]+(n<<3));
  904. return goog.math.Long.fromBits(x[0], x[1]);
  905. };
  906. var $hs_readCharOffAddrzh = function (a, n, s) {
  907. return [s, String.fromCharCode(new Uint8Array(a[0],a[1]+n)[0])];
  908. };
  909. var $hs_readWideCharOffAddrzh = function (a, n, s) {
  910. return [s, String.fromCharCode(new Uint32Array(a[0],a[1]+(n<<2))[0])];
  911. };
  912. var $hs_readIntOffAddrzh = function (a, n, s) {
  913. if(WORD_SIZE_IN_BITS==32) {
  914. return [s, new Int32Array(a[0],a[1]+(n<<2))[0]];
  915. }
  916. else {
  917. var x = new Int32Array(a[0], a[1] + (n<<3));
  918. return [s, goog.math.Long.fromBits(x[0], x[1])];
  919. }
  920. };
  921. var $hs_readWordOffAddrzh = function (a, n, s) {
  922. if(WORD_SIZE_IN_BITS==32) {
  923. return [s, new Uint32Array(a[0],a[1]+(n<<2))[0]];
  924. }
  925. else {
  926. var x = new Int32Array(a[0], a[1] + (n<<3));
  927. return [s, goog.math.Long.fromBits(x[0], x[1])];
  928. }
  929. };
  930. var $hs_readAddrOffAddrzh = function (a, n, s) {
  931. var res = a[0].ptrs[a[1]+(n<<2)];
  932. if(HS_DEBUG && a[2] !== new Uint32Array(a[0],a[1]+(n<<2))[0])
  933. throw "Array Pointer Error";
  934. return [s, res];
  935. };
  936. var $hs_readFloatOffAddrzh = function (a, n, s) {
  937. return [s, new Float32Array(a[0],a[1]+(n<<2))[0]];
  938. };
  939. var $hs_readDoubleOffAddrzh = function (a, n, s) {
  940. return [s, new Float64Array(a[0],a[1]+(n<<3))[0]];
  941. };
  942. var $hs_readStablePtrOffAddrzh = function (a, n, s) {
  943. var res = a[0].ptrs[a[1]+(n<<2)];
  944. if(HS_DEBUG && a[2] !== new Uint32Array(a[0],a[1]+(n<<2))[0])
  945. throw "Array Pointer Error";
  946. return [s, res];
  947. };
  948. var $hs_readInt8OffAddrzh = function (a, n, s) {
  949. if(WORD_SIZE_IN_BITS==32) {
  950. return [s, new Int8Array(a[0],a[1]+n)[0]];
  951. }
  952. else {
  953. return [s, goog.math.Long.fromNumber(new Int32Array(a[0],a[1]+n)[0])];
  954. }
  955. };
  956. var $hs_readInt16OffAddrzh = function (a, n, s) {
  957. if(WORD_SIZE_IN_BITS==32) {
  958. return [s, new Int16Array(a[0],a[1]+(n<<1))[0]];
  959. }
  960. else {
  961. return [s, goog.math.Long.fromNumber(new Int16Array(a[0],a[1]+(n<<1))[0])];
  962. }
  963. };
  964. var $hs_readInt32OffAddrzh = function (a, n, s) {
  965. if(WORD_SIZE_IN_BITS==32) {
  966. return [s, new Int32Array(a[0],a[1]+(n<<2))[0]];
  967. }
  968. else {
  969. return [s, goog.math.Long.fromNumber(new Int32Array(a[0],a[1]+(n<<2))[0])];
  970. }
  971. };
  972. var $hs_readInt64OffAddrzh = function (a, n, s) {
  973. var x = new Uint32Array(a[0],a[1]+(n<<3));
  974. return [s, goog.math.Long.fromBits(x[0], x[1])];
  975. };
  976. var $hs_readWord8OffAddrzh = function (a, n, s) {
  977. if(typeof(a) === 'string')
  978. return [s, a.charCodeAt(n)];
  979. else
  980. return [s, new Uint8Array(a[0],a[1]+n)[0]];
  981. };
  982. var $hs_readWord16OffAddrzh = function (a, n, s) {
  983. if(WORD_SIZE_IN_BITS==32) {
  984. return [s, new Uint16Array(a[0],a[1]+(n<<1))[0]];
  985. }
  986. else {
  987. return [s, goog.math.Long.fromBits(new Uint16Array(a[0],a[1]+(n<<1))[0], 0)];
  988. }
  989. };
  990. var $hs_readWord32OffAddrzh = function (a, n, s) {
  991. if(WORD_SIZE_IN_BITS==32) {
  992. return [s, new Uint32Array(a[0],a[1]+(n<<2))[0]];
  993. }
  994. else {
  995. return [s, goog.math.Long.fromBits(new Uint32Array(a[0],a[1]+(n<<2))[0], 0)];
  996. }
  997. };
  998. var $hs_readWord64OffAddrzh = function (a, n, s) {
  999. var x = new Uint32Array(a[0],a[1]+(n<<3));
  1000. return [s, goog.math.Long.fromBits(x[0], x[1])];
  1001. };
  1002. var $hs_writeCharOffAddrzh = function (a, n, v, s) {
  1003. (new Uint8Array(a[0],a[1]+n))[0] = v.charCodeAt();
  1004. return s;
  1005. };
  1006. var $hs_writeWideCharOffAddrzh = function (a, n, v, s) {
  1007. (new Uint32Array(a[0],a[1]+(n<<2)))[0] = v.charCodeAt();
  1008. return s;
  1009. };
  1010. var $hs_writeIntOffAddrzh = function (a, n, v, s) {
  1011. if(WORD_SIZE_IN_BITS==32) {
  1012. (new Int32Array(a[0],a[1]+(n<<2)))[0] = v;
  1013. return s;
  1014. }
  1015. else {
  1016. var x = new Int32Array(a[0], a[1]+(n<<3));
  1017. x[0] = v.getLowBits();
  1018. x[1] = v.getHighBits();
  1019. return s;
  1020. }
  1021. };
  1022. var $hs_writeWordOffAddrzh = function (a, n, v, s) {
  1023. if(WORD_SIZE_IN_BITS==32) {
  1024. (new Uint32Array(a[0],a[1]+(n<<2)))[0] = v;
  1025. return s;
  1026. }
  1027. else {
  1028. var x = new Int32Array(a[0], a[1]+(n<<3));
  1029. x[0] = v.getLowBits();
  1030. x[1] = v.getHighBits();
  1031. return s;
  1032. }
  1033. };
  1034. var $hs_writeAddrOffAddrzh = function (a, n, v, s) {
  1035. a[0].ptrs[n] = v;
  1036. (new Uint32Array(a[0],a[1]+(n<<2)))[0] = a[2];
  1037. return s;
  1038. };
  1039. var $hs_writeFloatOffAddrzh = function (a, n, v, s) {
  1040. (new Float32Array(a[0],a[1]+(n<<2)))[0] = v;
  1041. return s;
  1042. };
  1043. var $hs_writeDoubleOffAddrzh = function (a, n, v, s) {
  1044. (new Float64Array(a[0],a[1]+(n<<3)))[0] = v;
  1045. return s;
  1046. };
  1047. var $hs_writeStablePtrOffAddrzh = function (a, n, v, s) {
  1048. a[0].ptrs[n] = v;
  1049. (new Uint32Array(a[0],a[1]+(n<<2)))[0] = a[2];
  1050. return s;
  1051. };
  1052. var $hs_writeInt8OffAddrzh = function (a, n, v, s) {
  1053. (new Int8Array(a[0],a[1]+n))[0] = WORD_SIZE_IN_BITS==32 ? v : v.getLowBits();
  1054. return s;
  1055. };
  1056. var $hs_writeInt16OffAddrzh = function (a, n, v, s) {
  1057. (new Int16Array(a[0],a[1]+(n<<1)))[0] = WORD_SIZE_IN_BITS==32 ? v : v.getLowBits();
  1058. return s;
  1059. };
  1060. var $hs_writeInt32OffAddrzh = function (a, n, v, s) {
  1061. (new Int32Array(a[0],a[1]+(n<<2)))[0] = WORD_SIZE_IN_BITS==32 ? v : v.getLowBits();
  1062. return s;
  1063. };
  1064. var $hs_writeInt64OffAddrzh = function (a, n, v, s) {
  1065. var x = new Int32Array(a[0], a[1]+(n<<3));
  1066. x[0] = v.getLowBits();
  1067. x[1] = v.getHighBits();
  1068. return s;
  1069. };
  1070. var $hs_writeWord8OffAddrzh = function (a, n, v, s) {
  1071. (new Uint8Array(a[0],a[1]+n))[0] = WORD_SIZE_IN_BITS==32 ? v : v.getLowBits();
  1072. return s;
  1073. };
  1074. var $hs_writeWord16OffAddrzh = function (a, n, v, s) {
  1075. (new Uint16Array(a[0],a[1]+(n<<1)))[0] = WORD_SIZE_IN_BITS==32 ? v : v.getLowBits();
  1076. return s;
  1077. };
  1078. var $hs_writeWord32OffAddrzh = function (a, n, v, s) {
  1079. (new Uint32Array(a[0],a[1]+(n<<2)))[0] = WORD_SIZE_IN_BITS==32 ? v : v.getLowBits();
  1080. return s;
  1081. };
  1082. var $hs_writeWord64OffAddrzh = function (a, n, v, s) {
  1083. var x = new Int32Array(a[0], a[1]+(n<<3));
  1084. x[0] = v.getLowBits();
  1085. x[1] = v.getHighBits();
  1086. return s;
  1087. };
  1088. var $hs_alert = function (str) {
  1089. window.alert(str);
  1090. };
  1091. var $hs_logAny = function (c, str) {
  1092. var el = document.getElementById('log');
  1093. el.innerHTML = el.innerHTML + c + ": " + str + '<br/>\n';
  1094. };
  1095. var $hs_logInfo = function (str) {
  1096. $hs_logAny("INFO", str);
  1097. };
  1098. var $hs_logError = function (str) {
  1099. $hs_logAny("ERROR", str);
  1100. };
  1101. var $hs_logDebug = function (str) {
  1102. $hs_logAny("DEBUG", str);
  1103. };
  1104. var $hs_logger = goog.debug.Logger.getLogger('hs');
  1105. var $hs_utf32 = function(s) {
  1106. var res = $hs_newByteArrayzh((s.length<<2)+4)[1];
  1107. var dest = new Uint32Array(res[0]);
  1108. for(var i=0;i!=s.length;i++)
  1109. dest[i]=s.charCodeAt(i);
  1110. dest[i]=0;
  1111. return res;
  1112. };
  1113. var $hs_fromUtf32 = function(s) {
  1114. var res = "";
  1115. var src = new Uint32Array(s[0],s[1]);
  1116. var len = src[src.length-1] === 0 ? src.length - 1 : src.length;
  1117. for(var i=0;i!=len;i++)
  1118. res=res+String.fromCharCode(src[i]);
  1119. return res;
  1120. };
  1121. var $hs_ascii = function(s) {
  1122. var res = $hs_newByteArrayzh(s.length+1)[1];
  1123. var dest = new Uint8Array(res[0]);
  1124. for(var i=0;i!=s.length;i++)
  1125. dest[i]=s.charCodeAt(i);
  1126. dest[i]=0;
  1127. return res;
  1128. };
  1129. var integer_cmm_cmpIntegerzh = function(sa, abits, sb, bbits) {
  1130. if(WORD_SIZE_IN_BITS==32) {
  1131. return $hs_gmpToGoog(sa, abits).compare($hs_gmpToGoog(sb, bbits));
  1132. }
  1133. else {
  1134. return goog.math.Long.fromNumber($hs_gmpToGoog(sa, abits).compare(
  1135. $hs_gmpToGoog(sb, bbits)));
  1136. }
  1137. };
  1138. var integer_cmm_cmpIntegerIntzh = function(sa, abits, b) {
  1139. if(WORD_SIZE_IN_BITS==32) {
  1140. return $hs_gmpToGoog(sa, abits).compare(goog.math.Integer.fromInt(b));
  1141. }
  1142. else {
  1143. return goog.math.Long.fromNumber($hs_gmpToGoog(sa, abits).compare(
  1144. goog.math.Integer.fromBits([b.getLowBits(), b.getHighBits()])));
  1145. }
  1146. };
  1147. var integer_cmm_plusIntegerzh = function(sa, abits, sb, bbits) {
  1148. return $hs_googToGMP($hs_gmpToGoog(sa, abits).add($hs_gmpToGoog(sb, bbits)));
  1149. };
  1150. var integer_cmm_minusIntegerzh = function(sa, abits, sb, bbits) {
  1151. return $hs_googToGMP($hs_gmpToGoog(sa, abits).subtract($hs_gmpToGoog(sb, bbits)));
  1152. };
  1153. var integer_cmm_timesIntegerzh = function(sa, abits, sb, bbits) {
  1154. return $hs_googToGMP($hs_gmpToGoog(sa, abits).multiply($hs_gmpToGoog(sb, bbits)));
  1155. };
  1156. var integer_cmm_quotRemIntegerzh = function(sa, abits, sb, bbits) {
  1157. var a = $hs_gmpToGoog(sa, abits);
  1158. var b = $hs_gmpToGoog(sb, bbits)
  1159. var q = a.divide(b);
  1160. var r = a.subtract(q.multiply(b));
  1161. return $hs_googToGMP(q).concat($hs_googToGMP(r));
  1162. };
  1163. var integer_cmm_quotIntegerzh = function(sa, abits, sb, bbits) {
  1164. return $hs_googToGMP($hs_gmpToGoog(sa, abits).divide($hs_gmpToGoog(sb, bbits)));
  1165. };
  1166. var integer_cmm_remIntegerzh = function(sa, abits, sb, bbits) {
  1167. return $hs_googToGMP($hs_gmpToGoog(sa, abits).modulo($hs_gmpToGoog(sb, bbits)));
  1168. };
  1169. var integer_cmm_divModIntegerzh = function(sa, abits, sb, bbits) {
  1170. var a = $hs_gmpToGoog(sa, abits);
  1171. var b = $hs_gmpToGoog(sb, bbits);
  1172. var d = a.divide(b);
  1173. var m = a.subtract(d.multiply(b));
  1174. if(a.isNegative()!==b.isNegative() && !m.isZero()) {
  1175. // Take one off d and add b onto m
  1176. d = d.add(goog.math.Integer.fromInt(-1));
  1177. m = m.add(b);
  1178. }
  1179. return $hs_googToGMP(d).concat($hs_googToGMP(m));
  1180. };
  1181. var integer_cmm_divExactIntegerzh = function(sa, abits, sb, bbits) {
  1182. return $hs_googToGMP($hs_gmpToGoog(sa, abits).divide($hs_gmpToGoog(sb, bbits)));
  1183. };
  1184. var $hs_gcd = function(a, b) {
  1185. var x = $hs_absolute(a);
  1186. var y = $hs_absolute(b);
  1187. var big, small;
  1188. if(x.lessThan(y)) {
  1189. small = x;
  1190. big = y;
  1191. }
  1192. else {
  1193. small = x;
  1194. big = y;
  1195. }
  1196. while(!small.isZero()) {
  1197. var q = big.divide(small);
  1198. var r = big.subtract(q.multiply(small));
  1199. big = small;
  1200. small = r;
  1201. }
  1202. return $hs_googToGMP(big);
  1203. };
  1204. var integer_cmm_gcdIntegerzh = function(sa, abits, sb, bbits) {
  1205. return $hs_gcd($hs_gmpToGoog(sa, abits), $hs_gmpToGoog(sb, bbits));
  1206. };
  1207. var integer_cmm_gcdIntegerIntzh = function(sa, abits, b) {
  1208. if(WORD_SIZE_IN_BITS==32) {
  1209. return $hs_gcd($hs_gmpToGoog(sa, abits), goog.math.Integer.fromInt(b));
  1210. }
  1211. else {
  1212. return $hs_gcd($hs_gmpToGoog(sa, abits),
  1213. goog.math.Integer.fromBits([b.getLowBits(), b.getHighBits()]));
  1214. }
  1215. };
  1216. var integer_cmm_gcdIntzh = function(a, b) {
  1217. if(WORD_SIZE_IN_BITS==32) {
  1218. var x = a<0 ? -a : a;
  1219. var y = b<0 ? -b : b;
  1220. var big, small;
  1221. if(x<y) {
  1222. small = x;
  1223. big = y;
  1224. }
  1225. else {
  1226. small = x;
  1227. big = y;
  1228. }
  1229. while(small!==0) {
  1230. var r = big % small;
  1231. big = small;
  1232. small = r;
  1233. }
  1234. return big;
  1235. }
  1236. else {
  1237. var x = a.isNegative() ? a.negate() : a;
  1238. var y = b.isNegative() ? b.negate() : b;
  1239. var big, small;
  1240. if(x.lessThan(y)) {
  1241. small = x;
  1242. big = y;
  1243. }
  1244. else {
  1245. small = x;
  1246. big = y;
  1247. }
  1248. while(!small.isZero()) {
  1249. var q = big.divide(small);
  1250. var r = big.subtract(q.multiply(small));
  1251. big = small;
  1252. small = r;
  1253. }
  1254. return big;
  1255. }
  1256. };
  1257. var integer_cmm_decodeDoublezh = function(x) {
  1258. if( x < 0 ) {
  1259. var result = integer_cmm_decodeDoublezh(-x);
  1260. return [result[0], -result[1], result[2]];
  1261. }
  1262. var negExponent = 52-Math.floor(Math.log(x) * 1.4426950408889634); // 1/log(2)
  1263. return [-negExponent].concat($hs_googToGMP(
  1264. goog.math.Integer.fromNumber(x * Math.pow(2, negExponent))));
  1265. };
  1266. var integer_cmm_int2Integerzh = function(i) {
  1267. if(WORD_SIZE_IN_BITS==32) {
  1268. return $hs_googToGMP(goog.math.Integer.fromInt(i));
  1269. }
  1270. else {
  1271. return $hs_googToGMP(
  1272. goog.math.Integer.fromBits([i.getLowBits(), i.getHighBits()]));
  1273. }
  1274. };
  1275. var integer_cmm_word2Integerzh = function(i) {
  1276. if(WORD_SIZE_IN_BITS==32) {
  1277. return $hs_googToGMP(goog.math.Integer.fromBits(i<0?[0,i]:[i]));
  1278. }
  1279. else {
  1280. return $hs_googToGMP(goog.math.Integer.fromBits(
  1281. i.isNegative()?[0, i.getLowBits(), i.getHighBits()]
  1282. :[ i.getLowBits(), i.getHighBits()]));
  1283. }
  1284. };
  1285. var integer_cmm_andIntegerzh = function(sa, abits, sb, bbits) {
  1286. return $hs_googToGMP($hs_gmpToGoog(sa, abits).and($hs_gmpToGoog(sb, bbits)));
  1287. };
  1288. var integer_cmm_orIntegerzh = function(sa, abits, sb, bbits) {
  1289. return $hs_googToGMP($hs_gmpToGoog(sa, abits).or($hs_gmpToGoog(sb, bbits)));
  1290. };
  1291. var integer_cmm_xorIntegerzh = function(sa, abits, sb, bbits) {
  1292. return $hs_googToGMP($hs_gmpToGoog(sa, abits).xor($hs_gmpToGoog(sb, bbits)));
  1293. };
  1294. var integer_cmm_mul2ExpIntegerzh = function(sa, abits, b) {
  1295. return $hs_googToGMP($hs_gmpToGoog(sa, abits).shiftLeft(b));
  1296. };
  1297. var integer_cmm_fdivQ2ExpIntegerzh = function(sa, abits, b) {
  1298. return $hs_googToGMP($hs_gmpToGoog(sa, abits).shiftRight(b));
  1299. };
  1300. var integer_cmm_complementIntegerzh = function(sa, abits) {
  1301. return $hs_googToGMP($hs_gmpToGoog(sa, abits).not());
  1302. };
  1303. var integer_cmm_int64ToIntegerzh = function(a) {
  1304. return $hs_googToGMP(goog.math.Integer.fromBits([a.getLowBits(), a.getHighBits()]));
  1305. };
  1306. var integer_cmm_word64ToIntegerzh = function(a) {
  1307. return $hs_googToGMP(goog.math.Integer.fromBits(
  1308. a.isNegative()?[0, a.getLowBits(), a.getHighBits()]
  1309. :[ a.getLowBits(), a.getHighBits()]));
  1310. };
  1311. var hs_integerToInt64 = function(as, abits) {
  1312. var a = $hs_gmpToGoog(as, abits);
  1313. return goog.math.Long.fromBits(a.getBits(0), a.getBits(1));
  1314. };
  1315. var hs_integerToWord64 = function(as, abits) {
  1316. var a = $hs_gmpToGoog(as, abits);
  1317. return goog.math.Long.fromBits(a.getBits(0), a.getBits(1));
  1318. };
  1319. /**
  1320. * @param {!Array.<Object>} dest
  1321. * @param {!number} doff
  1322. * @param {!Array.<Object>} src
  1323. * @param {!number} soff
  1324. * @param {!number} count
  1325. */
  1326. var _hs_text_memcpy = function (dest, doff, src, soff, count) {
  1327. var srcarray = new Uint16Array(src[0],src[1]);
  1328. var destarray = new Uint16Array(dest[0],dest[1]);
  1329. while(count != 0) {
  1330. destarray[doff] = srcarray[soff];
  1331. soff++;
  1332. doff++;
  1333. count--;
  1334. }
  1335. };
  1336. var _hs_text_memcmp = function(a, aoff, b, boff, count) {
  1337. var aarray = new Uint16Array(a[0],a[1]);
  1338. var barray = new Uint16Array(b[0],b[1]);
  1339. while(count != 0) {
  1340. if( aarray[aoff] < barray[boff] )
  1341. return -1;
  1342. if( aarray[aoff] > barray[boff] )
  1343. return 1;
  1344. aoff++;
  1345. boff++;
  1346. count--;
  1347. }
  1348. return 0;
  1349. };
  1350. /**
  1351. * @define {number} size of Word and Int. If 64 we use goog.math.Long.
  1352. */
  1353. var $hs_UTF8_ACCEPT = 0;
  1354. /**
  1355. * @define {number} size of Word and Int. If 64 we use goog.math.Long.
  1356. */
  1357. var $hs_UTF8_REJECT = 12
  1358. var $hs_utf8d =
  1359. [
  1360. /*
  1361. * The first part of the table maps bytes to character classes that
  1362. * to reduce the size of the transition table and create bitmasks.
  1363. */
  1364. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1365. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1366. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1367. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1368. 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
  1369. 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
  1370. 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  1371. 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
  1372. /*
  1373. * The second part is a transition table that maps a combination of
  1374. * a state of the automaton and a character class to a state.
  1375. */
  1376. 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
  1377. 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
  1378. 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
  1379. 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
  1380. 12,36,12,12,12,12,12,12,12,12,12,12];
  1381. var $hs_decode = function(state, cp, b) {
  1382. var type = $hs_utf8d[b];
  1383. var codep = (state != $hs_UTF8_ACCEPT) ?
  1384. (b & 0x3f) | (cp << 6) :
  1385. (0xff >>> type) & b;
  1386. return [$hs_utf8d[256 + state + type], codep];
  1387. };
  1388. /*
  1389. * A best-effort decoder. Runs until it hits either end of input or
  1390. * the start of an invalid byte sequence.
  1391. *
  1392. * At exit, updates *destoff with the next offset to write to, and
  1393. * returns the next source offset to read from.
  1394. */
  1395. var _hs_text_decode_utf8 = function(dest, doffptr, src, srcend)
  1396. {
  1397. // Assumes src[0] is srcend[0]
  1398. var srcarray = new Uint8Array(src[0],0);
  1399. var s = src[1];
  1400. var send = srcend[1];
  1401. var destarray = new Uint16Array(dest[0],dest[1]);
  1402. // Should really check the size of size_t and CSize here somehow
  1403. var doffArray = new Uint32Array(doffptr[0], doffptr[1]);
  1404. var doff = doffArray[0];
  1405. var state = $hs_UTF8_ACCEPT;
  1406. var codepoint = 0;
  1407. while (s != srcend) {
  1408. if ($hs_decode(state, codepoint, srcarray[s++]) != $hs_UTF8_ACCEPT) {
  1409. if (state != $hs_UTF8_REJECT)
  1410. continue;
  1411. break;
  1412. }
  1413. if ((codepoint >>> 0) <= 0xffff)
  1414. destarray[doff++] = codepoint;
  1415. else {
  1416. destarray[doff++] = 0xD7C0 + (codepoint >>> 10);
  1417. destarray[doff++] = 0xDC00 + (codepoint & 0x3FF);
  1418. }
  1419. }
  1420. /* Error recovery - if we're not in a valid finishing state, back up. */
  1421. if (state != $hs_UTF8_ACCEPT)
  1422. s -= 1;
  1423. doffArray[0] = doff;
  1424. return [src[0], s, src[2] + (s - src[1])];
  1425. };
  1426. var memcpy = function(dest, src, count) {
  1427. if(typeof(src) === 'string') {
  1428. var destarray = new Uint8Array(dest[0],dest[1]);
  1429. var soff = 0;
  1430. var doff = 0;
  1431. while(count != 0) {
  1432. destarray[doff] = src[soff];
  1433. soff++;
  1434. doff++;
  1435. count--;
  1436. }
  1437. return dest;
  1438. }
  1439. else {
  1440. var destarray = new Uint8Array(dest[0],dest[1]);
  1441. var srcarray = new Uint8Array(src[0],src[1]);
  1442. var doff = 0;
  1443. var soff = 0;
  1444. while(count != 0) {
  1445. destarray[doff] = srcarray[soff];
  1446. soff++;
  1447. doff++;
  1448. count--;
  1449. }
  1450. return dest;
  1451. }
  1452. };
  1453. var memcmp = function(a, b, count) {
  1454. if(typeof(a) === 'string') {
  1455. if(typeof(b) === 'string') {
  1456. var x = a.slice(0,count).localeCompare(b.slice(0,count));
  1457. return x === 0 ? 0 : (x < 0 ? -1 : 1);
  1458. }
  1459. var barray = new Uint8Array(b[0],b[1]);
  1460. var aoff = 0;
  1461. var boff = 0;
  1462. while(count != 0) {
  1463. if( a[aoff] < barray[boff] )
  1464. return -1;
  1465. if( a[aoff] > barray[boff] )
  1466. return 1;
  1467. aoff++;
  1468. boff++;
  1469. count--;
  1470. }
  1471. return 0;
  1472. }
  1473. else {
  1474. if(typeof(b) === 'string') {
  1475. var aarray = new Uint8Array(a[0],a[1]);
  1476. var aoff = 0;
  1477. var boff = 0;
  1478. while(count != 0) {
  1479. if( aarray[aoff] < b[boff] )
  1480. return -1;
  1481. if( aarray[aoff] > b[boff] )
  1482. return 1;
  1483. aoff++;
  1484. boff++;
  1485. count--;
  1486. }
  1487. return 0;
  1488. }
  1489. var aarray = new Uint8Array(a[0],a[1]);
  1490. var barray = new Uint8Array(b[0],b[1]);
  1491. var aoff = 0;
  1492. var boff = 0;
  1493. while(count != 0) {
  1494. if( aarray[aoff] < barray[boff] )
  1495. return -1;
  1496. if( aarray[aoff] > barray[boff] )
  1497. return 1;
  1498. aoff++;
  1499. boff++;
  1500. count--;
  1501. }
  1502. return 0;
  1503. }
  1504. };
  1505. var u_iswalpha = function(a) {
  1506. return goog.string.isAlpha(String.fromCharCode(a)) ?
  1507. (WORD_SIZE_IN_BITS == 32 ? 1 : goog.math.Long.ONE)
  1508. :(WORD_SIZE_IN_BITS == 32 ? 0 : goog.math.Long.ZERO);
  1509. };
  1510. var u_iswalnum = function(a) {
  1511. return goog.string.isAlphaNumeric(String.fromCharCode(a)) ?
  1512. (WORD_SIZE_IN_BITS == 32 ? 1 : goog.math.Long.ONE)
  1513. :(WORD_SIZE_IN_BITS == 32 ? 0 : goog.math.Long.ZERO);
  1514. };
  1515. var u_iswspace = function(a) {
  1516. return goog.string.isSpace(String.fromCharCode(a)) ?
  1517. (WORD_SIZE_IN_BITS == 32 ? 1 : goog.math.Long.ONE)
  1518. :(WORD_SIZE_IN_BITS == 32 ? 0 : goog.math.Long.ZERO);
  1519. };
  1520. var u_iswlower = function(a) {
  1521. return a === u_towupper(a) ?
  1522. (WORD_SIZE_IN_BITS == 32 ? 1 : goog.math.Long.ONE)
  1523. :(WORD_SIZE_IN_BITS == 32 ? 0 : goog.math.Long.ZERO);
  1524. };
  1525. var u_iswupper = function(a) {
  1526. return a === u_towlower(a) ?
  1527. (WORD_SIZE_IN_BITS == 32 ? 1 : goog.math.Long.ONE)
  1528. :(WORD_SIZE_IN_BITS == 32 ? 0 : goog.math.Long.ZERO);
  1529. };
  1530. var u_towlower = function(a) { return String.fromCharCode(a).toLowerCase().charCodeAt(); };
  1531. var u_towupper = function(a) { return String.fromCharCode(a).toUpperCase().charCodeAt(); };
  1532. var rtsSupportsBoundThreads = function () { return 0; };
  1533. var getOrSetGHCConcSignalSignalHandlerStore = function (x) { return x; };
  1534. var stg_sig_install = function(a,b,c) { return -1; };
  1535. var localeEncoding = function() { return $hs_ascii("UTF-32LE"); };
  1536. var hs_iconv_open = function(to,from) { return 1; };
  1537. var hs_iconv_close = function(h) { return 0; };
  1538. var $hs_unsignedCompare = function(a,b) {
  1539. if (a.equals(b)) return 0;
  1540. var aneg = a.isNegative();
  1541. var bneg = b.isNegative();
  1542. if (aneg && !bneg) return 1;
  1543. if (!aneg && bneg) return -1;
  1544. return a.subtract(b).isNegative() ? -1 : 1;
  1545. };
  1546. if(WORD_SIZE_IN_BITS == 32) {
  1547. // Safer 32 bit multiplication than just a * b
  1548. var $hs_timesIntzh = function(a, b) {
  1549. return goog.math.Long(a,0).multiply(goog.math.Long(b,0)).getLowBits(); };
  1550. }
  1551. if(WORD_SIZE_IN_BITS == 64) {
  1552. // Int primatives for 64bit
  1553. var $hs_quotIntzh = function(a, b) {
  1554. return a.div(b); };
  1555. var $hs_remIntzh = function(a, b) {
  1556. return a.modulo(b); };
  1557. var $hs_int2Wordzh = function(a) {
  1558. return a; };
  1559. var $hs_int2Floatzh = function(a) {
  1560. return a.toNumber(); };
  1561. var $hs_int2Doublezh = function(a) {
  1562. return a.toNumber(); };
  1563. var $hs_uncheckedIShiftLzh = function(a, b) {
  1564. return a.shiftLeft(b.toNumber()); };
  1565. var $hs_uncheckedIShiftRAzh = function(a, b) {
  1566. return a.shiftRight(b.toNumber()); };
  1567. var $hs_uncheckedIShiftRLzh = function(a, b) {
  1568. return a.shiftRight(b.toNumber()); };
  1569. // Word primatives for 64bit
  1570. var $hs_quotWordzh = function(a, b) {
  1571. return a.div(b); }; // TODO make unsigned
  1572. var $hs_remWordzh = function(a, b) {
  1573. return a.modulo(b); }; // TODO make unsigned
  1574. var $hs_uncheckedShiftLzh = function(a, b) {
  1575. return a.shiftLeft(b.toNumber()); };
  1576. var $hs_uncheckedShif

Large files files are truncated, but you can click here to view the full file