1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | var Module = typeof Module !== 'undefined' ? Module : {};
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | var moduleOverrides = {};
|
31 | var key;
|
32 | for (key in Module) {
|
33 | if (Module.hasOwnProperty(key)) {
|
34 | moduleOverrides[key] = Module[key];
|
35 | }
|
36 | }
|
37 |
|
38 | Module['arguments'] = [];
|
39 | Module['thisProgram'] = './this.program';
|
40 | Module['quit'] = function(status, toThrow) {
|
41 | throw toThrow;
|
42 | };
|
43 | Module['preRun'] = [];
|
44 | Module['postRun'] = [];
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | var ENVIRONMENT_IS_WEB = false;
|
50 | var ENVIRONMENT_IS_WORKER = false;
|
51 | var ENVIRONMENT_IS_NODE = false;
|
52 | var ENVIRONMENT_IS_SHELL = false;
|
53 | ENVIRONMENT_IS_WEB = typeof window === 'object';
|
54 | ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
|
55 | ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function' && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER;
|
56 | ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
57 |
|
58 | if (Module['ENVIRONMENT']) {
|
59 | throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)');
|
60 | }
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | var scriptDirectory = '';
|
69 | function locateFile(path) {
|
70 | if (Module['locateFile']) {
|
71 | return Module['locateFile'](path, scriptDirectory);
|
72 | } else {
|
73 | return scriptDirectory + path;
|
74 | }
|
75 | }
|
76 |
|
77 | if (ENVIRONMENT_IS_NODE) {
|
78 | scriptDirectory = __dirname + '/';
|
79 |
|
80 |
|
81 |
|
82 | var nodeFS;
|
83 | var nodePath;
|
84 |
|
85 | Module['read'] = function shell_read(filename, binary) {
|
86 | var ret;
|
87 | if (!nodeFS) nodeFS = require('fs');
|
88 | if (!nodePath) nodePath = require('path');
|
89 | filename = nodePath['normalize'](filename);
|
90 | ret = nodeFS['readFileSync'](filename);
|
91 | return binary ? ret : ret.toString();
|
92 | };
|
93 |
|
94 | Module['readBinary'] = function readBinary(filename) {
|
95 | var ret = Module['read'](filename, true);
|
96 | if (!ret.buffer) {
|
97 | ret = new Uint8Array(ret);
|
98 | }
|
99 | assert(ret.buffer);
|
100 | return ret;
|
101 | };
|
102 |
|
103 | if (process['argv'].length > 1) {
|
104 | Module['thisProgram'] = process['argv'][1].replace(/\\/g, '/');
|
105 | }
|
106 |
|
107 | Module['arguments'] = process['argv'].slice(2);
|
108 |
|
109 | if (typeof module !== 'undefined') {
|
110 | module['exports'] = Module;
|
111 | }
|
112 |
|
113 | process['on']('uncaughtException', function(ex) {
|
114 |
|
115 | if (!(ex instanceof ExitStatus)) {
|
116 | throw ex;
|
117 | }
|
118 | });
|
119 |
|
120 |
|
121 | process['on']('unhandledRejection', abort);
|
122 |
|
123 | Module['quit'] = function(status) {
|
124 | process['exit'](status);
|
125 | };
|
126 |
|
127 | Module['inspect'] = function () { return '[Emscripten Module object]'; };
|
128 | } else
|
129 | if (ENVIRONMENT_IS_SHELL) {
|
130 |
|
131 |
|
132 | if (typeof read != 'undefined') {
|
133 | Module['read'] = function shell_read(f) {
|
134 | return read(f);
|
135 | };
|
136 | }
|
137 |
|
138 | Module['readBinary'] = function readBinary(f) {
|
139 | var data;
|
140 | if (typeof readbuffer === 'function') {
|
141 | return new Uint8Array(readbuffer(f));
|
142 | }
|
143 | data = read(f, 'binary');
|
144 | assert(typeof data === 'object');
|
145 | return data;
|
146 | };
|
147 |
|
148 | if (typeof scriptArgs != 'undefined') {
|
149 | Module['arguments'] = scriptArgs;
|
150 | } else if (typeof arguments != 'undefined') {
|
151 | Module['arguments'] = arguments;
|
152 | }
|
153 |
|
154 | if (typeof quit === 'function') {
|
155 | Module['quit'] = function(status) {
|
156 | quit(status);
|
157 | }
|
158 | }
|
159 | } else
|
160 | if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
161 | if (ENVIRONMENT_IS_WORKER) {
|
162 | scriptDirectory = self.location.href;
|
163 | } else if (document.currentScript) {
|
164 | scriptDirectory = document.currentScript.src;
|
165 | }
|
166 |
|
167 |
|
168 |
|
169 |
|
170 | if (scriptDirectory.indexOf('blob:') !== 0) {
|
171 | scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf('/')+1);
|
172 | } else {
|
173 | scriptDirectory = '';
|
174 | }
|
175 |
|
176 |
|
177 | Module['read'] = function shell_read(url) {
|
178 | var xhr = new XMLHttpRequest();
|
179 | xhr.open('GET', url, false);
|
180 | xhr.send(null);
|
181 | return xhr.responseText;
|
182 | };
|
183 |
|
184 | if (ENVIRONMENT_IS_WORKER) {
|
185 | Module['readBinary'] = function readBinary(url) {
|
186 | var xhr = new XMLHttpRequest();
|
187 | xhr.open('GET', url, false);
|
188 | xhr.responseType = 'arraybuffer';
|
189 | xhr.send(null);
|
190 | return new Uint8Array(xhr.response);
|
191 | };
|
192 | }
|
193 |
|
194 | Module['readAsync'] = function readAsync(url, onload, onerror) {
|
195 | var xhr = new XMLHttpRequest();
|
196 | xhr.open('GET', url, true);
|
197 | xhr.responseType = 'arraybuffer';
|
198 | xhr.onload = function xhr_onload() {
|
199 | if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
|
200 | onload(xhr.response);
|
201 | return;
|
202 | }
|
203 | onerror();
|
204 | };
|
205 | xhr.onerror = onerror;
|
206 | xhr.send(null);
|
207 | };
|
208 |
|
209 | Module['setWindowTitle'] = function(title) { document.title = title };
|
210 | } else
|
211 | {
|
212 | throw new Error('environment detection error');
|
213 | }
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 | var out = Module['print'] || (typeof console !== 'undefined' ? console.log.bind(console) : (typeof print !== 'undefined' ? print : null));
|
222 | var err = Module['printErr'] || (typeof printErr !== 'undefined' ? printErr : ((typeof console !== 'undefined' && console.warn.bind(console)) || out));
|
223 |
|
224 |
|
225 | for (key in moduleOverrides) {
|
226 | if (moduleOverrides.hasOwnProperty(key)) {
|
227 | Module[key] = moduleOverrides[key];
|
228 | }
|
229 | }
|
230 |
|
231 |
|
232 | moduleOverrides = undefined;
|
233 |
|
234 |
|
235 | assert(typeof Module['memoryInitializerPrefixURL'] === 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
|
236 | assert(typeof Module['pthreadMainPrefixURL'] === 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
|
237 | assert(typeof Module['cdInitializerPrefixURL'] === 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
|
238 | assert(typeof Module['filePackagePrefixURL'] === 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 | var STACK_ALIGN = 16;
|
250 |
|
251 |
|
252 |
|
253 | stackSave = stackRestore = stackAlloc = setTempRet0 = getTempRet0 = function() {
|
254 | abort('cannot use the stack before compiled code is ready to run, and has provided stack access');
|
255 | };
|
256 |
|
257 | function staticAlloc(size) {
|
258 | assert(!staticSealed);
|
259 | var ret = STATICTOP;
|
260 | STATICTOP = (STATICTOP + size + 15) & -16;
|
261 | assert(STATICTOP < TOTAL_MEMORY, 'not enough memory for static allocation - increase TOTAL_MEMORY');
|
262 | return ret;
|
263 | }
|
264 |
|
265 | function dynamicAlloc(size) {
|
266 | assert(DYNAMICTOP_PTR);
|
267 | var ret = HEAP32[DYNAMICTOP_PTR>>2];
|
268 | var end = (ret + size + 15) & -16;
|
269 | HEAP32[DYNAMICTOP_PTR>>2] = end;
|
270 | if (end >= TOTAL_MEMORY) {
|
271 | var success = enlargeMemory();
|
272 | if (!success) {
|
273 | HEAP32[DYNAMICTOP_PTR>>2] = ret;
|
274 | return 0;
|
275 | }
|
276 | }
|
277 | return ret;
|
278 | }
|
279 |
|
280 | function alignMemory(size, factor) {
|
281 | if (!factor) factor = STACK_ALIGN;
|
282 | var ret = size = Math.ceil(size / factor) * factor;
|
283 | return ret;
|
284 | }
|
285 |
|
286 | function getNativeTypeSize(type) {
|
287 | switch (type) {
|
288 | case 'i1': case 'i8': return 1;
|
289 | case 'i16': return 2;
|
290 | case 'i32': return 4;
|
291 | case 'i64': return 8;
|
292 | case 'float': return 4;
|
293 | case 'double': return 8;
|
294 | default: {
|
295 | if (type[type.length-1] === '*') {
|
296 | return 4;
|
297 | } else if (type[0] === 'i') {
|
298 | var bits = parseInt(type.substr(1));
|
299 | assert(bits % 8 === 0);
|
300 | return bits / 8;
|
301 | } else {
|
302 | return 0;
|
303 | }
|
304 | }
|
305 | }
|
306 | }
|
307 |
|
308 | function warnOnce(text) {
|
309 | if (!warnOnce.shown) warnOnce.shown = {};
|
310 | if (!warnOnce.shown[text]) {
|
311 | warnOnce.shown[text] = 1;
|
312 | err(text);
|
313 | }
|
314 | }
|
315 |
|
316 | var asm2wasmImports = {
|
317 | "f64-rem": function(x, y) {
|
318 | return x % y;
|
319 | },
|
320 | "debugger": function() {
|
321 | debugger;
|
322 | }
|
323 | };
|
324 |
|
325 |
|
326 |
|
327 | var jsCallStartIndex = 1;
|
328 | var functionPointers = new Array(0);
|
329 |
|
330 |
|
331 | function addFunction(func, sig) {
|
332 | if (typeof sig === 'undefined') {
|
333 | err('warning: addFunction(): You should provide a wasm function signature string as a second argument. This is not necessary for asm.js and asm2wasm, but is required for the LLVM wasm backend, so it is recommended for full portability.');
|
334 | }
|
335 | var base = 0;
|
336 | for (var i = base; i < base + 0; i++) {
|
337 | if (!functionPointers[i]) {
|
338 | functionPointers[i] = func;
|
339 | return jsCallStartIndex + i;
|
340 | }
|
341 | }
|
342 | throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
|
343 | }
|
344 |
|
345 | function removeFunction(index) {
|
346 | functionPointers[index-jsCallStartIndex] = null;
|
347 | }
|
348 |
|
349 | var funcWrappers = {};
|
350 |
|
351 | function getFuncWrapper(func, sig) {
|
352 | if (!func) return;
|
353 | assert(sig);
|
354 | if (!funcWrappers[sig]) {
|
355 | funcWrappers[sig] = {};
|
356 | }
|
357 | var sigCache = funcWrappers[sig];
|
358 | if (!sigCache[func]) {
|
359 |
|
360 | if (sig.length === 1) {
|
361 | sigCache[func] = function dynCall_wrapper() {
|
362 | return dynCall(sig, func);
|
363 | };
|
364 | } else if (sig.length === 2) {
|
365 | sigCache[func] = function dynCall_wrapper(arg) {
|
366 | return dynCall(sig, func, [arg]);
|
367 | };
|
368 | } else {
|
369 |
|
370 | sigCache[func] = function dynCall_wrapper() {
|
371 | return dynCall(sig, func, Array.prototype.slice.call(arguments));
|
372 | };
|
373 | }
|
374 | }
|
375 | return sigCache[func];
|
376 | }
|
377 |
|
378 |
|
379 | function makeBigInt(low, high, unsigned) {
|
380 | return unsigned ? ((+((low>>>0)))+((+((high>>>0)))*4294967296.0)) : ((+((low>>>0)))+((+((high|0)))*4294967296.0));
|
381 | }
|
382 |
|
383 | function dynCall(sig, ptr, args) {
|
384 | if (args && args.length) {
|
385 | assert(args.length == sig.length-1);
|
386 | assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\'');
|
387 | return Module['dynCall_' + sig].apply(null, [ptr].concat(args));
|
388 | } else {
|
389 | assert(sig.length == 1);
|
390 | assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\'');
|
391 | return Module['dynCall_' + sig].call(null, ptr);
|
392 | }
|
393 | }
|
394 |
|
395 |
|
396 | function getCompilerSetting(name) {
|
397 | throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for getCompilerSetting or emscripten_get_compiler_setting to work';
|
398 | }
|
399 |
|
400 | var Runtime = {
|
401 |
|
402 |
|
403 |
|
404 | dynCall: dynCall,
|
405 |
|
406 | getTempRet0: function() { abort('getTempRet0() is now a top-level function, after removing the Runtime object. Remove "Runtime."') },
|
407 | staticAlloc: function() { abort('staticAlloc() is now a top-level function, after removing the Runtime object. Remove "Runtime."') },
|
408 | stackAlloc: function() { abort('stackAlloc() is now a top-level function, after removing the Runtime object. Remove "Runtime."') },
|
409 | };
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 | var GLOBAL_BASE = 1024;
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 | var ABORT = false;
|
437 |
|
438 |
|
439 |
|
440 |
|
441 | var EXITSTATUS = 0;
|
442 |
|
443 |
|
444 | function assert(condition, text) {
|
445 | if (!condition) {
|
446 | abort('Assertion failed: ' + text);
|
447 | }
|
448 | }
|
449 |
|
450 | var globalScope = this;
|
451 |
|
452 |
|
453 | function getCFunc(ident) {
|
454 | var func = Module['_' + ident];
|
455 | assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
|
456 | return func;
|
457 | }
|
458 |
|
459 | var JSfuncs = {
|
460 |
|
461 |
|
462 |
|
463 | 'stackSave': function() {
|
464 | stackSave()
|
465 | },
|
466 | 'stackRestore': function() {
|
467 | stackRestore()
|
468 | },
|
469 |
|
470 | 'arrayToC' : function(arr) {
|
471 | var ret = stackAlloc(arr.length);
|
472 | writeArrayToMemory(arr, ret);
|
473 | return ret;
|
474 | },
|
475 | 'stringToC' : function(str) {
|
476 | var ret = 0;
|
477 | if (str !== null && str !== undefined && str !== 0) {
|
478 |
|
479 | var len = (str.length << 2) + 1;
|
480 | ret = stackAlloc(len);
|
481 | stringToUTF8(str, ret, len);
|
482 | }
|
483 | return ret;
|
484 | }
|
485 | };
|
486 |
|
487 |
|
488 | var toC = {
|
489 | 'string': JSfuncs['stringToC'], 'array': JSfuncs['arrayToC']
|
490 | };
|
491 |
|
492 |
|
493 |
|
494 | function ccall(ident, returnType, argTypes, args, opts) {
|
495 | function convertReturnValue(ret) {
|
496 | if (returnType === 'string') return Pointer_stringify(ret);
|
497 | if (returnType === 'boolean') return Boolean(ret);
|
498 | return ret;
|
499 | }
|
500 |
|
501 | var func = getCFunc(ident);
|
502 | var cArgs = [];
|
503 | var stack = 0;
|
504 | assert(returnType !== 'array', 'Return type should not be "array".');
|
505 | if (args) {
|
506 | for (var i = 0; i < args.length; i++) {
|
507 | var converter = toC[argTypes[i]];
|
508 | if (converter) {
|
509 | if (stack === 0) stack = stackSave();
|
510 | cArgs[i] = converter(args[i]);
|
511 | } else {
|
512 | cArgs[i] = args[i];
|
513 | }
|
514 | }
|
515 | }
|
516 | var ret = func.apply(null, cArgs);
|
517 | ret = convertReturnValue(ret);
|
518 | if (stack !== 0) stackRestore(stack);
|
519 | return ret;
|
520 | }
|
521 |
|
522 | function cwrap(ident, returnType, argTypes, opts) {
|
523 | return function() {
|
524 | return ccall(ident, returnType, argTypes, arguments, opts);
|
525 | }
|
526 | }
|
527 |
|
528 |
|
529 | function setValue(ptr, value, type, noSafe) {
|
530 | type = type || 'i8';
|
531 | if (type.charAt(type.length-1) === '*') type = 'i32';
|
532 | switch(type) {
|
533 | case 'i1': HEAP8[((ptr)>>0)]=value; break;
|
534 | case 'i8': HEAP8[((ptr)>>0)]=value; break;
|
535 | case 'i16': HEAP16[((ptr)>>1)]=value; break;
|
536 | case 'i32': HEAP32[((ptr)>>2)]=value; break;
|
537 | case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math_min((+(Math_floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
|
538 | case 'float': HEAPF32[((ptr)>>2)]=value; break;
|
539 | case 'double': HEAPF64[((ptr)>>3)]=value; break;
|
540 | default: abort('invalid type for setValue: ' + type);
|
541 | }
|
542 | }
|
543 |
|
544 |
|
545 | function getValue(ptr, type, noSafe) {
|
546 | type = type || 'i8';
|
547 | if (type.charAt(type.length-1) === '*') type = 'i32';
|
548 | switch(type) {
|
549 | case 'i1': return HEAP8[((ptr)>>0)];
|
550 | case 'i8': return HEAP8[((ptr)>>0)];
|
551 | case 'i16': return HEAP16[((ptr)>>1)];
|
552 | case 'i32': return HEAP32[((ptr)>>2)];
|
553 | case 'i64': return HEAP32[((ptr)>>2)];
|
554 | case 'float': return HEAPF32[((ptr)>>2)];
|
555 | case 'double': return HEAPF64[((ptr)>>3)];
|
556 | default: abort('invalid type for getValue: ' + type);
|
557 | }
|
558 | return null;
|
559 | }
|
560 |
|
561 | var ALLOC_NORMAL = 0;
|
562 | var ALLOC_STACK = 1;
|
563 | var ALLOC_STATIC = 2;
|
564 | var ALLOC_DYNAMIC = 3;
|
565 | var ALLOC_NONE = 4;
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 | function allocate(slab, types, allocator, ptr) {
|
582 | var zeroinit, size;
|
583 | if (typeof slab === 'number') {
|
584 | zeroinit = true;
|
585 | size = slab;
|
586 | } else {
|
587 | zeroinit = false;
|
588 | size = slab.length;
|
589 | }
|
590 |
|
591 | var singleType = typeof types === 'string' ? types : null;
|
592 |
|
593 | var ret;
|
594 | if (allocator == ALLOC_NONE) {
|
595 | ret = ptr;
|
596 | } else {
|
597 | ret = [typeof _malloc === 'function' ? _malloc : staticAlloc, stackAlloc, staticAlloc, dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
|
598 | }
|
599 |
|
600 | if (zeroinit) {
|
601 | var stop;
|
602 | ptr = ret;
|
603 | assert((ret & 3) == 0);
|
604 | stop = ret + (size & ~3);
|
605 | for (; ptr < stop; ptr += 4) {
|
606 | HEAP32[((ptr)>>2)]=0;
|
607 | }
|
608 | stop = ret + size;
|
609 | while (ptr < stop) {
|
610 | HEAP8[((ptr++)>>0)]=0;
|
611 | }
|
612 | return ret;
|
613 | }
|
614 |
|
615 | if (singleType === 'i8') {
|
616 | if (slab.subarray || slab.slice) {
|
617 | HEAPU8.set( (slab), ret);
|
618 | } else {
|
619 | HEAPU8.set(new Uint8Array(slab), ret);
|
620 | }
|
621 | return ret;
|
622 | }
|
623 |
|
624 | var i = 0, type, typeSize, previousType;
|
625 | while (i < size) {
|
626 | var curr = slab[i];
|
627 |
|
628 | type = singleType || types[i];
|
629 | if (type === 0) {
|
630 | i++;
|
631 | continue;
|
632 | }
|
633 | assert(type, 'Must know what type to store in allocate!');
|
634 |
|
635 | if (type == 'i64') type = 'i32';
|
636 |
|
637 | setValue(ret+i, curr, type);
|
638 |
|
639 |
|
640 | if (previousType !== type) {
|
641 | typeSize = getNativeTypeSize(type);
|
642 | previousType = type;
|
643 | }
|
644 | i += typeSize;
|
645 | }
|
646 |
|
647 | return ret;
|
648 | }
|
649 |
|
650 |
|
651 | function getMemory(size) {
|
652 | if (!staticSealed) return staticAlloc(size);
|
653 | if (!runtimeInitialized) return dynamicAlloc(size);
|
654 | return _malloc(size);
|
655 | }
|
656 |
|
657 |
|
658 | function Pointer_stringify(ptr, length) {
|
659 | if (length === 0 || !ptr) return '';
|
660 |
|
661 | var hasUtf = 0;
|
662 | var t;
|
663 | var i = 0;
|
664 | while (1) {
|
665 | assert(ptr + i < TOTAL_MEMORY);
|
666 | t = HEAPU8[(((ptr)+(i))>>0)];
|
667 | hasUtf |= t;
|
668 | if (t == 0 && !length) break;
|
669 | i++;
|
670 | if (length && i == length) break;
|
671 | }
|
672 | if (!length) length = i;
|
673 |
|
674 | var ret = '';
|
675 |
|
676 | if (hasUtf < 128) {
|
677 | var MAX_CHUNK = 1024;
|
678 | var curr;
|
679 | while (length > 0) {
|
680 | curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
|
681 | ret = ret ? ret + curr : curr;
|
682 | ptr += MAX_CHUNK;
|
683 | length -= MAX_CHUNK;
|
684 | }
|
685 | return ret;
|
686 | }
|
687 | return UTF8ToString(ptr);
|
688 | }
|
689 |
|
690 |
|
691 |
|
692 |
|
693 | function AsciiToString(ptr) {
|
694 | var str = '';
|
695 | while (1) {
|
696 | var ch = HEAP8[((ptr++)>>0)];
|
697 | if (!ch) return str;
|
698 | str += String.fromCharCode(ch);
|
699 | }
|
700 | }
|
701 |
|
702 |
|
703 |
|
704 |
|
705 | function stringToAscii(str, outPtr) {
|
706 | return writeAsciiToMemory(str, outPtr, false);
|
707 | }
|
708 |
|
709 |
|
710 |
|
711 |
|
712 | var UTF8Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
|
713 | function UTF8ArrayToString(u8Array, idx) {
|
714 | var endPtr = idx;
|
715 |
|
716 |
|
717 | while (u8Array[endPtr]) ++endPtr;
|
718 |
|
719 | if (endPtr - idx > 16 && u8Array.subarray && UTF8Decoder) {
|
720 | return UTF8Decoder.decode(u8Array.subarray(idx, endPtr));
|
721 | } else {
|
722 | var u0, u1, u2, u3, u4, u5;
|
723 |
|
724 | var str = '';
|
725 | while (1) {
|
726 |
|
727 |
|
728 |
|
729 |
|
730 | u0 = u8Array[idx++];
|
731 | if (!u0) return str;
|
732 | if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
|
733 | u1 = u8Array[idx++] & 63;
|
734 | if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
|
735 | u2 = u8Array[idx++] & 63;
|
736 | if ((u0 & 0xF0) == 0xE0) {
|
737 | u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
738 | } else {
|
739 | u3 = u8Array[idx++] & 63;
|
740 | if ((u0 & 0xF8) == 0xF0) {
|
741 | u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | u3;
|
742 | } else {
|
743 | u4 = u8Array[idx++] & 63;
|
744 | if ((u0 & 0xFC) == 0xF8) {
|
745 | u0 = ((u0 & 3) << 24) | (u1 << 18) | (u2 << 12) | (u3 << 6) | u4;
|
746 | } else {
|
747 | u5 = u8Array[idx++] & 63;
|
748 | u0 = ((u0 & 1) << 30) | (u1 << 24) | (u2 << 18) | (u3 << 12) | (u4 << 6) | u5;
|
749 | }
|
750 | }
|
751 | }
|
752 | if (u0 < 0x10000) {
|
753 | str += String.fromCharCode(u0);
|
754 | } else {
|
755 | var ch = u0 - 0x10000;
|
756 | str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
757 | }
|
758 | }
|
759 | }
|
760 | }
|
761 |
|
762 |
|
763 |
|
764 |
|
765 | function UTF8ToString(ptr) {
|
766 | return UTF8ArrayToString(HEAPU8,ptr);
|
767 | }
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 | function stringToUTF8Array(str, outU8Array, outIdx, maxBytesToWrite) {
|
783 | if (!(maxBytesToWrite > 0))
|
784 | return 0;
|
785 |
|
786 | var startIdx = outIdx;
|
787 | var endIdx = outIdx + maxBytesToWrite - 1;
|
788 | for (var i = 0; i < str.length; ++i) {
|
789 |
|
790 |
|
791 |
|
792 | var u = str.charCodeAt(i);
|
793 | if (u >= 0xD800 && u <= 0xDFFF) {
|
794 | var u1 = str.charCodeAt(++i);
|
795 | u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
|
796 | }
|
797 | if (u <= 0x7F) {
|
798 | if (outIdx >= endIdx) break;
|
799 | outU8Array[outIdx++] = u;
|
800 | } else if (u <= 0x7FF) {
|
801 | if (outIdx + 1 >= endIdx) break;
|
802 | outU8Array[outIdx++] = 0xC0 | (u >> 6);
|
803 | outU8Array[outIdx++] = 0x80 | (u & 63);
|
804 | } else if (u <= 0xFFFF) {
|
805 | if (outIdx + 2 >= endIdx) break;
|
806 | outU8Array[outIdx++] = 0xE0 | (u >> 12);
|
807 | outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
|
808 | outU8Array[outIdx++] = 0x80 | (u & 63);
|
809 | } else if (u <= 0x1FFFFF) {
|
810 | if (outIdx + 3 >= endIdx) break;
|
811 | outU8Array[outIdx++] = 0xF0 | (u >> 18);
|
812 | outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63);
|
813 | outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
|
814 | outU8Array[outIdx++] = 0x80 | (u & 63);
|
815 | } else if (u <= 0x3FFFFFF) {
|
816 | if (outIdx + 4 >= endIdx) break;
|
817 | outU8Array[outIdx++] = 0xF8 | (u >> 24);
|
818 | outU8Array[outIdx++] = 0x80 | ((u >> 18) & 63);
|
819 | outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63);
|
820 | outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
|
821 | outU8Array[outIdx++] = 0x80 | (u & 63);
|
822 | } else {
|
823 | if (outIdx + 5 >= endIdx) break;
|
824 | outU8Array[outIdx++] = 0xFC | (u >> 30);
|
825 | outU8Array[outIdx++] = 0x80 | ((u >> 24) & 63);
|
826 | outU8Array[outIdx++] = 0x80 | ((u >> 18) & 63);
|
827 | outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63);
|
828 | outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
|
829 | outU8Array[outIdx++] = 0x80 | (u & 63);
|
830 | }
|
831 | }
|
832 |
|
833 | outU8Array[outIdx] = 0;
|
834 | return outIdx - startIdx;
|
835 | }
|
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 | function stringToUTF8(str, outPtr, maxBytesToWrite) {
|
843 | assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
844 | return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
|
845 | }
|
846 |
|
847 |
|
848 |
|
849 | function lengthBytesUTF8(str) {
|
850 | var len = 0;
|
851 | for (var i = 0; i < str.length; ++i) {
|
852 |
|
853 |
|
854 | var u = str.charCodeAt(i);
|
855 | if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
|
856 | if (u <= 0x7F) {
|
857 | ++len;
|
858 | } else if (u <= 0x7FF) {
|
859 | len += 2;
|
860 | } else if (u <= 0xFFFF) {
|
861 | len += 3;
|
862 | } else if (u <= 0x1FFFFF) {
|
863 | len += 4;
|
864 | } else if (u <= 0x3FFFFFF) {
|
865 | len += 5;
|
866 | } else {
|
867 | len += 6;
|
868 | }
|
869 | }
|
870 | return len;
|
871 | }
|
872 |
|
873 |
|
874 |
|
875 |
|
876 | var UTF16Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-16le') : undefined;
|
877 | function UTF16ToString(ptr) {
|
878 | assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
|
879 | var endPtr = ptr;
|
880 |
|
881 |
|
882 | var idx = endPtr >> 1;
|
883 | while (HEAP16[idx]) ++idx;
|
884 | endPtr = idx << 1;
|
885 |
|
886 | if (endPtr - ptr > 32 && UTF16Decoder) {
|
887 | return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
|
888 | } else {
|
889 | var i = 0;
|
890 |
|
891 | var str = '';
|
892 | while (1) {
|
893 | var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
|
894 | if (codeUnit == 0) return str;
|
895 | ++i;
|
896 |
|
897 | str += String.fromCharCode(codeUnit);
|
898 | }
|
899 | }
|
900 | }
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 | function stringToUTF16(str, outPtr, maxBytesToWrite) {
|
914 | assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
|
915 | assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
916 |
|
917 | if (maxBytesToWrite === undefined) {
|
918 | maxBytesToWrite = 0x7FFFFFFF;
|
919 | }
|
920 | if (maxBytesToWrite < 2) return 0;
|
921 | maxBytesToWrite -= 2;
|
922 | var startPtr = outPtr;
|
923 | var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
|
924 | for (var i = 0; i < numCharsToWrite; ++i) {
|
925 |
|
926 | var codeUnit = str.charCodeAt(i);
|
927 | HEAP16[((outPtr)>>1)]=codeUnit;
|
928 | outPtr += 2;
|
929 | }
|
930 |
|
931 | HEAP16[((outPtr)>>1)]=0;
|
932 | return outPtr - startPtr;
|
933 | }
|
934 |
|
935 |
|
936 |
|
937 | function lengthBytesUTF16(str) {
|
938 | return str.length*2;
|
939 | }
|
940 |
|
941 | function UTF32ToString(ptr) {
|
942 | assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
|
943 | var i = 0;
|
944 |
|
945 | var str = '';
|
946 | while (1) {
|
947 | var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
|
948 | if (utf32 == 0)
|
949 | return str;
|
950 | ++i;
|
951 |
|
952 |
|
953 | if (utf32 >= 0x10000) {
|
954 | var ch = utf32 - 0x10000;
|
955 | str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
956 | } else {
|
957 | str += String.fromCharCode(utf32);
|
958 | }
|
959 | }
|
960 | }
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 | function stringToUTF32(str, outPtr, maxBytesToWrite) {
|
974 | assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
|
975 | assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
976 |
|
977 | if (maxBytesToWrite === undefined) {
|
978 | maxBytesToWrite = 0x7FFFFFFF;
|
979 | }
|
980 | if (maxBytesToWrite < 4) return 0;
|
981 | var startPtr = outPtr;
|
982 | var endPtr = startPtr + maxBytesToWrite - 4;
|
983 | for (var i = 0; i < str.length; ++i) {
|
984 |
|
985 |
|
986 | var codeUnit = str.charCodeAt(i);
|
987 | if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
|
988 | var trailSurrogate = str.charCodeAt(++i);
|
989 | codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
|
990 | }
|
991 | HEAP32[((outPtr)>>2)]=codeUnit;
|
992 | outPtr += 4;
|
993 | if (outPtr + 4 > endPtr) break;
|
994 | }
|
995 |
|
996 | HEAP32[((outPtr)>>2)]=0;
|
997 | return outPtr - startPtr;
|
998 | }
|
999 |
|
1000 |
|
1001 |
|
1002 | function lengthBytesUTF32(str) {
|
1003 | var len = 0;
|
1004 | for (var i = 0; i < str.length; ++i) {
|
1005 |
|
1006 |
|
1007 | var codeUnit = str.charCodeAt(i);
|
1008 | if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i;
|
1009 | len += 4;
|
1010 | }
|
1011 |
|
1012 | return len;
|
1013 | }
|
1014 |
|
1015 |
|
1016 |
|
1017 | function allocateUTF8(str) {
|
1018 | var size = lengthBytesUTF8(str) + 1;
|
1019 | var ret = _malloc(size);
|
1020 | if (ret) stringToUTF8Array(str, HEAP8, ret, size);
|
1021 | return ret;
|
1022 | }
|
1023 |
|
1024 |
|
1025 | function allocateUTF8OnStack(str) {
|
1026 | var size = lengthBytesUTF8(str) + 1;
|
1027 | var ret = stackAlloc(size);
|
1028 | stringToUTF8Array(str, HEAP8, ret, size);
|
1029 | return ret;
|
1030 | }
|
1031 |
|
1032 | function demangle(func) {
|
1033 | var __cxa_demangle_func = Module['___cxa_demangle'] || Module['__cxa_demangle'];
|
1034 | assert(__cxa_demangle_func);
|
1035 | try {
|
1036 | var s = func;
|
1037 | if (s.startsWith('__Z'))
|
1038 | s = s.substr(1);
|
1039 | var len = lengthBytesUTF8(s)+1;
|
1040 | var buf = _malloc(len);
|
1041 | stringToUTF8(s, buf, len);
|
1042 | var status = _malloc(4);
|
1043 | var ret = __cxa_demangle_func(buf, 0, 0, status);
|
1044 | if (HEAP32[((status)>>2)] === 0 && ret) {
|
1045 | return Pointer_stringify(ret);
|
1046 | }
|
1047 |
|
1048 | } catch(e) {
|
1049 |
|
1050 | } finally {
|
1051 | if (buf) _free(buf);
|
1052 | if (status) _free(status);
|
1053 | if (ret) _free(ret);
|
1054 | }
|
1055 |
|
1056 | return func;
|
1057 | }
|
1058 |
|
1059 | function demangleAll(text) {
|
1060 | var regex =
|
1061 | /__Z[\w\d_]+/g;
|
1062 | return text.replace(regex,
|
1063 | function(x) {
|
1064 | var y = demangle(x);
|
1065 | return x === y ? x : (y + ' [' + x + ']');
|
1066 | });
|
1067 | }
|
1068 |
|
1069 | function jsStackTrace() {
|
1070 | var err = new Error();
|
1071 | if (!err.stack) {
|
1072 |
|
1073 |
|
1074 | try {
|
1075 | throw new Error(0);
|
1076 | } catch(e) {
|
1077 | err = e;
|
1078 | }
|
1079 | if (!err.stack) {
|
1080 | return '(no stack trace available)';
|
1081 | }
|
1082 | }
|
1083 | return err.stack.toString();
|
1084 | }
|
1085 |
|
1086 | function stackTrace() {
|
1087 | var js = jsStackTrace();
|
1088 | if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace']();
|
1089 | return demangleAll(js);
|
1090 | }
|
1091 |
|
1092 |
|
1093 |
|
1094 | var PAGE_SIZE = 16384;
|
1095 | var WASM_PAGE_SIZE = 65536;
|
1096 | var ASMJS_PAGE_SIZE = 16777216;
|
1097 | var MIN_TOTAL_MEMORY = 16777216;
|
1098 |
|
1099 | function alignUp(x, multiple) {
|
1100 | if (x % multiple > 0) {
|
1101 | x += multiple - (x % multiple);
|
1102 | }
|
1103 | return x;
|
1104 | }
|
1105 |
|
1106 | var HEAP,
|
1107 |
|
1108 | buffer,
|
1109 |
|
1110 | HEAP8,
|
1111 |
|
1112 | HEAPU8,
|
1113 |
|
1114 | HEAP16,
|
1115 |
|
1116 | HEAPU16,
|
1117 |
|
1118 | HEAP32,
|
1119 |
|
1120 | HEAPU32,
|
1121 |
|
1122 | HEAPF32,
|
1123 |
|
1124 | HEAPF64;
|
1125 |
|
1126 | function updateGlobalBuffer(buf) {
|
1127 | Module['buffer'] = buffer = buf;
|
1128 | }
|
1129 |
|
1130 | function updateGlobalBufferViews() {
|
1131 | Module['HEAP8'] = HEAP8 = new Int8Array(buffer);
|
1132 | Module['HEAP16'] = HEAP16 = new Int16Array(buffer);
|
1133 | Module['HEAP32'] = HEAP32 = new Int32Array(buffer);
|
1134 | Module['HEAPU8'] = HEAPU8 = new Uint8Array(buffer);
|
1135 | Module['HEAPU16'] = HEAPU16 = new Uint16Array(buffer);
|
1136 | Module['HEAPU32'] = HEAPU32 = new Uint32Array(buffer);
|
1137 | Module['HEAPF32'] = HEAPF32 = new Float32Array(buffer);
|
1138 | Module['HEAPF64'] = HEAPF64 = new Float64Array(buffer);
|
1139 | }
|
1140 |
|
1141 | var STATIC_BASE, STATICTOP, staticSealed;
|
1142 | var STACK_BASE, STACKTOP, STACK_MAX;
|
1143 | var DYNAMIC_BASE, DYNAMICTOP_PTR;
|
1144 |
|
1145 | STATIC_BASE = STATICTOP = STACK_BASE = STACKTOP = STACK_MAX = DYNAMIC_BASE = DYNAMICTOP_PTR = 0;
|
1146 | staticSealed = false;
|
1147 |
|
1148 |
|
1149 |
|
1150 | function writeStackCookie() {
|
1151 | assert((STACK_MAX & 3) == 0);
|
1152 | HEAPU32[(STACK_MAX >> 2)-1] = 0x02135467;
|
1153 | HEAPU32[(STACK_MAX >> 2)-2] = 0x89BACDFE;
|
1154 | }
|
1155 |
|
1156 | function checkStackCookie() {
|
1157 | if (HEAPU32[(STACK_MAX >> 2)-1] != 0x02135467 || HEAPU32[(STACK_MAX >> 2)-2] != 0x89BACDFE) {
|
1158 | abort('Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x02135467, but received 0x' + HEAPU32[(STACK_MAX >> 2)-2].toString(16) + ' ' + HEAPU32[(STACK_MAX >> 2)-1].toString(16));
|
1159 | }
|
1160 |
|
1161 | if (HEAP32[0] !== 0x63736d65 ) throw 'Runtime error: The application has corrupted its heap memory area (address zero)!';
|
1162 | }
|
1163 |
|
1164 | function abortStackOverflow(allocSize) {
|
1165 | abort('Stack overflow! Attempted to allocate ' + allocSize + ' bytes on the stack, but stack has only ' + (STACK_MAX - stackSave() + allocSize) + ' bytes available!');
|
1166 | }
|
1167 |
|
1168 |
|
1169 | function abortOnCannotGrowMemory() {
|
1170 | abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ');
|
1171 | }
|
1172 |
|
1173 |
|
1174 | function enlargeMemory() {
|
1175 | abortOnCannotGrowMemory();
|
1176 | }
|
1177 |
|
1178 |
|
1179 | var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
|
1180 | var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 16777216;
|
1181 | if (TOTAL_MEMORY < TOTAL_STACK) err('TOTAL_MEMORY should be larger than TOTAL_STACK, was ' + TOTAL_MEMORY + '! (TOTAL_STACK=' + TOTAL_STACK + ')');
|
1182 |
|
1183 |
|
1184 |
|
1185 | assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray !== undefined && Int32Array.prototype.set !== undefined,
|
1186 | 'JS engine does not provide full typed array support');
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 | if (Module['buffer']) {
|
1192 | buffer = Module['buffer'];
|
1193 | assert(buffer.byteLength === TOTAL_MEMORY, 'provided buffer should be ' + TOTAL_MEMORY + ' bytes, but it is ' + buffer.byteLength);
|
1194 | } else {
|
1195 |
|
1196 | if (typeof WebAssembly === 'object' && typeof WebAssembly.Memory === 'function') {
|
1197 | assert(TOTAL_MEMORY % WASM_PAGE_SIZE === 0);
|
1198 | Module['wasmMemory'] = new WebAssembly.Memory({ 'initial': TOTAL_MEMORY / WASM_PAGE_SIZE, 'maximum': TOTAL_MEMORY / WASM_PAGE_SIZE });
|
1199 | buffer = Module['wasmMemory'].buffer;
|
1200 | } else
|
1201 | {
|
1202 | buffer = new ArrayBuffer(TOTAL_MEMORY);
|
1203 | }
|
1204 | assert(buffer.byteLength === TOTAL_MEMORY);
|
1205 | Module['buffer'] = buffer;
|
1206 | }
|
1207 | updateGlobalBufferViews();
|
1208 |
|
1209 |
|
1210 | function getTotalMemory() {
|
1211 | return TOTAL_MEMORY;
|
1212 | }
|
1213 |
|
1214 |
|
1215 | HEAP32[0] = 0x63736d65;
|
1216 | HEAP16[1] = 0x6373;
|
1217 | if (HEAPU8[2] !== 0x73 || HEAPU8[3] !== 0x63) throw 'Runtime error: expected the system to be little-endian!';
|
1218 |
|
1219 | function callRuntimeCallbacks(callbacks) {
|
1220 | while(callbacks.length > 0) {
|
1221 | var callback = callbacks.shift();
|
1222 | if (typeof callback == 'function') {
|
1223 | callback();
|
1224 | continue;
|
1225 | }
|
1226 | var func = callback.func;
|
1227 | if (typeof func === 'number') {
|
1228 | if (callback.arg === undefined) {
|
1229 | Module['dynCall_v'](func);
|
1230 | } else {
|
1231 | Module['dynCall_vi'](func, callback.arg);
|
1232 | }
|
1233 | } else {
|
1234 | func(callback.arg === undefined ? null : callback.arg);
|
1235 | }
|
1236 | }
|
1237 | }
|
1238 |
|
1239 | var __ATPRERUN__ = [];
|
1240 | var __ATINIT__ = [];
|
1241 | var __ATMAIN__ = [];
|
1242 | var __ATEXIT__ = [];
|
1243 | var __ATPOSTRUN__ = [];
|
1244 |
|
1245 | var runtimeInitialized = false;
|
1246 | var runtimeExited = false;
|
1247 |
|
1248 |
|
1249 | function preRun() {
|
1250 |
|
1251 | if (Module['preRun']) {
|
1252 | if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
|
1253 | while (Module['preRun'].length) {
|
1254 | addOnPreRun(Module['preRun'].shift());
|
1255 | }
|
1256 | }
|
1257 | callRuntimeCallbacks(__ATPRERUN__);
|
1258 | }
|
1259 |
|
1260 | function ensureInitRuntime() {
|
1261 | checkStackCookie();
|
1262 | if (runtimeInitialized) return;
|
1263 | runtimeInitialized = true;
|
1264 | callRuntimeCallbacks(__ATINIT__);
|
1265 | }
|
1266 |
|
1267 | function preMain() {
|
1268 | checkStackCookie();
|
1269 | callRuntimeCallbacks(__ATMAIN__);
|
1270 | }
|
1271 |
|
1272 | function exitRuntime() {
|
1273 | checkStackCookie();
|
1274 | callRuntimeCallbacks(__ATEXIT__);
|
1275 | runtimeExited = true;
|
1276 | }
|
1277 |
|
1278 | function postRun() {
|
1279 | checkStackCookie();
|
1280 |
|
1281 | if (Module['postRun']) {
|
1282 | if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
|
1283 | while (Module['postRun'].length) {
|
1284 | addOnPostRun(Module['postRun'].shift());
|
1285 | }
|
1286 | }
|
1287 | callRuntimeCallbacks(__ATPOSTRUN__);
|
1288 | }
|
1289 |
|
1290 | function addOnPreRun(cb) {
|
1291 | __ATPRERUN__.unshift(cb);
|
1292 | }
|
1293 |
|
1294 | function addOnInit(cb) {
|
1295 | __ATINIT__.unshift(cb);
|
1296 | }
|
1297 |
|
1298 | function addOnPreMain(cb) {
|
1299 | __ATMAIN__.unshift(cb);
|
1300 | }
|
1301 |
|
1302 | function addOnExit(cb) {
|
1303 | __ATEXIT__.unshift(cb);
|
1304 | }
|
1305 |
|
1306 | function addOnPostRun(cb) {
|
1307 | __ATPOSTRUN__.unshift(cb);
|
1308 | }
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 | function writeStringToMemory(string, buffer, dontAddNull) {
|
1316 | warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
|
1317 |
|
1318 | var lastChar, end;
|
1319 | if (dontAddNull) {
|
1320 |
|
1321 |
|
1322 |
|
1323 | end = buffer + lengthBytesUTF8(string);
|
1324 | lastChar = HEAP8[end];
|
1325 | }
|
1326 | stringToUTF8(string, buffer, Infinity);
|
1327 | if (dontAddNull) HEAP8[end] = lastChar;
|
1328 | }
|
1329 |
|
1330 | function writeArrayToMemory(array, buffer) {
|
1331 | assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
|
1332 | HEAP8.set(array, buffer);
|
1333 | }
|
1334 |
|
1335 | function writeAsciiToMemory(str, buffer, dontAddNull) {
|
1336 | for (var i = 0; i < str.length; ++i) {
|
1337 | assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff);
|
1338 | HEAP8[((buffer++)>>0)]=str.charCodeAt(i);
|
1339 | }
|
1340 |
|
1341 | if (!dontAddNull) HEAP8[((buffer)>>0)]=0;
|
1342 | }
|
1343 |
|
1344 | function unSign(value, bits, ignore) {
|
1345 | if (value >= 0) {
|
1346 | return value;
|
1347 | }
|
1348 | return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value
|
1349 | : Math.pow(2, bits) + value;
|
1350 | }
|
1351 | function reSign(value, bits, ignore) {
|
1352 | if (value <= 0) {
|
1353 | return value;
|
1354 | }
|
1355 | var half = bits <= 32 ? Math.abs(1 << (bits-1))
|
1356 | : Math.pow(2, bits-1);
|
1357 | if (value >= half && (bits <= 32 || value > half)) {
|
1358 |
|
1359 |
|
1360 | value = -2*half + value;
|
1361 | }
|
1362 | return value;
|
1363 | }
|
1364 |
|
1365 | assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
1366 | assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
1367 | assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
1368 | assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
1369 |
|
1370 | var Math_abs = Math.abs;
|
1371 | var Math_cos = Math.cos;
|
1372 | var Math_sin = Math.sin;
|
1373 | var Math_tan = Math.tan;
|
1374 | var Math_acos = Math.acos;
|
1375 | var Math_asin = Math.asin;
|
1376 | var Math_atan = Math.atan;
|
1377 | var Math_atan2 = Math.atan2;
|
1378 | var Math_exp = Math.exp;
|
1379 | var Math_log = Math.log;
|
1380 | var Math_sqrt = Math.sqrt;
|
1381 | var Math_ceil = Math.ceil;
|
1382 | var Math_floor = Math.floor;
|
1383 | var Math_pow = Math.pow;
|
1384 | var Math_imul = Math.imul;
|
1385 | var Math_fround = Math.fround;
|
1386 | var Math_round = Math.round;
|
1387 | var Math_min = Math.min;
|
1388 | var Math_max = Math.max;
|
1389 | var Math_clz32 = Math.clz32;
|
1390 | var Math_trunc = Math.trunc;
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 | var runDependencies = 0;
|
1400 | var runDependencyWatcher = null;
|
1401 | var dependenciesFulfilled = null;
|
1402 | var runDependencyTracking = {};
|
1403 |
|
1404 | function getUniqueRunDependency(id) {
|
1405 | var orig = id;
|
1406 | while (1) {
|
1407 | if (!runDependencyTracking[id]) return id;
|
1408 | id = orig + Math.random();
|
1409 | }
|
1410 | return id;
|
1411 | }
|
1412 |
|
1413 | function addRunDependency(id) {
|
1414 | runDependencies++;
|
1415 | if (Module['monitorRunDependencies']) {
|
1416 | Module['monitorRunDependencies'](runDependencies);
|
1417 | }
|
1418 | if (id) {
|
1419 | assert(!runDependencyTracking[id]);
|
1420 | runDependencyTracking[id] = 1;
|
1421 | if (runDependencyWatcher === null && typeof setInterval !== 'undefined') {
|
1422 |
|
1423 | runDependencyWatcher = setInterval(function() {
|
1424 | if (ABORT) {
|
1425 | clearInterval(runDependencyWatcher);
|
1426 | runDependencyWatcher = null;
|
1427 | return;
|
1428 | }
|
1429 | var shown = false;
|
1430 | for (var dep in runDependencyTracking) {
|
1431 | if (!shown) {
|
1432 | shown = true;
|
1433 | err('still waiting on run dependencies:');
|
1434 | }
|
1435 | err('dependency: ' + dep);
|
1436 | }
|
1437 | if (shown) {
|
1438 | err('(end of list)');
|
1439 | }
|
1440 | }, 10000);
|
1441 | }
|
1442 | } else {
|
1443 | err('warning: run dependency added without ID');
|
1444 | }
|
1445 | }
|
1446 |
|
1447 | function removeRunDependency(id) {
|
1448 | runDependencies--;
|
1449 | if (Module['monitorRunDependencies']) {
|
1450 | Module['monitorRunDependencies'](runDependencies);
|
1451 | }
|
1452 | if (id) {
|
1453 | assert(runDependencyTracking[id]);
|
1454 | delete runDependencyTracking[id];
|
1455 | } else {
|
1456 | err('warning: run dependency removed without ID');
|
1457 | }
|
1458 | if (runDependencies == 0) {
|
1459 | if (runDependencyWatcher !== null) {
|
1460 | clearInterval(runDependencyWatcher);
|
1461 | runDependencyWatcher = null;
|
1462 | }
|
1463 | if (dependenciesFulfilled) {
|
1464 | var callback = dependenciesFulfilled;
|
1465 | dependenciesFulfilled = null;
|
1466 | callback();
|
1467 | }
|
1468 | }
|
1469 | }
|
1470 |
|
1471 | Module["preloadedImages"] = {};
|
1472 | Module["preloadedAudios"] = {};
|
1473 |
|
1474 |
|
1475 |
|
1476 | var memoryInitializer = null;
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 | var dataURIPrefix = 'data:application/octet-stream;base64,';
|
1490 |
|
1491 |
|
1492 | function isDataURI(filename) {
|
1493 | return String.prototype.startsWith ?
|
1494 | filename.startsWith(dataURIPrefix) :
|
1495 | filename.indexOf(dataURIPrefix) === 0;
|
1496 | }
|
1497 |
|
1498 |
|
1499 |
|
1500 |
|
1501 | function integrateWasmJS() {
|
1502 |
|
1503 |
|
1504 |
|
1505 |
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 | var method = 'native-wasm';
|
1516 |
|
1517 | var wasmTextFile = 'redirects.wast';
|
1518 | var wasmBinaryFile = 'redirects.wasm';
|
1519 | var asmjsCodeFile = 'redirects.temp.asm.js';
|
1520 |
|
1521 | if (!isDataURI(wasmTextFile)) {
|
1522 | wasmTextFile = locateFile(wasmTextFile);
|
1523 | }
|
1524 | if (!isDataURI(wasmBinaryFile)) {
|
1525 | wasmBinaryFile = locateFile(wasmBinaryFile);
|
1526 | }
|
1527 | if (!isDataURI(asmjsCodeFile)) {
|
1528 | asmjsCodeFile = locateFile(asmjsCodeFile);
|
1529 | }
|
1530 |
|
1531 |
|
1532 |
|
1533 | var wasmPageSize = 64*1024;
|
1534 |
|
1535 | var info = {
|
1536 | 'global': null,
|
1537 | 'env': null,
|
1538 | 'asm2wasm': asm2wasmImports,
|
1539 | 'parent': Module
|
1540 | };
|
1541 |
|
1542 | var exports = null;
|
1543 |
|
1544 |
|
1545 | function mergeMemory(newBuffer) {
|
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 | var oldBuffer = Module['buffer'];
|
1551 | if (newBuffer.byteLength < oldBuffer.byteLength) {
|
1552 | err('the new buffer in mergeMemory is smaller than the previous one. in native wasm, we should grow memory here');
|
1553 | }
|
1554 | var oldView = new Int8Array(oldBuffer);
|
1555 | var newView = new Int8Array(newBuffer);
|
1556 |
|
1557 |
|
1558 | newView.set(oldView);
|
1559 | updateGlobalBuffer(newBuffer);
|
1560 | updateGlobalBufferViews();
|
1561 | }
|
1562 |
|
1563 | function getBinary() {
|
1564 | try {
|
1565 | if (Module['wasmBinary']) {
|
1566 | return new Uint8Array(Module['wasmBinary']);
|
1567 | }
|
1568 | if (Module['readBinary']) {
|
1569 | return Module['readBinary'](wasmBinaryFile);
|
1570 | } else {
|
1571 | throw "both async and sync fetching of the wasm failed";
|
1572 | }
|
1573 | }
|
1574 | catch (err) {
|
1575 | abort(err);
|
1576 | }
|
1577 | }
|
1578 |
|
1579 | function getBinaryPromise() {
|
1580 |
|
1581 |
|
1582 | if (!Module['wasmBinary'] && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch === 'function') {
|
1583 | return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
|
1584 | if (!response['ok']) {
|
1585 | throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
|
1586 | }
|
1587 | return response['arrayBuffer']();
|
1588 | }).catch(function () {
|
1589 | return getBinary();
|
1590 | });
|
1591 | }
|
1592 |
|
1593 | return new Promise(function(resolve, reject) {
|
1594 | resolve(getBinary());
|
1595 | });
|
1596 | }
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 | function doNativeWasm(global, env, providedBuffer) {
|
1602 | if (typeof WebAssembly !== 'object') {
|
1603 |
|
1604 | abort('No WebAssembly support found. Build with -s WASM=0 to target JavaScript instead.');
|
1605 | err('no native wasm support detected');
|
1606 | return false;
|
1607 | }
|
1608 |
|
1609 | if (!(Module['wasmMemory'] instanceof WebAssembly.Memory)) {
|
1610 | err('no native wasm Memory in use');
|
1611 | return false;
|
1612 | }
|
1613 | env['memory'] = Module['wasmMemory'];
|
1614 |
|
1615 | info['global'] = {
|
1616 | 'NaN': NaN,
|
1617 | 'Infinity': Infinity
|
1618 | };
|
1619 | info['global.Math'] = Math;
|
1620 | info['env'] = env;
|
1621 |
|
1622 |
|
1623 | function receiveInstance(instance, module) {
|
1624 | exports = instance.exports;
|
1625 | if (exports.memory) mergeMemory(exports.memory);
|
1626 | Module['asm'] = exports;
|
1627 | Module["usingWasm"] = true;
|
1628 | removeRunDependency('wasm-instantiate');
|
1629 | }
|
1630 | addRunDependency('wasm-instantiate');
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 | if (Module['instantiateWasm']) {
|
1636 | try {
|
1637 | return Module['instantiateWasm'](info, receiveInstance);
|
1638 | } catch(e) {
|
1639 | err('Module.instantiateWasm callback failed with error: ' + e);
|
1640 | return false;
|
1641 | }
|
1642 | }
|
1643 |
|
1644 |
|
1645 |
|
1646 |
|
1647 | var trueModule = Module;
|
1648 | function receiveInstantiatedSource(output) {
|
1649 |
|
1650 |
|
1651 | assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
|
1652 | trueModule = null;
|
1653 | receiveInstance(output['instance'], output['module']);
|
1654 | }
|
1655 | function instantiateArrayBuffer(receiver) {
|
1656 | getBinaryPromise().then(function(binary) {
|
1657 | return WebAssembly.instantiate(binary, info);
|
1658 | }).then(receiver, function(reason) {
|
1659 | err('failed to asynchronously prepare wasm: ' + reason);
|
1660 | abort(reason);
|
1661 | });
|
1662 | }
|
1663 |
|
1664 | if (!Module['wasmBinary'] &&
|
1665 | typeof WebAssembly.instantiateStreaming === 'function' &&
|
1666 | !isDataURI(wasmBinaryFile) &&
|
1667 | typeof fetch === 'function') {
|
1668 | WebAssembly.instantiateStreaming(fetch(wasmBinaryFile, { credentials: 'same-origin' }), info)
|
1669 | .then(receiveInstantiatedSource, function(reason) {
|
1670 |
|
1671 |
|
1672 | err('wasm streaming compile failed: ' + reason);
|
1673 | err('falling back to ArrayBuffer instantiation');
|
1674 | instantiateArrayBuffer(receiveInstantiatedSource);
|
1675 | });
|
1676 | } else {
|
1677 | instantiateArrayBuffer(receiveInstantiatedSource);
|
1678 | }
|
1679 | return {};
|
1680 | }
|
1681 |
|
1682 |
|
1683 |
|
1684 | Module['asmPreload'] = Module['asm'];
|
1685 |
|
1686 |
|
1687 |
|
1688 | var asmjsReallocBuffer = Module['reallocBuffer'];
|
1689 |
|
1690 | var wasmReallocBuffer = function(size) {
|
1691 | var PAGE_MULTIPLE = Module["usingWasm"] ? WASM_PAGE_SIZE : ASMJS_PAGE_SIZE;
|
1692 | size = alignUp(size, PAGE_MULTIPLE);
|
1693 | var old = Module['buffer'];
|
1694 | var oldSize = old.byteLength;
|
1695 | if (Module["usingWasm"]) {
|
1696 |
|
1697 | try {
|
1698 | var result = Module['wasmMemory'].grow((size - oldSize) / wasmPageSize);
|
1699 | if (result !== (-1 | 0)) {
|
1700 |
|
1701 | return Module['buffer'] = Module['wasmMemory'].buffer;
|
1702 | } else {
|
1703 | return null;
|
1704 | }
|
1705 | } catch(e) {
|
1706 | console.error('Module.reallocBuffer: Attempted to grow from ' + oldSize + ' bytes to ' + size + ' bytes, but got error: ' + e);
|
1707 | return null;
|
1708 | }
|
1709 | }
|
1710 | };
|
1711 |
|
1712 | Module['reallocBuffer'] = function(size) {
|
1713 | if (finalMethod === 'asmjs') {
|
1714 | return asmjsReallocBuffer(size);
|
1715 | } else {
|
1716 | return wasmReallocBuffer(size);
|
1717 | }
|
1718 | };
|
1719 |
|
1720 |
|
1721 | var finalMethod = '';
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 | Module['asm'] = function(global, env, providedBuffer) {
|
1728 |
|
1729 | if (!env['table']) {
|
1730 | var TABLE_SIZE = Module['wasmTableSize'];
|
1731 | if (TABLE_SIZE === undefined) TABLE_SIZE = 1024;
|
1732 | var MAX_TABLE_SIZE = Module['wasmMaxTableSize'];
|
1733 | if (typeof WebAssembly === 'object' && typeof WebAssembly.Table === 'function') {
|
1734 | if (MAX_TABLE_SIZE !== undefined) {
|
1735 | env['table'] = new WebAssembly.Table({ 'initial': TABLE_SIZE, 'maximum': MAX_TABLE_SIZE, 'element': 'anyfunc' });
|
1736 | } else {
|
1737 | env['table'] = new WebAssembly.Table({ 'initial': TABLE_SIZE, element: 'anyfunc' });
|
1738 | }
|
1739 | } else {
|
1740 | env['table'] = new Array(TABLE_SIZE);
|
1741 | }
|
1742 | Module['wasmTable'] = env['table'];
|
1743 | }
|
1744 |
|
1745 | if (!env['__memory_base']) {
|
1746 | env['__memory_base'] = Module['STATIC_BASE'];
|
1747 | }
|
1748 | if (!env['__table_base']) {
|
1749 | env['__table_base'] = 0;
|
1750 | }
|
1751 |
|
1752 |
|
1753 |
|
1754 | var exports;
|
1755 | exports = doNativeWasm(global, env, providedBuffer);
|
1756 |
|
1757 | assert(exports, 'no binaryen method succeeded. consider enabling more options, like interpreting, if you want that: http://kripken.github.io/emscripten-site/docs/compiling/WebAssembly.html#binaryen-methods');
|
1758 |
|
1759 |
|
1760 | return exports;
|
1761 | };
|
1762 |
|
1763 | var methodHandler = Module['asm'];
|
1764 | }
|
1765 |
|
1766 | integrateWasmJS();
|
1767 |
|
1768 |
|
1769 |
|
1770 | var ASM_CONSTS = [];
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 | STATIC_BASE = GLOBAL_BASE;
|
1777 |
|
1778 | STATICTOP = STATIC_BASE + 212224;
|
1779 | __ATINIT__.push({ func: function() { __GLOBAL__sub_I_redirects_cpp() } }, { func: function() { __GLOBAL__sub_I_parser_cc() } }, { func: function() { __GLOBAL__sub_I_rule_cc() } }, { func: function() { __GLOBAL__sub_I_jsoncpp_cpp() } }, { func: function() { __GLOBAL__sub_I_base64_cc() } }, { func: function() { __GLOBAL__sub_I_bind_cpp() } }, { func: function() { ___emscripten_environ_constructor() } });
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 | var STATIC_BUMP = 212224;
|
1788 | Module["STATIC_BASE"] = STATIC_BASE;
|
1789 | Module["STATIC_BUMP"] = STATIC_BUMP;
|
1790 |
|
1791 |
|
1792 | var tempDoublePtr = STATICTOP; STATICTOP += 16;
|
1793 |
|
1794 | assert(tempDoublePtr % 8 == 0);
|
1795 |
|
1796 | function copyTempFloat(ptr) {
|
1797 |
|
1798 | HEAP8[tempDoublePtr] = HEAP8[ptr];
|
1799 |
|
1800 | HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
|
1801 |
|
1802 | HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
|
1803 |
|
1804 | HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
|
1805 |
|
1806 | }
|
1807 |
|
1808 | function copyTempDouble(ptr) {
|
1809 |
|
1810 | HEAP8[tempDoublePtr] = HEAP8[ptr];
|
1811 |
|
1812 | HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
|
1813 |
|
1814 | HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
|
1815 |
|
1816 | HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
|
1817 |
|
1818 | HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
|
1819 |
|
1820 | HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
|
1821 |
|
1822 | HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
|
1823 |
|
1824 | HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
|
1825 |
|
1826 | }
|
1827 |
|
1828 |
|
1829 |
|
1830 |
|
1831 | function ___assert_fail(condition, filename, line, func) {
|
1832 | abort('Assertion failed: ' + Pointer_stringify(condition) + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function']);
|
1833 | }
|
1834 |
|
1835 |
|
1836 | var ENV={};function ___buildEnvironment(environ) {
|
1837 |
|
1838 | var MAX_ENV_VALUES = 64;
|
1839 | var TOTAL_ENV_SIZE = 1024;
|
1840 |
|
1841 |
|
1842 | var poolPtr;
|
1843 | var envPtr;
|
1844 | if (!___buildEnvironment.called) {
|
1845 | ___buildEnvironment.called = true;
|
1846 |
|
1847 | ENV['USER'] = ENV['LOGNAME'] = 'web_user';
|
1848 | ENV['PATH'] = '/';
|
1849 | ENV['PWD'] = '/';
|
1850 | ENV['HOME'] = '/home/web_user';
|
1851 | ENV['LANG'] = 'C.UTF-8';
|
1852 | ENV['_'] = Module['thisProgram'];
|
1853 |
|
1854 | poolPtr = getMemory(TOTAL_ENV_SIZE);
|
1855 | envPtr = getMemory(MAX_ENV_VALUES * 4);
|
1856 | HEAP32[((envPtr)>>2)]=poolPtr;
|
1857 | HEAP32[((environ)>>2)]=envPtr;
|
1858 | } else {
|
1859 | envPtr = HEAP32[((environ)>>2)];
|
1860 | poolPtr = HEAP32[((envPtr)>>2)];
|
1861 | }
|
1862 |
|
1863 |
|
1864 | var strings = [];
|
1865 | var totalSize = 0;
|
1866 | for (var key in ENV) {
|
1867 | if (typeof ENV[key] === 'string') {
|
1868 | var line = key + '=' + ENV[key];
|
1869 | strings.push(line);
|
1870 | totalSize += line.length;
|
1871 | }
|
1872 | }
|
1873 | if (totalSize > TOTAL_ENV_SIZE) {
|
1874 | throw new Error('Environment size exceeded TOTAL_ENV_SIZE!');
|
1875 | }
|
1876 |
|
1877 |
|
1878 | var ptrSize = 4;
|
1879 | for (var i = 0; i < strings.length; i++) {
|
1880 | var line = strings[i];
|
1881 | writeAsciiToMemory(line, poolPtr);
|
1882 | HEAP32[(((envPtr)+(i * ptrSize))>>2)]=poolPtr;
|
1883 | poolPtr += line.length + 1;
|
1884 | }
|
1885 | HEAP32[(((envPtr)+(strings.length * ptrSize))>>2)]=0;
|
1886 | }
|
1887 |
|
1888 | function ___cxa_allocate_exception(size) {
|
1889 | return _malloc(size);
|
1890 | }
|
1891 |
|
1892 |
|
1893 | var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:function (adjusted) {
|
1894 | if (!adjusted || EXCEPTIONS.infos[adjusted]) return adjusted;
|
1895 | for (var key in EXCEPTIONS.infos) {
|
1896 | var ptr = +key;
|
1897 | var info = EXCEPTIONS.infos[ptr];
|
1898 | if (info.adjusted === adjusted) {
|
1899 | return ptr;
|
1900 | }
|
1901 | }
|
1902 | return adjusted;
|
1903 | },addRef:function (ptr) {
|
1904 | if (!ptr) return;
|
1905 | var info = EXCEPTIONS.infos[ptr];
|
1906 | info.refcount++;
|
1907 | },decRef:function (ptr) {
|
1908 | if (!ptr) return;
|
1909 | var info = EXCEPTIONS.infos[ptr];
|
1910 | assert(info.refcount > 0);
|
1911 | info.refcount--;
|
1912 |
|
1913 |
|
1914 |
|
1915 | if (info.refcount === 0 && !info.rethrown) {
|
1916 | if (info.destructor) {
|
1917 | Module['dynCall_vi'](info.destructor, ptr);
|
1918 | }
|
1919 | delete EXCEPTIONS.infos[ptr];
|
1920 | ___cxa_free_exception(ptr);
|
1921 | }
|
1922 | },clearRef:function (ptr) {
|
1923 | if (!ptr) return;
|
1924 | var info = EXCEPTIONS.infos[ptr];
|
1925 | info.refcount = 0;
|
1926 | }};function ___cxa_begin_catch(ptr) {
|
1927 | var info = EXCEPTIONS.infos[ptr];
|
1928 | if (info && !info.caught) {
|
1929 | info.caught = true;
|
1930 | __ZSt18uncaught_exceptionv.uncaught_exception--;
|
1931 | }
|
1932 | if (info) info.rethrown = false;
|
1933 | EXCEPTIONS.caught.push(ptr);
|
1934 | EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(ptr));
|
1935 | return ptr;
|
1936 | }
|
1937 |
|
1938 | function ___cxa_pure_virtual() {
|
1939 | ABORT = true;
|
1940 | throw 'Pure virtual function called!';
|
1941 | }
|
1942 |
|
1943 |
|
1944 |
|
1945 | function ___resumeException(ptr) {
|
1946 | if (!EXCEPTIONS.last) { EXCEPTIONS.last = ptr; }
|
1947 | throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
|
1948 | }function ___cxa_find_matching_catch() {
|
1949 | var thrown = EXCEPTIONS.last;
|
1950 | if (!thrown) {
|
1951 |
|
1952 | return ((setTempRet0(0),0)|0);
|
1953 | }
|
1954 | var info = EXCEPTIONS.infos[thrown];
|
1955 | var throwntype = info.type;
|
1956 | if (!throwntype) {
|
1957 |
|
1958 | return ((setTempRet0(0),thrown)|0);
|
1959 | }
|
1960 | var typeArray = Array.prototype.slice.call(arguments);
|
1961 |
|
1962 | var pointer = Module['___cxa_is_pointer_type'](throwntype);
|
1963 |
|
1964 | if (!___cxa_find_matching_catch.buffer) ___cxa_find_matching_catch.buffer = _malloc(4);
|
1965 | HEAP32[((___cxa_find_matching_catch.buffer)>>2)]=thrown;
|
1966 | thrown = ___cxa_find_matching_catch.buffer;
|
1967 |
|
1968 |
|
1969 |
|
1970 |
|
1971 | for (var i = 0; i < typeArray.length; i++) {
|
1972 | if (typeArray[i] && Module['___cxa_can_catch'](typeArray[i], throwntype, thrown)) {
|
1973 | thrown = HEAP32[((thrown)>>2)];
|
1974 | info.adjusted = thrown;
|
1975 | return ((setTempRet0(typeArray[i]),thrown)|0);
|
1976 | }
|
1977 | }
|
1978 |
|
1979 |
|
1980 |
|
1981 | thrown = HEAP32[((thrown)>>2)];
|
1982 | return ((setTempRet0(throwntype),thrown)|0);
|
1983 | }function ___cxa_throw(ptr, type, destructor) {
|
1984 | EXCEPTIONS.infos[ptr] = {
|
1985 | ptr: ptr,
|
1986 | adjusted: ptr,
|
1987 | type: type,
|
1988 | destructor: destructor,
|
1989 | refcount: 0,
|
1990 | caught: false,
|
1991 | rethrown: false
|
1992 | };
|
1993 | EXCEPTIONS.last = ptr;
|
1994 | if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
|
1995 | __ZSt18uncaught_exceptionv.uncaught_exception = 1;
|
1996 | } else {
|
1997 | __ZSt18uncaught_exceptionv.uncaught_exception++;
|
1998 | }
|
1999 | throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
|
2000 | }
|
2001 |
|
2002 | function ___cxa_uncaught_exception() {
|
2003 | return !!__ZSt18uncaught_exceptionv.uncaught_exception;
|
2004 | }
|
2005 |
|
2006 | function ___gxx_personality_v0() {
|
2007 | }
|
2008 |
|
2009 | function ___lock() {}
|
2010 |
|
2011 |
|
2012 | var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
|
2013 |
|
2014 | function ___setErrNo(value) {
|
2015 | if (Module['___errno_location']) HEAP32[((Module['___errno_location']())>>2)]=value;
|
2016 | else err('failed to set errno from JS');
|
2017 | return value;
|
2018 | }function ___map_file(pathname, size) {
|
2019 | ___setErrNo(ERRNO_CODES.EPERM);
|
2020 | return -1;
|
2021 | }
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 | var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
|
2027 |
|
2028 | var PATH={splitPath:function (filename) {
|
2029 | var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
2030 | return splitPathRe.exec(filename).slice(1);
|
2031 | },normalizeArray:function (parts, allowAboveRoot) {
|
2032 |
|
2033 | var up = 0;
|
2034 | for (var i = parts.length - 1; i >= 0; i--) {
|
2035 | var last = parts[i];
|
2036 | if (last === '.') {
|
2037 | parts.splice(i, 1);
|
2038 | } else if (last === '..') {
|
2039 | parts.splice(i, 1);
|
2040 | up++;
|
2041 | } else if (up) {
|
2042 | parts.splice(i, 1);
|
2043 | up--;
|
2044 | }
|
2045 | }
|
2046 |
|
2047 | if (allowAboveRoot) {
|
2048 | for (; up; up--) {
|
2049 | parts.unshift('..');
|
2050 | }
|
2051 | }
|
2052 | return parts;
|
2053 | },normalize:function (path) {
|
2054 | var isAbsolute = path.charAt(0) === '/',
|
2055 | trailingSlash = path.substr(-1) === '/';
|
2056 |
|
2057 | path = PATH.normalizeArray(path.split('/').filter(function(p) {
|
2058 | return !!p;
|
2059 | }), !isAbsolute).join('/');
|
2060 | if (!path && !isAbsolute) {
|
2061 | path = '.';
|
2062 | }
|
2063 | if (path && trailingSlash) {
|
2064 | path += '/';
|
2065 | }
|
2066 | return (isAbsolute ? '/' : '') + path;
|
2067 | },dirname:function (path) {
|
2068 | var result = PATH.splitPath(path),
|
2069 | root = result[0],
|
2070 | dir = result[1];
|
2071 | if (!root && !dir) {
|
2072 |
|
2073 | return '.';
|
2074 | }
|
2075 | if (dir) {
|
2076 |
|
2077 | dir = dir.substr(0, dir.length - 1);
|
2078 | }
|
2079 | return root + dir;
|
2080 | },basename:function (path) {
|
2081 |
|
2082 | if (path === '/') return '/';
|
2083 | var lastSlash = path.lastIndexOf('/');
|
2084 | if (lastSlash === -1) return path;
|
2085 | return path.substr(lastSlash+1);
|
2086 | },extname:function (path) {
|
2087 | return PATH.splitPath(path)[3];
|
2088 | },join:function () {
|
2089 | var paths = Array.prototype.slice.call(arguments, 0);
|
2090 | return PATH.normalize(paths.join('/'));
|
2091 | },join2:function (l, r) {
|
2092 | return PATH.normalize(l + '/' + r);
|
2093 | },resolve:function () {
|
2094 | var resolvedPath = '',
|
2095 | resolvedAbsolute = false;
|
2096 | for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
2097 | var path = (i >= 0) ? arguments[i] : FS.cwd();
|
2098 |
|
2099 | if (typeof path !== 'string') {
|
2100 | throw new TypeError('Arguments to path.resolve must be strings');
|
2101 | } else if (!path) {
|
2102 | return '';
|
2103 | }
|
2104 | resolvedPath = path + '/' + resolvedPath;
|
2105 | resolvedAbsolute = path.charAt(0) === '/';
|
2106 | }
|
2107 |
|
2108 |
|
2109 | resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
|
2110 | return !!p;
|
2111 | }), !resolvedAbsolute).join('/');
|
2112 | return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
2113 | },relative:function (from, to) {
|
2114 | from = PATH.resolve(from).substr(1);
|
2115 | to = PATH.resolve(to).substr(1);
|
2116 | function trim(arr) {
|
2117 | var start = 0;
|
2118 | for (; start < arr.length; start++) {
|
2119 | if (arr[start] !== '') break;
|
2120 | }
|
2121 | var end = arr.length - 1;
|
2122 | for (; end >= 0; end--) {
|
2123 | if (arr[end] !== '') break;
|
2124 | }
|
2125 | if (start > end) return [];
|
2126 | return arr.slice(start, end - start + 1);
|
2127 | }
|
2128 | var fromParts = trim(from.split('/'));
|
2129 | var toParts = trim(to.split('/'));
|
2130 | var length = Math.min(fromParts.length, toParts.length);
|
2131 | var samePartsLength = length;
|
2132 | for (var i = 0; i < length; i++) {
|
2133 | if (fromParts[i] !== toParts[i]) {
|
2134 | samePartsLength = i;
|
2135 | break;
|
2136 | }
|
2137 | }
|
2138 | var outputParts = [];
|
2139 | for (var i = samePartsLength; i < fromParts.length; i++) {
|
2140 | outputParts.push('..');
|
2141 | }
|
2142 | outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
2143 | return outputParts.join('/');
|
2144 | }};
|
2145 |
|
2146 | var TTY={ttys:[],init:function () {
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 | },shutdown:function () {
|
2156 |
|
2157 |
|
2158 |
|
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 | },register:function (dev, ops) {
|
2166 | TTY.ttys[dev] = { input: [], output: [], ops: ops };
|
2167 | FS.registerDevice(dev, TTY.stream_ops);
|
2168 | },stream_ops:{open:function (stream) {
|
2169 | var tty = TTY.ttys[stream.node.rdev];
|
2170 | if (!tty) {
|
2171 | throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
|
2172 | }
|
2173 | stream.tty = tty;
|
2174 | stream.seekable = false;
|
2175 | },close:function (stream) {
|
2176 |
|
2177 | stream.tty.ops.flush(stream.tty);
|
2178 | },flush:function (stream) {
|
2179 | stream.tty.ops.flush(stream.tty);
|
2180 | },read:function (stream, buffer, offset, length, pos /* ignored */) {
|
2181 | if (!stream.tty || !stream.tty.ops.get_char) {
|
2182 | throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
|
2183 | }
|
2184 | var bytesRead = 0;
|
2185 | for (var i = 0; i < length; i++) {
|
2186 | var result;
|
2187 | try {
|
2188 | result = stream.tty.ops.get_char(stream.tty);
|
2189 | } catch (e) {
|
2190 | throw new FS.ErrnoError(ERRNO_CODES.EIO);
|
2191 | }
|
2192 | if (result === undefined && bytesRead === 0) {
|
2193 | throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
|
2194 | }
|
2195 | if (result === null || result === undefined) break;
|
2196 | bytesRead++;
|
2197 | buffer[offset+i] = result;
|
2198 | }
|
2199 | if (bytesRead) {
|
2200 | stream.node.timestamp = Date.now();
|
2201 | }
|
2202 | return bytesRead;
|
2203 | },write:function (stream, buffer, offset, length, pos) {
|
2204 | if (!stream.tty || !stream.tty.ops.put_char) {
|
2205 | throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
|
2206 | }
|
2207 | var i = 0;
|
2208 | try {
|
2209 | if (offset === 0 && length === 0) {
|
2210 |
|
2211 | stream.tty.ops.flush(stream.tty);
|
2212 | } else {
|
2213 | while (i < length) {
|
2214 | stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
|
2215 | i++;
|
2216 | }
|
2217 | }
|
2218 | } catch (e) {
|
2219 | throw new FS.ErrnoError(ERRNO_CODES.EIO);
|
2220 | }
|
2221 | if (length) {
|
2222 | stream.node.timestamp = Date.now();
|
2223 | }
|
2224 | return i;
|
2225 | }},default_tty_ops:{get_char:function (tty) {
|
2226 | if (!tty.input.length) {
|
2227 | var result = null;
|
2228 | if (ENVIRONMENT_IS_NODE) {
|
2229 |
|
2230 | var BUFSIZE = 256;
|
2231 | var buf = new Buffer(BUFSIZE);
|
2232 | var bytesRead = 0;
|
2233 |
|
2234 | var isPosixPlatform = (process.platform != 'win32');
|
2235 |
|
2236 | var fd = process.stdin.fd;
|
2237 | if (isPosixPlatform) {
|
2238 |
|
2239 | var usingDevice = false;
|
2240 | try {
|
2241 | fd = fs.openSync('/dev/stdin', 'r');
|
2242 | usingDevice = true;
|
2243 | } catch (e) {}
|
2244 | }
|
2245 |
|
2246 | try {
|
2247 | bytesRead = fs.readSync(fd, buf, 0, BUFSIZE, null);
|
2248 | } catch(e) {
|
2249 |
|
2250 |
|
2251 | if (e.toString().indexOf('EOF') != -1) bytesRead = 0;
|
2252 | else throw e;
|
2253 | }
|
2254 |
|
2255 | if (usingDevice) { fs.closeSync(fd); }
|
2256 | if (bytesRead > 0) {
|
2257 | result = buf.slice(0, bytesRead).toString('utf-8');
|
2258 | } else {
|
2259 | result = null;
|
2260 | }
|
2261 |
|
2262 | } else if (typeof window != 'undefined' &&
|
2263 | typeof window.prompt == 'function') {
|
2264 |
|
2265 | result = window.prompt('Input: ');
|
2266 | if (result !== null) {
|
2267 | result += '\n';
|
2268 | }
|
2269 | } else if (typeof readline == 'function') {
|
2270 |
|
2271 | result = readline();
|
2272 | if (result !== null) {
|
2273 | result += '\n';
|
2274 | }
|
2275 | }
|
2276 | if (!result) {
|
2277 | return null;
|
2278 | }
|
2279 | tty.input = intArrayFromString(result, true);
|
2280 | }
|
2281 | return tty.input.shift();
|
2282 | },put_char:function (tty, val) {
|
2283 | if (val === null || val === 10) {
|
2284 | out(UTF8ArrayToString(tty.output, 0));
|
2285 | tty.output = [];
|
2286 | } else {
|
2287 | if (val != 0) tty.output.push(val);
|
2288 | }
|
2289 | },flush:function (tty) {
|
2290 | if (tty.output && tty.output.length > 0) {
|
2291 | out(UTF8ArrayToString(tty.output, 0));
|
2292 | tty.output = [];
|
2293 | }
|
2294 | }},default_tty1_ops:{put_char:function (tty, val) {
|
2295 | if (val === null || val === 10) {
|
2296 | err(UTF8ArrayToString(tty.output, 0));
|
2297 | tty.output = [];
|
2298 | } else {
|
2299 | if (val != 0) tty.output.push(val);
|
2300 | }
|
2301 | },flush:function (tty) {
|
2302 | if (tty.output && tty.output.length > 0) {
|
2303 | err(UTF8ArrayToString(tty.output, 0));
|
2304 | tty.output = [];
|
2305 | }
|
2306 | }}};
|
2307 |
|
2308 | var MEMFS={ops_table:null,mount:function (mount) {
|
2309 | return MEMFS.createNode(null, '/', 16384 | 511 , 0);
|
2310 | },createNode:function (parent, name, mode, dev) {
|
2311 | if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
|
2312 |
|
2313 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
2314 | }
|
2315 | if (!MEMFS.ops_table) {
|
2316 | MEMFS.ops_table = {
|
2317 | dir: {
|
2318 | node: {
|
2319 | getattr: MEMFS.node_ops.getattr,
|
2320 | setattr: MEMFS.node_ops.setattr,
|
2321 | lookup: MEMFS.node_ops.lookup,
|
2322 | mknod: MEMFS.node_ops.mknod,
|
2323 | rename: MEMFS.node_ops.rename,
|
2324 | unlink: MEMFS.node_ops.unlink,
|
2325 | rmdir: MEMFS.node_ops.rmdir,
|
2326 | readdir: MEMFS.node_ops.readdir,
|
2327 | symlink: MEMFS.node_ops.symlink
|
2328 | },
|
2329 | stream: {
|
2330 | llseek: MEMFS.stream_ops.llseek
|
2331 | }
|
2332 | },
|
2333 | file: {
|
2334 | node: {
|
2335 | getattr: MEMFS.node_ops.getattr,
|
2336 | setattr: MEMFS.node_ops.setattr
|
2337 | },
|
2338 | stream: {
|
2339 | llseek: MEMFS.stream_ops.llseek,
|
2340 | read: MEMFS.stream_ops.read,
|
2341 | write: MEMFS.stream_ops.write,
|
2342 | allocate: MEMFS.stream_ops.allocate,
|
2343 | mmap: MEMFS.stream_ops.mmap,
|
2344 | msync: MEMFS.stream_ops.msync
|
2345 | }
|
2346 | },
|
2347 | link: {
|
2348 | node: {
|
2349 | getattr: MEMFS.node_ops.getattr,
|
2350 | setattr: MEMFS.node_ops.setattr,
|
2351 | readlink: MEMFS.node_ops.readlink
|
2352 | },
|
2353 | stream: {}
|
2354 | },
|
2355 | chrdev: {
|
2356 | node: {
|
2357 | getattr: MEMFS.node_ops.getattr,
|
2358 | setattr: MEMFS.node_ops.setattr
|
2359 | },
|
2360 | stream: FS.chrdev_stream_ops
|
2361 | }
|
2362 | };
|
2363 | }
|
2364 | var node = FS.createNode(parent, name, mode, dev);
|
2365 | if (FS.isDir(node.mode)) {
|
2366 | node.node_ops = MEMFS.ops_table.dir.node;
|
2367 | node.stream_ops = MEMFS.ops_table.dir.stream;
|
2368 | node.contents = {};
|
2369 | } else if (FS.isFile(node.mode)) {
|
2370 | node.node_ops = MEMFS.ops_table.file.node;
|
2371 | node.stream_ops = MEMFS.ops_table.file.stream;
|
2372 | node.usedBytes = 0;
|
2373 |
|
2374 |
|
2375 |
|
2376 | node.contents = null;
|
2377 | } else if (FS.isLink(node.mode)) {
|
2378 | node.node_ops = MEMFS.ops_table.link.node;
|
2379 | node.stream_ops = MEMFS.ops_table.link.stream;
|
2380 | } else if (FS.isChrdev(node.mode)) {
|
2381 | node.node_ops = MEMFS.ops_table.chrdev.node;
|
2382 | node.stream_ops = MEMFS.ops_table.chrdev.stream;
|
2383 | }
|
2384 | node.timestamp = Date.now();
|
2385 |
|
2386 | if (parent) {
|
2387 | parent.contents[name] = node;
|
2388 | }
|
2389 | return node;
|
2390 | },getFileDataAsRegularArray:function (node) {
|
2391 | if (node.contents && node.contents.subarray) {
|
2392 | var arr = [];
|
2393 | for (var i = 0; i < node.usedBytes; ++i) arr.push(node.contents[i]);
|
2394 | return arr;
|
2395 | }
|
2396 | return node.contents;
|
2397 | },getFileDataAsTypedArray:function (node) {
|
2398 | if (!node.contents) return new Uint8Array;
|
2399 | if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes);
|
2400 | return new Uint8Array(node.contents);
|
2401 | },expandFileStorage:function (node, newCapacity) {
|
2402 |
|
2403 |
|
2404 |
|
2405 | if (node.contents && node.contents.subarray && newCapacity > node.contents.length) {
|
2406 | node.contents = MEMFS.getFileDataAsRegularArray(node);
|
2407 | node.usedBytes = node.contents.length;
|
2408 | }
|
2409 |
|
2410 | if (!node.contents || node.contents.subarray) {
|
2411 | var prevCapacity = node.contents ? node.contents.length : 0;
|
2412 | if (prevCapacity >= newCapacity) return;
|
2413 |
|
2414 |
|
2415 |
|
2416 | var CAPACITY_DOUBLING_MAX = 1024 * 1024;
|
2417 | newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) | 0);
|
2418 | if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256);
|
2419 | var oldContents = node.contents;
|
2420 | node.contents = new Uint8Array(newCapacity);
|
2421 | if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
|
2422 | return;
|
2423 | }
|
2424 |
|
2425 | if (!node.contents && newCapacity > 0) node.contents = [];
|
2426 | while (node.contents.length < newCapacity) node.contents.push(0);
|
2427 | },resizeFileStorage:function (node, newSize) {
|
2428 | if (node.usedBytes == newSize) return;
|
2429 | if (newSize == 0) {
|
2430 | node.contents = null;
|
2431 | node.usedBytes = 0;
|
2432 | return;
|
2433 | }
|
2434 | if (!node.contents || node.contents.subarray) {
|
2435 | var oldContents = node.contents;
|
2436 | node.contents = new Uint8Array(new ArrayBuffer(newSize));
|
2437 | if (oldContents) {
|
2438 | node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)));
|
2439 | }
|
2440 | node.usedBytes = newSize;
|
2441 | return;
|
2442 | }
|
2443 |
|
2444 | if (!node.contents) node.contents = [];
|
2445 | if (node.contents.length > newSize) node.contents.length = newSize;
|
2446 | else while (node.contents.length < newSize) node.contents.push(0);
|
2447 | node.usedBytes = newSize;
|
2448 | },node_ops:{getattr:function (node) {
|
2449 | var attr = {};
|
2450 |
|
2451 | attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
|
2452 | attr.ino = node.id;
|
2453 | attr.mode = node.mode;
|
2454 | attr.nlink = 1;
|
2455 | attr.uid = 0;
|
2456 | attr.gid = 0;
|
2457 | attr.rdev = node.rdev;
|
2458 | if (FS.isDir(node.mode)) {
|
2459 | attr.size = 4096;
|
2460 | } else if (FS.isFile(node.mode)) {
|
2461 | attr.size = node.usedBytes;
|
2462 | } else if (FS.isLink(node.mode)) {
|
2463 | attr.size = node.link.length;
|
2464 | } else {
|
2465 | attr.size = 0;
|
2466 | }
|
2467 | attr.atime = new Date(node.timestamp);
|
2468 | attr.mtime = new Date(node.timestamp);
|
2469 | attr.ctime = new Date(node.timestamp);
|
2470 |
|
2471 |
|
2472 | attr.blksize = 4096;
|
2473 | attr.blocks = Math.ceil(attr.size / attr.blksize);
|
2474 | return attr;
|
2475 | },setattr:function (node, attr) {
|
2476 | if (attr.mode !== undefined) {
|
2477 | node.mode = attr.mode;
|
2478 | }
|
2479 | if (attr.timestamp !== undefined) {
|
2480 | node.timestamp = attr.timestamp;
|
2481 | }
|
2482 | if (attr.size !== undefined) {
|
2483 | MEMFS.resizeFileStorage(node, attr.size);
|
2484 | }
|
2485 | },lookup:function (parent, name) {
|
2486 | throw FS.genericErrors[ERRNO_CODES.ENOENT];
|
2487 | },mknod:function (parent, name, mode, dev) {
|
2488 | return MEMFS.createNode(parent, name, mode, dev);
|
2489 | },rename:function (old_node, new_dir, new_name) {
|
2490 |
|
2491 | if (FS.isDir(old_node.mode)) {
|
2492 | var new_node;
|
2493 | try {
|
2494 | new_node = FS.lookupNode(new_dir, new_name);
|
2495 | } catch (e) {
|
2496 | }
|
2497 | if (new_node) {
|
2498 | for (var i in new_node.contents) {
|
2499 | throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
|
2500 | }
|
2501 | }
|
2502 | }
|
2503 |
|
2504 | delete old_node.parent.contents[old_node.name];
|
2505 | old_node.name = new_name;
|
2506 | new_dir.contents[new_name] = old_node;
|
2507 | old_node.parent = new_dir;
|
2508 | },unlink:function (parent, name) {
|
2509 | delete parent.contents[name];
|
2510 | },rmdir:function (parent, name) {
|
2511 | var node = FS.lookupNode(parent, name);
|
2512 | for (var i in node.contents) {
|
2513 | throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
|
2514 | }
|
2515 | delete parent.contents[name];
|
2516 | },readdir:function (node) {
|
2517 | var entries = ['.', '..']
|
2518 | for (var key in node.contents) {
|
2519 | if (!node.contents.hasOwnProperty(key)) {
|
2520 | continue;
|
2521 | }
|
2522 | entries.push(key);
|
2523 | }
|
2524 | return entries;
|
2525 | },symlink:function (parent, newname, oldpath) {
|
2526 | var node = MEMFS.createNode(parent, newname, 511 | 40960, 0);
|
2527 | node.link = oldpath;
|
2528 | return node;
|
2529 | },readlink:function (node) {
|
2530 | if (!FS.isLink(node.mode)) {
|
2531 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
2532 | }
|
2533 | return node.link;
|
2534 | }},stream_ops:{read:function (stream, buffer, offset, length, position) {
|
2535 | var contents = stream.node.contents;
|
2536 | if (position >= stream.node.usedBytes) return 0;
|
2537 | var size = Math.min(stream.node.usedBytes - position, length);
|
2538 | assert(size >= 0);
|
2539 | if (size > 8 && contents.subarray) {
|
2540 | buffer.set(contents.subarray(position, position + size), offset);
|
2541 | } else {
|
2542 | for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
|
2543 | }
|
2544 | return size;
|
2545 | },write:function (stream, buffer, offset, length, position, canOwn) {
|
2546 |
|
2547 | if (!length) return 0;
|
2548 | var node = stream.node;
|
2549 | node.timestamp = Date.now();
|
2550 |
|
2551 | if (buffer.subarray && (!node.contents || node.contents.subarray)) {
|
2552 | if (canOwn) {
|
2553 | assert(position === 0, 'canOwn must imply no weird position inside the file');
|
2554 | node.contents = buffer.subarray(offset, offset + length);
|
2555 | node.usedBytes = length;
|
2556 | return length;
|
2557 | } else if (node.usedBytes === 0 && position === 0) {
|
2558 | node.contents = new Uint8Array(buffer.subarray(offset, offset + length));
|
2559 | node.usedBytes = length;
|
2560 | return length;
|
2561 | } else if (position + length <= node.usedBytes) {
|
2562 | node.contents.set(buffer.subarray(offset, offset + length), position);
|
2563 | return length;
|
2564 | }
|
2565 | }
|
2566 |
|
2567 |
|
2568 | MEMFS.expandFileStorage(node, position+length);
|
2569 | if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position);
|
2570 | else {
|
2571 | for (var i = 0; i < length; i++) {
|
2572 | node.contents[position + i] = buffer[offset + i];
|
2573 | }
|
2574 | }
|
2575 | node.usedBytes = Math.max(node.usedBytes, position+length);
|
2576 | return length;
|
2577 | },llseek:function (stream, offset, whence) {
|
2578 | var position = offset;
|
2579 | if (whence === 1) {
|
2580 | position += stream.position;
|
2581 | } else if (whence === 2) {
|
2582 | if (FS.isFile(stream.node.mode)) {
|
2583 | position += stream.node.usedBytes;
|
2584 | }
|
2585 | }
|
2586 | if (position < 0) {
|
2587 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
2588 | }
|
2589 | return position;
|
2590 | },allocate:function (stream, offset, length) {
|
2591 | MEMFS.expandFileStorage(stream.node, offset + length);
|
2592 | stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
|
2593 | },mmap:function (stream, buffer, offset, length, position, prot, flags) {
|
2594 | if (!FS.isFile(stream.node.mode)) {
|
2595 | throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
|
2596 | }
|
2597 | var ptr;
|
2598 | var allocated;
|
2599 | var contents = stream.node.contents;
|
2600 |
|
2601 | if ( !(flags & 2) &&
|
2602 | (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
|
2603 |
|
2604 |
|
2605 | allocated = false;
|
2606 | ptr = contents.byteOffset;
|
2607 | } else {
|
2608 |
|
2609 | if (position > 0 || position + length < stream.node.usedBytes) {
|
2610 | if (contents.subarray) {
|
2611 | contents = contents.subarray(position, position + length);
|
2612 | } else {
|
2613 | contents = Array.prototype.slice.call(contents, position, position + length);
|
2614 | }
|
2615 | }
|
2616 | allocated = true;
|
2617 | ptr = _malloc(length);
|
2618 | if (!ptr) {
|
2619 | throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
|
2620 | }
|
2621 | buffer.set(contents, ptr);
|
2622 | }
|
2623 | return { ptr: ptr, allocated: allocated };
|
2624 | },msync:function (stream, buffer, offset, length, mmapFlags) {
|
2625 | if (!FS.isFile(stream.node.mode)) {
|
2626 | throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
|
2627 | }
|
2628 | if (mmapFlags & 2) {
|
2629 |
|
2630 | return 0;
|
2631 | }
|
2632 |
|
2633 | var bytesWritten = MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
|
2634 |
|
2635 | return 0;
|
2636 | }}};
|
2637 |
|
2638 | var IDBFS={dbs:{},indexedDB:function () {
|
2639 | if (typeof indexedDB !== 'undefined') return indexedDB;
|
2640 | var ret = null;
|
2641 | if (typeof window === 'object') ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
|
2642 | assert(ret, 'IDBFS used, but indexedDB not supported');
|
2643 | return ret;
|
2644 | },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
|
2645 |
|
2646 | return MEMFS.mount.apply(null, arguments);
|
2647 | },syncfs:function (mount, populate, callback) {
|
2648 | IDBFS.getLocalSet(mount, function(err, local) {
|
2649 | if (err) return callback(err);
|
2650 |
|
2651 | IDBFS.getRemoteSet(mount, function(err, remote) {
|
2652 | if (err) return callback(err);
|
2653 |
|
2654 | var src = populate ? remote : local;
|
2655 | var dst = populate ? local : remote;
|
2656 |
|
2657 | IDBFS.reconcile(src, dst, callback);
|
2658 | });
|
2659 | });
|
2660 | },getDB:function (name, callback) {
|
2661 |
|
2662 | var db = IDBFS.dbs[name];
|
2663 | if (db) {
|
2664 | return callback(null, db);
|
2665 | }
|
2666 |
|
2667 | var req;
|
2668 | try {
|
2669 | req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
|
2670 | } catch (e) {
|
2671 | return callback(e);
|
2672 | }
|
2673 | if (!req) {
|
2674 | return callback("Unable to connect to IndexedDB");
|
2675 | }
|
2676 | req.onupgradeneeded = function(e) {
|
2677 | var db = e.target.result;
|
2678 | var transaction = e.target.transaction;
|
2679 |
|
2680 | var fileStore;
|
2681 |
|
2682 | if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
|
2683 | fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
|
2684 | } else {
|
2685 | fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
|
2686 | }
|
2687 |
|
2688 | if (!fileStore.indexNames.contains('timestamp')) {
|
2689 | fileStore.createIndex('timestamp', 'timestamp', { unique: false });
|
2690 | }
|
2691 | };
|
2692 | req.onsuccess = function() {
|
2693 | db = req.result;
|
2694 |
|
2695 |
|
2696 | IDBFS.dbs[name] = db;
|
2697 | callback(null, db);
|
2698 | };
|
2699 | req.onerror = function(e) {
|
2700 | callback(this.error);
|
2701 | e.preventDefault();
|
2702 | };
|
2703 | },getLocalSet:function (mount, callback) {
|
2704 | var entries = {};
|
2705 |
|
2706 | function isRealDir(p) {
|
2707 | return p !== '.' && p !== '..';
|
2708 | };
|
2709 | function toAbsolute(root) {
|
2710 | return function(p) {
|
2711 | return PATH.join2(root, p);
|
2712 | }
|
2713 | };
|
2714 |
|
2715 | var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
|
2716 |
|
2717 | while (check.length) {
|
2718 | var path = check.pop();
|
2719 | var stat;
|
2720 |
|
2721 | try {
|
2722 | stat = FS.stat(path);
|
2723 | } catch (e) {
|
2724 | return callback(e);
|
2725 | }
|
2726 |
|
2727 | if (FS.isDir(stat.mode)) {
|
2728 | check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
|
2729 | }
|
2730 |
|
2731 | entries[path] = { timestamp: stat.mtime };
|
2732 | }
|
2733 |
|
2734 | return callback(null, { type: 'local', entries: entries });
|
2735 | },getRemoteSet:function (mount, callback) {
|
2736 | var entries = {};
|
2737 |
|
2738 | IDBFS.getDB(mount.mountpoint, function(err, db) {
|
2739 | if (err) return callback(err);
|
2740 |
|
2741 | try {
|
2742 | var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
|
2743 | transaction.onerror = function(e) {
|
2744 | callback(this.error);
|
2745 | e.preventDefault();
|
2746 | };
|
2747 |
|
2748 | var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
|
2749 | var index = store.index('timestamp');
|
2750 |
|
2751 | index.openKeyCursor().onsuccess = function(event) {
|
2752 | var cursor = event.target.result;
|
2753 |
|
2754 | if (!cursor) {
|
2755 | return callback(null, { type: 'remote', db: db, entries: entries });
|
2756 | }
|
2757 |
|
2758 | entries[cursor.primaryKey] = { timestamp: cursor.key };
|
2759 |
|
2760 | cursor.continue();
|
2761 | };
|
2762 | } catch (e) {
|
2763 | return callback(e);
|
2764 | }
|
2765 | });
|
2766 | },loadLocalEntry:function (path, callback) {
|
2767 | var stat, node;
|
2768 |
|
2769 | try {
|
2770 | var lookup = FS.lookupPath(path);
|
2771 | node = lookup.node;
|
2772 | stat = FS.stat(path);
|
2773 | } catch (e) {
|
2774 | return callback(e);
|
2775 | }
|
2776 |
|
2777 | if (FS.isDir(stat.mode)) {
|
2778 | return callback(null, { timestamp: stat.mtime, mode: stat.mode });
|
2779 | } else if (FS.isFile(stat.mode)) {
|
2780 |
|
2781 |
|
2782 | node.contents = MEMFS.getFileDataAsTypedArray(node);
|
2783 | return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
|
2784 | } else {
|
2785 | return callback(new Error('node type not supported'));
|
2786 | }
|
2787 | },storeLocalEntry:function (path, entry, callback) {
|
2788 | try {
|
2789 | if (FS.isDir(entry.mode)) {
|
2790 | FS.mkdir(path, entry.mode);
|
2791 | } else if (FS.isFile(entry.mode)) {
|
2792 | FS.writeFile(path, entry.contents, { canOwn: true });
|
2793 | } else {
|
2794 | return callback(new Error('node type not supported'));
|
2795 | }
|
2796 |
|
2797 | FS.chmod(path, entry.mode);
|
2798 | FS.utime(path, entry.timestamp, entry.timestamp);
|
2799 | } catch (e) {
|
2800 | return callback(e);
|
2801 | }
|
2802 |
|
2803 | callback(null);
|
2804 | },removeLocalEntry:function (path, callback) {
|
2805 | try {
|
2806 | var lookup = FS.lookupPath(path);
|
2807 | var stat = FS.stat(path);
|
2808 |
|
2809 | if (FS.isDir(stat.mode)) {
|
2810 | FS.rmdir(path);
|
2811 | } else if (FS.isFile(stat.mode)) {
|
2812 | FS.unlink(path);
|
2813 | }
|
2814 | } catch (e) {
|
2815 | return callback(e);
|
2816 | }
|
2817 |
|
2818 | callback(null);
|
2819 | },loadRemoteEntry:function (store, path, callback) {
|
2820 | var req = store.get(path);
|
2821 | req.onsuccess = function(event) { callback(null, event.target.result); };
|
2822 | req.onerror = function(e) {
|
2823 | callback(this.error);
|
2824 | e.preventDefault();
|
2825 | };
|
2826 | },storeRemoteEntry:function (store, path, entry, callback) {
|
2827 | var req = store.put(entry, path);
|
2828 | req.onsuccess = function() { callback(null); };
|
2829 | req.onerror = function(e) {
|
2830 | callback(this.error);
|
2831 | e.preventDefault();
|
2832 | };
|
2833 | },removeRemoteEntry:function (store, path, callback) {
|
2834 | var req = store.delete(path);
|
2835 | req.onsuccess = function() { callback(null); };
|
2836 | req.onerror = function(e) {
|
2837 | callback(this.error);
|
2838 | e.preventDefault();
|
2839 | };
|
2840 | },reconcile:function (src, dst, callback) {
|
2841 | var total = 0;
|
2842 |
|
2843 | var create = [];
|
2844 | Object.keys(src.entries).forEach(function (key) {
|
2845 | var e = src.entries[key];
|
2846 | var e2 = dst.entries[key];
|
2847 | if (!e2 || e.timestamp > e2.timestamp) {
|
2848 | create.push(key);
|
2849 | total++;
|
2850 | }
|
2851 | });
|
2852 |
|
2853 | var remove = [];
|
2854 | Object.keys(dst.entries).forEach(function (key) {
|
2855 | var e = dst.entries[key];
|
2856 | var e2 = src.entries[key];
|
2857 | if (!e2) {
|
2858 | remove.push(key);
|
2859 | total++;
|
2860 | }
|
2861 | });
|
2862 |
|
2863 | if (!total) {
|
2864 | return callback(null);
|
2865 | }
|
2866 |
|
2867 | var errored = false;
|
2868 | var completed = 0;
|
2869 | var db = src.type === 'remote' ? src.db : dst.db;
|
2870 | var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
|
2871 | var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
|
2872 |
|
2873 | function done(err) {
|
2874 | if (err) {
|
2875 | if (!done.errored) {
|
2876 | done.errored = true;
|
2877 | return callback(err);
|
2878 | }
|
2879 | return;
|
2880 | }
|
2881 | if (++completed >= total) {
|
2882 | return callback(null);
|
2883 | }
|
2884 | };
|
2885 |
|
2886 | transaction.onerror = function(e) {
|
2887 | done(this.error);
|
2888 | e.preventDefault();
|
2889 | };
|
2890 |
|
2891 |
|
2892 |
|
2893 | create.sort().forEach(function (path) {
|
2894 | if (dst.type === 'local') {
|
2895 | IDBFS.loadRemoteEntry(store, path, function (err, entry) {
|
2896 | if (err) return done(err);
|
2897 | IDBFS.storeLocalEntry(path, entry, done);
|
2898 | });
|
2899 | } else {
|
2900 | IDBFS.loadLocalEntry(path, function (err, entry) {
|
2901 | if (err) return done(err);
|
2902 | IDBFS.storeRemoteEntry(store, path, entry, done);
|
2903 | });
|
2904 | }
|
2905 | });
|
2906 |
|
2907 |
|
2908 |
|
2909 | remove.sort().reverse().forEach(function(path) {
|
2910 | if (dst.type === 'local') {
|
2911 | IDBFS.removeLocalEntry(path, done);
|
2912 | } else {
|
2913 | IDBFS.removeRemoteEntry(store, path, done);
|
2914 | }
|
2915 | });
|
2916 | }};
|
2917 |
|
2918 | var NODEFS={isWindows:false,staticInit:function () {
|
2919 | NODEFS.isWindows = !!process.platform.match(/^win/);
|
2920 | var flags = process["binding"]("constants");
|
2921 |
|
2922 | if (flags["fs"]) {
|
2923 | flags = flags["fs"];
|
2924 | }
|
2925 | NODEFS.flagsForNodeMap = {
|
2926 | "1024": flags["O_APPEND"],
|
2927 | "64": flags["O_CREAT"],
|
2928 | "128": flags["O_EXCL"],
|
2929 | "0": flags["O_RDONLY"],
|
2930 | "2": flags["O_RDWR"],
|
2931 | "4096": flags["O_SYNC"],
|
2932 | "512": flags["O_TRUNC"],
|
2933 | "1": flags["O_WRONLY"]
|
2934 | };
|
2935 | },bufferFrom:function (arrayBuffer) {
|
2936 |
|
2937 |
|
2938 |
|
2939 | return Buffer.alloc ? Buffer.from(arrayBuffer) : new Buffer(arrayBuffer);
|
2940 | },mount:function (mount) {
|
2941 | assert(ENVIRONMENT_IS_NODE);
|
2942 | return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
|
2943 | },createNode:function (parent, name, mode, dev) {
|
2944 | if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
|
2945 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
2946 | }
|
2947 | var node = FS.createNode(parent, name, mode);
|
2948 | node.node_ops = NODEFS.node_ops;
|
2949 | node.stream_ops = NODEFS.stream_ops;
|
2950 | return node;
|
2951 | },getMode:function (path) {
|
2952 | var stat;
|
2953 | try {
|
2954 | stat = fs.lstatSync(path);
|
2955 | if (NODEFS.isWindows) {
|
2956 |
|
2957 |
|
2958 | stat.mode = stat.mode | ((stat.mode & 292) >> 2);
|
2959 | }
|
2960 | } catch (e) {
|
2961 | if (!e.code) throw e;
|
2962 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
2963 | }
|
2964 | return stat.mode;
|
2965 | },realPath:function (node) {
|
2966 | var parts = [];
|
2967 | while (node.parent !== node) {
|
2968 | parts.push(node.name);
|
2969 | node = node.parent;
|
2970 | }
|
2971 | parts.push(node.mount.opts.root);
|
2972 | parts.reverse();
|
2973 | return PATH.join.apply(null, parts);
|
2974 | },flagsForNode:function (flags) {
|
2975 | flags &= ~0x200000 ;
|
2976 | flags &= ~0x800 ;
|
2977 | flags &= ~0x8000 ;
|
2978 | flags &= ~0x80000 ;
|
2979 | var newFlags = 0;
|
2980 | for (var k in NODEFS.flagsForNodeMap) {
|
2981 | if (flags & k) {
|
2982 | newFlags |= NODEFS.flagsForNodeMap[k];
|
2983 | flags ^= k;
|
2984 | }
|
2985 | }
|
2986 |
|
2987 | if (!flags) {
|
2988 | return newFlags;
|
2989 | } else {
|
2990 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
2991 | }
|
2992 | },node_ops:{getattr:function (node) {
|
2993 | var path = NODEFS.realPath(node);
|
2994 | var stat;
|
2995 | try {
|
2996 | stat = fs.lstatSync(path);
|
2997 | } catch (e) {
|
2998 | if (!e.code) throw e;
|
2999 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3000 | }
|
3001 |
|
3002 |
|
3003 | if (NODEFS.isWindows && !stat.blksize) {
|
3004 | stat.blksize = 4096;
|
3005 | }
|
3006 | if (NODEFS.isWindows && !stat.blocks) {
|
3007 | stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
|
3008 | }
|
3009 | return {
|
3010 | dev: stat.dev,
|
3011 | ino: stat.ino,
|
3012 | mode: stat.mode,
|
3013 | nlink: stat.nlink,
|
3014 | uid: stat.uid,
|
3015 | gid: stat.gid,
|
3016 | rdev: stat.rdev,
|
3017 | size: stat.size,
|
3018 | atime: stat.atime,
|
3019 | mtime: stat.mtime,
|
3020 | ctime: stat.ctime,
|
3021 | blksize: stat.blksize,
|
3022 | blocks: stat.blocks
|
3023 | };
|
3024 | },setattr:function (node, attr) {
|
3025 | var path = NODEFS.realPath(node);
|
3026 | try {
|
3027 | if (attr.mode !== undefined) {
|
3028 | fs.chmodSync(path, attr.mode);
|
3029 |
|
3030 | node.mode = attr.mode;
|
3031 | }
|
3032 | if (attr.timestamp !== undefined) {
|
3033 | var date = new Date(attr.timestamp);
|
3034 | fs.utimesSync(path, date, date);
|
3035 | }
|
3036 | if (attr.size !== undefined) {
|
3037 | fs.truncateSync(path, attr.size);
|
3038 | }
|
3039 | } catch (e) {
|
3040 | if (!e.code) throw e;
|
3041 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3042 | }
|
3043 | },lookup:function (parent, name) {
|
3044 | var path = PATH.join2(NODEFS.realPath(parent), name);
|
3045 | var mode = NODEFS.getMode(path);
|
3046 | return NODEFS.createNode(parent, name, mode);
|
3047 | },mknod:function (parent, name, mode, dev) {
|
3048 | var node = NODEFS.createNode(parent, name, mode, dev);
|
3049 |
|
3050 | var path = NODEFS.realPath(node);
|
3051 | try {
|
3052 | if (FS.isDir(node.mode)) {
|
3053 | fs.mkdirSync(path, node.mode);
|
3054 | } else {
|
3055 | fs.writeFileSync(path, '', { mode: node.mode });
|
3056 | }
|
3057 | } catch (e) {
|
3058 | if (!e.code) throw e;
|
3059 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3060 | }
|
3061 | return node;
|
3062 | },rename:function (oldNode, newDir, newName) {
|
3063 | var oldPath = NODEFS.realPath(oldNode);
|
3064 | var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
|
3065 | try {
|
3066 | fs.renameSync(oldPath, newPath);
|
3067 | } catch (e) {
|
3068 | if (!e.code) throw e;
|
3069 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3070 | }
|
3071 | },unlink:function (parent, name) {
|
3072 | var path = PATH.join2(NODEFS.realPath(parent), name);
|
3073 | try {
|
3074 | fs.unlinkSync(path);
|
3075 | } catch (e) {
|
3076 | if (!e.code) throw e;
|
3077 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3078 | }
|
3079 | },rmdir:function (parent, name) {
|
3080 | var path = PATH.join2(NODEFS.realPath(parent), name);
|
3081 | try {
|
3082 | fs.rmdirSync(path);
|
3083 | } catch (e) {
|
3084 | if (!e.code) throw e;
|
3085 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3086 | }
|
3087 | },readdir:function (node) {
|
3088 | var path = NODEFS.realPath(node);
|
3089 | try {
|
3090 | return fs.readdirSync(path);
|
3091 | } catch (e) {
|
3092 | if (!e.code) throw e;
|
3093 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3094 | }
|
3095 | },symlink:function (parent, newName, oldPath) {
|
3096 | var newPath = PATH.join2(NODEFS.realPath(parent), newName);
|
3097 | try {
|
3098 | fs.symlinkSync(oldPath, newPath);
|
3099 | } catch (e) {
|
3100 | if (!e.code) throw e;
|
3101 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3102 | }
|
3103 | },readlink:function (node) {
|
3104 | var path = NODEFS.realPath(node);
|
3105 | try {
|
3106 | path = fs.readlinkSync(path);
|
3107 | path = NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root), path);
|
3108 | return path;
|
3109 | } catch (e) {
|
3110 | if (!e.code) throw e;
|
3111 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3112 | }
|
3113 | }},stream_ops:{open:function (stream) {
|
3114 | var path = NODEFS.realPath(stream.node);
|
3115 | try {
|
3116 | if (FS.isFile(stream.node.mode)) {
|
3117 | stream.nfd = fs.openSync(path, NODEFS.flagsForNode(stream.flags));
|
3118 | }
|
3119 | } catch (e) {
|
3120 | if (!e.code) throw e;
|
3121 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3122 | }
|
3123 | },close:function (stream) {
|
3124 | try {
|
3125 | if (FS.isFile(stream.node.mode) && stream.nfd) {
|
3126 | fs.closeSync(stream.nfd);
|
3127 | }
|
3128 | } catch (e) {
|
3129 | if (!e.code) throw e;
|
3130 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3131 | }
|
3132 | },read:function (stream, buffer, offset, length, position) {
|
3133 |
|
3134 | if (length === 0) return 0;
|
3135 | try {
|
3136 | return fs.readSync(stream.nfd, NODEFS.bufferFrom(buffer.buffer), offset, length, position);
|
3137 | } catch (e) {
|
3138 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3139 | }
|
3140 | },write:function (stream, buffer, offset, length, position) {
|
3141 | try {
|
3142 | return fs.writeSync(stream.nfd, NODEFS.bufferFrom(buffer.buffer), offset, length, position);
|
3143 | } catch (e) {
|
3144 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3145 | }
|
3146 | },llseek:function (stream, offset, whence) {
|
3147 | var position = offset;
|
3148 | if (whence === 1) {
|
3149 | position += stream.position;
|
3150 | } else if (whence === 2) {
|
3151 | if (FS.isFile(stream.node.mode)) {
|
3152 | try {
|
3153 | var stat = fs.fstatSync(stream.nfd);
|
3154 | position += stat.size;
|
3155 | } catch (e) {
|
3156 | throw new FS.ErrnoError(ERRNO_CODES[e.code]);
|
3157 | }
|
3158 | }
|
3159 | }
|
3160 |
|
3161 | if (position < 0) {
|
3162 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
3163 | }
|
3164 |
|
3165 | return position;
|
3166 | }}};
|
3167 |
|
3168 | var WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:function (mount) {
|
3169 | assert(ENVIRONMENT_IS_WORKER);
|
3170 | if (!WORKERFS.reader) WORKERFS.reader = new FileReaderSync();
|
3171 | var root = WORKERFS.createNode(null, '/', WORKERFS.DIR_MODE, 0);
|
3172 | var createdParents = {};
|
3173 | function ensureParent(path) {
|
3174 |
|
3175 | var parts = path.split('/');
|
3176 | var parent = root;
|
3177 | for (var i = 0; i < parts.length-1; i++) {
|
3178 | var curr = parts.slice(0, i+1).join('/');
|
3179 |
|
3180 |
|
3181 |
|
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 | if (!createdParents[curr]) {
|
3187 | createdParents[curr] = WORKERFS.createNode(parent, parts[i], WORKERFS.DIR_MODE, 0);
|
3188 | }
|
3189 | parent = createdParents[curr];
|
3190 | }
|
3191 | return parent;
|
3192 | }
|
3193 | function base(path) {
|
3194 | var parts = path.split('/');
|
3195 | return parts[parts.length-1];
|
3196 | }
|
3197 |
|
3198 | Array.prototype.forEach.call(mount.opts["files"] || [], function(file) {
|
3199 | WORKERFS.createNode(ensureParent(file.name), base(file.name), WORKERFS.FILE_MODE, 0, file, file.lastModifiedDate);
|
3200 | });
|
3201 | (mount.opts["blobs"] || []).forEach(function(obj) {
|
3202 | WORKERFS.createNode(ensureParent(obj["name"]), base(obj["name"]), WORKERFS.FILE_MODE, 0, obj["data"]);
|
3203 | });
|
3204 | (mount.opts["packages"] || []).forEach(function(pack) {
|
3205 | pack['metadata'].files.forEach(function(file) {
|
3206 | var name = file.filename.substr(1);
|
3207 | WORKERFS.createNode(ensureParent(name), base(name), WORKERFS.FILE_MODE, 0, pack['blob'].slice(file.start, file.end));
|
3208 | });
|
3209 | });
|
3210 | return root;
|
3211 | },createNode:function (parent, name, mode, dev, contents, mtime) {
|
3212 | var node = FS.createNode(parent, name, mode);
|
3213 | node.mode = mode;
|
3214 | node.node_ops = WORKERFS.node_ops;
|
3215 | node.stream_ops = WORKERFS.stream_ops;
|
3216 | node.timestamp = (mtime || new Date).getTime();
|
3217 | assert(WORKERFS.FILE_MODE !== WORKERFS.DIR_MODE);
|
3218 | if (mode === WORKERFS.FILE_MODE) {
|
3219 | node.size = contents.size;
|
3220 | node.contents = contents;
|
3221 | } else {
|
3222 | node.size = 4096;
|
3223 | node.contents = {};
|
3224 | }
|
3225 | if (parent) {
|
3226 | parent.contents[name] = node;
|
3227 | }
|
3228 | return node;
|
3229 | },node_ops:{getattr:function (node) {
|
3230 | return {
|
3231 | dev: 1,
|
3232 | ino: undefined,
|
3233 | mode: node.mode,
|
3234 | nlink: 1,
|
3235 | uid: 0,
|
3236 | gid: 0,
|
3237 | rdev: undefined,
|
3238 | size: node.size,
|
3239 | atime: new Date(node.timestamp),
|
3240 | mtime: new Date(node.timestamp),
|
3241 | ctime: new Date(node.timestamp),
|
3242 | blksize: 4096,
|
3243 | blocks: Math.ceil(node.size / 4096),
|
3244 | };
|
3245 | },setattr:function (node, attr) {
|
3246 | if (attr.mode !== undefined) {
|
3247 | node.mode = attr.mode;
|
3248 | }
|
3249 | if (attr.timestamp !== undefined) {
|
3250 | node.timestamp = attr.timestamp;
|
3251 | }
|
3252 | },lookup:function (parent, name) {
|
3253 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
3254 | },mknod:function (parent, name, mode, dev) {
|
3255 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3256 | },rename:function (oldNode, newDir, newName) {
|
3257 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3258 | },unlink:function (parent, name) {
|
3259 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3260 | },rmdir:function (parent, name) {
|
3261 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3262 | },readdir:function (node) {
|
3263 | var entries = ['.', '..'];
|
3264 | for (var key in node.contents) {
|
3265 | if (!node.contents.hasOwnProperty(key)) {
|
3266 | continue;
|
3267 | }
|
3268 | entries.push(key);
|
3269 | }
|
3270 | return entries;
|
3271 | },symlink:function (parent, newName, oldPath) {
|
3272 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3273 | },readlink:function (node) {
|
3274 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3275 | }},stream_ops:{read:function (stream, buffer, offset, length, position) {
|
3276 | if (position >= stream.node.size) return 0;
|
3277 | var chunk = stream.node.contents.slice(position, position + length);
|
3278 | var ab = WORKERFS.reader.readAsArrayBuffer(chunk);
|
3279 | buffer.set(new Uint8Array(ab), offset);
|
3280 | return chunk.size;
|
3281 | },write:function (stream, buffer, offset, length, position) {
|
3282 | throw new FS.ErrnoError(ERRNO_CODES.EIO);
|
3283 | },llseek:function (stream, offset, whence) {
|
3284 | var position = offset;
|
3285 | if (whence === 1) {
|
3286 | position += stream.position;
|
3287 | } else if (whence === 2) {
|
3288 | if (FS.isFile(stream.node.mode)) {
|
3289 | position += stream.node.size;
|
3290 | }
|
3291 | }
|
3292 | if (position < 0) {
|
3293 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
3294 | }
|
3295 | return position;
|
3296 | }}};
|
3297 |
|
3298 | var _stdin=STATICTOP; STATICTOP += 16;;
|
3299 |
|
3300 | var _stdout=STATICTOP; STATICTOP += 16;;
|
3301 |
|
3302 | var _stderr=STATICTOP; STATICTOP += 16;;var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function (e) {
|
3303 | if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
|
3304 | return ___setErrNo(e.errno);
|
3305 | },lookupPath:function (path, opts) {
|
3306 | path = PATH.resolve(FS.cwd(), path);
|
3307 | opts = opts || {};
|
3308 |
|
3309 | if (!path) return { path: '', node: null };
|
3310 |
|
3311 | var defaults = {
|
3312 | follow_mount: true,
|
3313 | recurse_count: 0
|
3314 | };
|
3315 | for (var key in defaults) {
|
3316 | if (opts[key] === undefined) {
|
3317 | opts[key] = defaults[key];
|
3318 | }
|
3319 | }
|
3320 |
|
3321 | if (opts.recurse_count > 8) {
|
3322 | throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
|
3323 | }
|
3324 |
|
3325 |
|
3326 | var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
|
3327 | return !!p;
|
3328 | }), false);
|
3329 |
|
3330 |
|
3331 | var current = FS.root;
|
3332 | var current_path = '/';
|
3333 |
|
3334 | for (var i = 0; i < parts.length; i++) {
|
3335 | var islast = (i === parts.length-1);
|
3336 | if (islast && opts.parent) {
|
3337 |
|
3338 | break;
|
3339 | }
|
3340 |
|
3341 | current = FS.lookupNode(current, parts[i]);
|
3342 | current_path = PATH.join2(current_path, parts[i]);
|
3343 |
|
3344 |
|
3345 | if (FS.isMountpoint(current)) {
|
3346 | if (!islast || (islast && opts.follow_mount)) {
|
3347 | current = current.mounted.root;
|
3348 | }
|
3349 | }
|
3350 |
|
3351 |
|
3352 |
|
3353 | if (!islast || opts.follow) {
|
3354 | var count = 0;
|
3355 | while (FS.isLink(current.mode)) {
|
3356 | var link = FS.readlink(current_path);
|
3357 | current_path = PATH.resolve(PATH.dirname(current_path), link);
|
3358 |
|
3359 | var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
|
3360 | current = lookup.node;
|
3361 |
|
3362 | if (count++ > 40) {
|
3363 | throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
|
3364 | }
|
3365 | }
|
3366 | }
|
3367 | }
|
3368 |
|
3369 | return { path: current_path, node: current };
|
3370 | },getPath:function (node) {
|
3371 | var path;
|
3372 | while (true) {
|
3373 | if (FS.isRoot(node)) {
|
3374 | var mount = node.mount.mountpoint;
|
3375 | if (!path) return mount;
|
3376 | return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
|
3377 | }
|
3378 | path = path ? node.name + '/' + path : node.name;
|
3379 | node = node.parent;
|
3380 | }
|
3381 | },hashName:function (parentid, name) {
|
3382 | var hash = 0;
|
3383 |
|
3384 |
|
3385 | for (var i = 0; i < name.length; i++) {
|
3386 | hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
|
3387 | }
|
3388 | return ((parentid + hash) >>> 0) % FS.nameTable.length;
|
3389 | },hashAddNode:function (node) {
|
3390 | var hash = FS.hashName(node.parent.id, node.name);
|
3391 | node.name_next = FS.nameTable[hash];
|
3392 | FS.nameTable[hash] = node;
|
3393 | },hashRemoveNode:function (node) {
|
3394 | var hash = FS.hashName(node.parent.id, node.name);
|
3395 | if (FS.nameTable[hash] === node) {
|
3396 | FS.nameTable[hash] = node.name_next;
|
3397 | } else {
|
3398 | var current = FS.nameTable[hash];
|
3399 | while (current) {
|
3400 | if (current.name_next === node) {
|
3401 | current.name_next = node.name_next;
|
3402 | break;
|
3403 | }
|
3404 | current = current.name_next;
|
3405 | }
|
3406 | }
|
3407 | },lookupNode:function (parent, name) {
|
3408 | var err = FS.mayLookup(parent);
|
3409 | if (err) {
|
3410 | throw new FS.ErrnoError(err, parent);
|
3411 | }
|
3412 | var hash = FS.hashName(parent.id, name);
|
3413 | for (var node = FS.nameTable[hash]; node; node = node.name_next) {
|
3414 | var nodeName = node.name;
|
3415 | if (node.parent.id === parent.id && nodeName === name) {
|
3416 | return node;
|
3417 | }
|
3418 | }
|
3419 |
|
3420 | return FS.lookup(parent, name);
|
3421 | },createNode:function (parent, name, mode, rdev) {
|
3422 | if (!FS.FSNode) {
|
3423 | FS.FSNode = function(parent, name, mode, rdev) {
|
3424 | if (!parent) {
|
3425 | parent = this;
|
3426 | }
|
3427 | this.parent = parent;
|
3428 | this.mount = parent.mount;
|
3429 | this.mounted = null;
|
3430 | this.id = FS.nextInode++;
|
3431 | this.name = name;
|
3432 | this.mode = mode;
|
3433 | this.node_ops = {};
|
3434 | this.stream_ops = {};
|
3435 | this.rdev = rdev;
|
3436 | };
|
3437 |
|
3438 | FS.FSNode.prototype = {};
|
3439 |
|
3440 |
|
3441 | var readMode = 292 | 73;
|
3442 | var writeMode = 146;
|
3443 |
|
3444 |
|
3445 |
|
3446 | Object.defineProperties(FS.FSNode.prototype, {
|
3447 | read: {
|
3448 | get: function() { return (this.mode & readMode) === readMode; },
|
3449 | set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
|
3450 | },
|
3451 | write: {
|
3452 | get: function() { return (this.mode & writeMode) === writeMode; },
|
3453 | set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
|
3454 | },
|
3455 | isFolder: {
|
3456 | get: function() { return FS.isDir(this.mode); }
|
3457 | },
|
3458 | isDevice: {
|
3459 | get: function() { return FS.isChrdev(this.mode); }
|
3460 | }
|
3461 | });
|
3462 | }
|
3463 |
|
3464 | var node = new FS.FSNode(parent, name, mode, rdev);
|
3465 |
|
3466 | FS.hashAddNode(node);
|
3467 |
|
3468 | return node;
|
3469 | },destroyNode:function (node) {
|
3470 | FS.hashRemoveNode(node);
|
3471 | },isRoot:function (node) {
|
3472 | return node === node.parent;
|
3473 | },isMountpoint:function (node) {
|
3474 | return !!node.mounted;
|
3475 | },isFile:function (mode) {
|
3476 | return (mode & 61440) === 32768;
|
3477 | },isDir:function (mode) {
|
3478 | return (mode & 61440) === 16384;
|
3479 | },isLink:function (mode) {
|
3480 | return (mode & 61440) === 40960;
|
3481 | },isChrdev:function (mode) {
|
3482 | return (mode & 61440) === 8192;
|
3483 | },isBlkdev:function (mode) {
|
3484 | return (mode & 61440) === 24576;
|
3485 | },isFIFO:function (mode) {
|
3486 | return (mode & 61440) === 4096;
|
3487 | },isSocket:function (mode) {
|
3488 | return (mode & 49152) === 49152;
|
3489 | },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
|
3490 | var flags = FS.flagModes[str];
|
3491 | if (typeof flags === 'undefined') {
|
3492 | throw new Error('Unknown file open mode: ' + str);
|
3493 | }
|
3494 | return flags;
|
3495 | },flagsToPermissionString:function (flag) {
|
3496 | var perms = ['r', 'w', 'rw'][flag & 3];
|
3497 | if ((flag & 512)) {
|
3498 | perms += 'w';
|
3499 | }
|
3500 | return perms;
|
3501 | },nodePermissions:function (node, perms) {
|
3502 | if (FS.ignorePermissions) {
|
3503 | return 0;
|
3504 | }
|
3505 |
|
3506 | if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
|
3507 | return ERRNO_CODES.EACCES;
|
3508 | } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
|
3509 | return ERRNO_CODES.EACCES;
|
3510 | } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
|
3511 | return ERRNO_CODES.EACCES;
|
3512 | }
|
3513 | return 0;
|
3514 | },mayLookup:function (dir) {
|
3515 | var err = FS.nodePermissions(dir, 'x');
|
3516 | if (err) return err;
|
3517 | if (!dir.node_ops.lookup) return ERRNO_CODES.EACCES;
|
3518 | return 0;
|
3519 | },mayCreate:function (dir, name) {
|
3520 | try {
|
3521 | var node = FS.lookupNode(dir, name);
|
3522 | return ERRNO_CODES.EEXIST;
|
3523 | } catch (e) {
|
3524 | }
|
3525 | return FS.nodePermissions(dir, 'wx');
|
3526 | },mayDelete:function (dir, name, isdir) {
|
3527 | var node;
|
3528 | try {
|
3529 | node = FS.lookupNode(dir, name);
|
3530 | } catch (e) {
|
3531 | return e.errno;
|
3532 | }
|
3533 | var err = FS.nodePermissions(dir, 'wx');
|
3534 | if (err) {
|
3535 | return err;
|
3536 | }
|
3537 | if (isdir) {
|
3538 | if (!FS.isDir(node.mode)) {
|
3539 | return ERRNO_CODES.ENOTDIR;
|
3540 | }
|
3541 | if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
|
3542 | return ERRNO_CODES.EBUSY;
|
3543 | }
|
3544 | } else {
|
3545 | if (FS.isDir(node.mode)) {
|
3546 | return ERRNO_CODES.EISDIR;
|
3547 | }
|
3548 | }
|
3549 | return 0;
|
3550 | },mayOpen:function (node, flags) {
|
3551 | if (!node) {
|
3552 | return ERRNO_CODES.ENOENT;
|
3553 | }
|
3554 | if (FS.isLink(node.mode)) {
|
3555 | return ERRNO_CODES.ELOOP;
|
3556 | } else if (FS.isDir(node.mode)) {
|
3557 | if (FS.flagsToPermissionString(flags) !== 'r' ||
|
3558 | (flags & 512)) {
|
3559 | return ERRNO_CODES.EISDIR;
|
3560 | }
|
3561 | }
|
3562 | return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
|
3563 | },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
|
3564 | fd_start = fd_start || 0;
|
3565 | fd_end = fd_end || FS.MAX_OPEN_FDS;
|
3566 | for (var fd = fd_start; fd <= fd_end; fd++) {
|
3567 | if (!FS.streams[fd]) {
|
3568 | return fd;
|
3569 | }
|
3570 | }
|
3571 | throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
|
3572 | },getStream:function (fd) {
|
3573 | return FS.streams[fd];
|
3574 | },createStream:function (stream, fd_start, fd_end) {
|
3575 | if (!FS.FSStream) {
|
3576 | FS.FSStream = function(){};
|
3577 | FS.FSStream.prototype = {};
|
3578 |
|
3579 | Object.defineProperties(FS.FSStream.prototype, {
|
3580 | object: {
|
3581 | get: function() { return this.node; },
|
3582 | set: function(val) { this.node = val; }
|
3583 | },
|
3584 | isRead: {
|
3585 | get: function() { return (this.flags & 2097155) !== 1; }
|
3586 | },
|
3587 | isWrite: {
|
3588 | get: function() { return (this.flags & 2097155) !== 0; }
|
3589 | },
|
3590 | isAppend: {
|
3591 | get: function() { return (this.flags & 1024); }
|
3592 | }
|
3593 | });
|
3594 | }
|
3595 |
|
3596 | var newStream = new FS.FSStream();
|
3597 | for (var p in stream) {
|
3598 | newStream[p] = stream[p];
|
3599 | }
|
3600 | stream = newStream;
|
3601 | var fd = FS.nextfd(fd_start, fd_end);
|
3602 | stream.fd = fd;
|
3603 | FS.streams[fd] = stream;
|
3604 | return stream;
|
3605 | },closeStream:function (fd) {
|
3606 | FS.streams[fd] = null;
|
3607 | },chrdev_stream_ops:{open:function (stream) {
|
3608 | var device = FS.getDevice(stream.node.rdev);
|
3609 |
|
3610 | stream.stream_ops = device.stream_ops;
|
3611 |
|
3612 | if (stream.stream_ops.open) {
|
3613 | stream.stream_ops.open(stream);
|
3614 | }
|
3615 | },llseek:function () {
|
3616 | throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
|
3617 | }},major:function (dev) {
|
3618 | return ((dev) >> 8);
|
3619 | },minor:function (dev) {
|
3620 | return ((dev) & 0xff);
|
3621 | },makedev:function (ma, mi) {
|
3622 | return ((ma) << 8 | (mi));
|
3623 | },registerDevice:function (dev, ops) {
|
3624 | FS.devices[dev] = { stream_ops: ops };
|
3625 | },getDevice:function (dev) {
|
3626 | return FS.devices[dev];
|
3627 | },getMounts:function (mount) {
|
3628 | var mounts = [];
|
3629 | var check = [mount];
|
3630 |
|
3631 | while (check.length) {
|
3632 | var m = check.pop();
|
3633 |
|
3634 | mounts.push(m);
|
3635 |
|
3636 | check.push.apply(check, m.mounts);
|
3637 | }
|
3638 |
|
3639 | return mounts;
|
3640 | },syncfs:function (populate, callback) {
|
3641 | if (typeof(populate) === 'function') {
|
3642 | callback = populate;
|
3643 | populate = false;
|
3644 | }
|
3645 |
|
3646 | FS.syncFSRequests++;
|
3647 |
|
3648 | if (FS.syncFSRequests > 1) {
|
3649 | console.log('warning: ' + FS.syncFSRequests + ' FS.syncfs operations in flight at once, probably just doing extra work');
|
3650 | }
|
3651 |
|
3652 | var mounts = FS.getMounts(FS.root.mount);
|
3653 | var completed = 0;
|
3654 |
|
3655 | function doCallback(err) {
|
3656 | assert(FS.syncFSRequests > 0);
|
3657 | FS.syncFSRequests--;
|
3658 | return callback(err);
|
3659 | }
|
3660 |
|
3661 | function done(err) {
|
3662 | if (err) {
|
3663 | if (!done.errored) {
|
3664 | done.errored = true;
|
3665 | return doCallback(err);
|
3666 | }
|
3667 | return;
|
3668 | }
|
3669 | if (++completed >= mounts.length) {
|
3670 | doCallback(null);
|
3671 | }
|
3672 | };
|
3673 |
|
3674 |
|
3675 | mounts.forEach(function (mount) {
|
3676 | if (!mount.type.syncfs) {
|
3677 | return done(null);
|
3678 | }
|
3679 | mount.type.syncfs(mount, populate, done);
|
3680 | });
|
3681 | },mount:function (type, opts, mountpoint) {
|
3682 | var root = mountpoint === '/';
|
3683 | var pseudo = !mountpoint;
|
3684 | var node;
|
3685 |
|
3686 | if (root && FS.root) {
|
3687 | throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
|
3688 | } else if (!root && !pseudo) {
|
3689 | var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
|
3690 |
|
3691 | mountpoint = lookup.path;
|
3692 | node = lookup.node;
|
3693 |
|
3694 | if (FS.isMountpoint(node)) {
|
3695 | throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
|
3696 | }
|
3697 |
|
3698 | if (!FS.isDir(node.mode)) {
|
3699 | throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
|
3700 | }
|
3701 | }
|
3702 |
|
3703 | var mount = {
|
3704 | type: type,
|
3705 | opts: opts,
|
3706 | mountpoint: mountpoint,
|
3707 | mounts: []
|
3708 | };
|
3709 |
|
3710 |
|
3711 | var mountRoot = type.mount(mount);
|
3712 | mountRoot.mount = mount;
|
3713 | mount.root = mountRoot;
|
3714 |
|
3715 | if (root) {
|
3716 | FS.root = mountRoot;
|
3717 | } else if (node) {
|
3718 |
|
3719 | node.mounted = mount;
|
3720 |
|
3721 |
|
3722 | if (node.mount) {
|
3723 | node.mount.mounts.push(mount);
|
3724 | }
|
3725 | }
|
3726 |
|
3727 | return mountRoot;
|
3728 | },unmount:function (mountpoint) {
|
3729 | var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
|
3730 |
|
3731 | if (!FS.isMountpoint(lookup.node)) {
|
3732 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
3733 | }
|
3734 |
|
3735 |
|
3736 | var node = lookup.node;
|
3737 | var mount = node.mounted;
|
3738 | var mounts = FS.getMounts(mount);
|
3739 |
|
3740 | Object.keys(FS.nameTable).forEach(function (hash) {
|
3741 | var current = FS.nameTable[hash];
|
3742 |
|
3743 | while (current) {
|
3744 | var next = current.name_next;
|
3745 |
|
3746 | if (mounts.indexOf(current.mount) !== -1) {
|
3747 | FS.destroyNode(current);
|
3748 | }
|
3749 |
|
3750 | current = next;
|
3751 | }
|
3752 | });
|
3753 |
|
3754 |
|
3755 | node.mounted = null;
|
3756 |
|
3757 |
|
3758 | var idx = node.mount.mounts.indexOf(mount);
|
3759 | assert(idx !== -1);
|
3760 | node.mount.mounts.splice(idx, 1);
|
3761 | },lookup:function (parent, name) {
|
3762 | return parent.node_ops.lookup(parent, name);
|
3763 | },mknod:function (path, mode, dev) {
|
3764 | var lookup = FS.lookupPath(path, { parent: true });
|
3765 | var parent = lookup.node;
|
3766 | var name = PATH.basename(path);
|
3767 | if (!name || name === '.' || name === '..') {
|
3768 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
3769 | }
|
3770 | var err = FS.mayCreate(parent, name);
|
3771 | if (err) {
|
3772 | throw new FS.ErrnoError(err);
|
3773 | }
|
3774 | if (!parent.node_ops.mknod) {
|
3775 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3776 | }
|
3777 | return parent.node_ops.mknod(parent, name, mode, dev);
|
3778 | },create:function (path, mode) {
|
3779 | mode = mode !== undefined ? mode : 438 ;
|
3780 | mode &= 4095;
|
3781 | mode |= 32768;
|
3782 | return FS.mknod(path, mode, 0);
|
3783 | },mkdir:function (path, mode) {
|
3784 | mode = mode !== undefined ? mode : 511 ;
|
3785 | mode &= 511 | 512;
|
3786 | mode |= 16384;
|
3787 | return FS.mknod(path, mode, 0);
|
3788 | },mkdirTree:function (path, mode) {
|
3789 | var dirs = path.split('/');
|
3790 | var d = '';
|
3791 | for (var i = 0; i < dirs.length; ++i) {
|
3792 | if (!dirs[i]) continue;
|
3793 | d += '/' + dirs[i];
|
3794 | try {
|
3795 | FS.mkdir(d, mode);
|
3796 | } catch(e) {
|
3797 | if (e.errno != ERRNO_CODES.EEXIST) throw e;
|
3798 | }
|
3799 | }
|
3800 | },mkdev:function (path, mode, dev) {
|
3801 | if (typeof(dev) === 'undefined') {
|
3802 | dev = mode;
|
3803 | mode = 438 ;
|
3804 | }
|
3805 | mode |= 8192;
|
3806 | return FS.mknod(path, mode, dev);
|
3807 | },symlink:function (oldpath, newpath) {
|
3808 | if (!PATH.resolve(oldpath)) {
|
3809 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
3810 | }
|
3811 | var lookup = FS.lookupPath(newpath, { parent: true });
|
3812 | var parent = lookup.node;
|
3813 | if (!parent) {
|
3814 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
3815 | }
|
3816 | var newname = PATH.basename(newpath);
|
3817 | var err = FS.mayCreate(parent, newname);
|
3818 | if (err) {
|
3819 | throw new FS.ErrnoError(err);
|
3820 | }
|
3821 | if (!parent.node_ops.symlink) {
|
3822 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3823 | }
|
3824 | return parent.node_ops.symlink(parent, newname, oldpath);
|
3825 | },rename:function (old_path, new_path) {
|
3826 | var old_dirname = PATH.dirname(old_path);
|
3827 | var new_dirname = PATH.dirname(new_path);
|
3828 | var old_name = PATH.basename(old_path);
|
3829 | var new_name = PATH.basename(new_path);
|
3830 |
|
3831 | var lookup, old_dir, new_dir;
|
3832 | try {
|
3833 | lookup = FS.lookupPath(old_path, { parent: true });
|
3834 | old_dir = lookup.node;
|
3835 | lookup = FS.lookupPath(new_path, { parent: true });
|
3836 | new_dir = lookup.node;
|
3837 | } catch (e) {
|
3838 | throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
|
3839 | }
|
3840 | if (!old_dir || !new_dir) throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
3841 |
|
3842 | if (old_dir.mount !== new_dir.mount) {
|
3843 | throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
|
3844 | }
|
3845 |
|
3846 | var old_node = FS.lookupNode(old_dir, old_name);
|
3847 |
|
3848 | var relative = PATH.relative(old_path, new_dirname);
|
3849 | if (relative.charAt(0) !== '.') {
|
3850 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
3851 | }
|
3852 |
|
3853 | relative = PATH.relative(new_path, old_dirname);
|
3854 | if (relative.charAt(0) !== '.') {
|
3855 | throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
|
3856 | }
|
3857 |
|
3858 | var new_node;
|
3859 | try {
|
3860 | new_node = FS.lookupNode(new_dir, new_name);
|
3861 | } catch (e) {
|
3862 |
|
3863 | }
|
3864 |
|
3865 | if (old_node === new_node) {
|
3866 | return;
|
3867 | }
|
3868 |
|
3869 | var isdir = FS.isDir(old_node.mode);
|
3870 | var err = FS.mayDelete(old_dir, old_name, isdir);
|
3871 | if (err) {
|
3872 | throw new FS.ErrnoError(err);
|
3873 | }
|
3874 |
|
3875 |
|
3876 | err = new_node ?
|
3877 | FS.mayDelete(new_dir, new_name, isdir) :
|
3878 | FS.mayCreate(new_dir, new_name);
|
3879 | if (err) {
|
3880 | throw new FS.ErrnoError(err);
|
3881 | }
|
3882 | if (!old_dir.node_ops.rename) {
|
3883 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3884 | }
|
3885 | if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
|
3886 | throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
|
3887 | }
|
3888 |
|
3889 | if (new_dir !== old_dir) {
|
3890 | err = FS.nodePermissions(old_dir, 'w');
|
3891 | if (err) {
|
3892 | throw new FS.ErrnoError(err);
|
3893 | }
|
3894 | }
|
3895 | try {
|
3896 | if (FS.trackingDelegate['willMovePath']) {
|
3897 | FS.trackingDelegate['willMovePath'](old_path, new_path);
|
3898 | }
|
3899 | } catch(e) {
|
3900 | console.log("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
|
3901 | }
|
3902 |
|
3903 | FS.hashRemoveNode(old_node);
|
3904 |
|
3905 | try {
|
3906 | old_dir.node_ops.rename(old_node, new_dir, new_name);
|
3907 | } catch (e) {
|
3908 | throw e;
|
3909 | } finally {
|
3910 |
|
3911 |
|
3912 | FS.hashAddNode(old_node);
|
3913 | }
|
3914 | try {
|
3915 | if (FS.trackingDelegate['onMovePath']) FS.trackingDelegate['onMovePath'](old_path, new_path);
|
3916 | } catch(e) {
|
3917 | console.log("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
|
3918 | }
|
3919 | },rmdir:function (path) {
|
3920 | var lookup = FS.lookupPath(path, { parent: true });
|
3921 | var parent = lookup.node;
|
3922 | var name = PATH.basename(path);
|
3923 | var node = FS.lookupNode(parent, name);
|
3924 | var err = FS.mayDelete(parent, name, true);
|
3925 | if (err) {
|
3926 | throw new FS.ErrnoError(err);
|
3927 | }
|
3928 | if (!parent.node_ops.rmdir) {
|
3929 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3930 | }
|
3931 | if (FS.isMountpoint(node)) {
|
3932 | throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
|
3933 | }
|
3934 | try {
|
3935 | if (FS.trackingDelegate['willDeletePath']) {
|
3936 | FS.trackingDelegate['willDeletePath'](path);
|
3937 | }
|
3938 | } catch(e) {
|
3939 | console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message);
|
3940 | }
|
3941 | parent.node_ops.rmdir(parent, name);
|
3942 | FS.destroyNode(node);
|
3943 | try {
|
3944 | if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path);
|
3945 | } catch(e) {
|
3946 | console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message);
|
3947 | }
|
3948 | },readdir:function (path) {
|
3949 | var lookup = FS.lookupPath(path, { follow: true });
|
3950 | var node = lookup.node;
|
3951 | if (!node.node_ops.readdir) {
|
3952 | throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
|
3953 | }
|
3954 | return node.node_ops.readdir(node);
|
3955 | },unlink:function (path) {
|
3956 | var lookup = FS.lookupPath(path, { parent: true });
|
3957 | var parent = lookup.node;
|
3958 | var name = PATH.basename(path);
|
3959 | var node = FS.lookupNode(parent, name);
|
3960 | var err = FS.mayDelete(parent, name, false);
|
3961 | if (err) {
|
3962 |
|
3963 |
|
3964 |
|
3965 | throw new FS.ErrnoError(err);
|
3966 | }
|
3967 | if (!parent.node_ops.unlink) {
|
3968 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
3969 | }
|
3970 | if (FS.isMountpoint(node)) {
|
3971 | throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
|
3972 | }
|
3973 | try {
|
3974 | if (FS.trackingDelegate['willDeletePath']) {
|
3975 | FS.trackingDelegate['willDeletePath'](path);
|
3976 | }
|
3977 | } catch(e) {
|
3978 | console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message);
|
3979 | }
|
3980 | parent.node_ops.unlink(parent, name);
|
3981 | FS.destroyNode(node);
|
3982 | try {
|
3983 | if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path);
|
3984 | } catch(e) {
|
3985 | console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message);
|
3986 | }
|
3987 | },readlink:function (path) {
|
3988 | var lookup = FS.lookupPath(path);
|
3989 | var link = lookup.node;
|
3990 | if (!link) {
|
3991 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
3992 | }
|
3993 | if (!link.node_ops.readlink) {
|
3994 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
3995 | }
|
3996 | return PATH.resolve(FS.getPath(link.parent), link.node_ops.readlink(link));
|
3997 | },stat:function (path, dontFollow) {
|
3998 | var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
3999 | var node = lookup.node;
|
4000 | if (!node) {
|
4001 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
4002 | }
|
4003 | if (!node.node_ops.getattr) {
|
4004 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
4005 | }
|
4006 | return node.node_ops.getattr(node);
|
4007 | },lstat:function (path) {
|
4008 | return FS.stat(path, true);
|
4009 | },chmod:function (path, mode, dontFollow) {
|
4010 | var node;
|
4011 | if (typeof path === 'string') {
|
4012 | var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
4013 | node = lookup.node;
|
4014 | } else {
|
4015 | node = path;
|
4016 | }
|
4017 | if (!node.node_ops.setattr) {
|
4018 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
4019 | }
|
4020 | node.node_ops.setattr(node, {
|
4021 | mode: (mode & 4095) | (node.mode & ~4095),
|
4022 | timestamp: Date.now()
|
4023 | });
|
4024 | },lchmod:function (path, mode) {
|
4025 | FS.chmod(path, mode, true);
|
4026 | },fchmod:function (fd, mode) {
|
4027 | var stream = FS.getStream(fd);
|
4028 | if (!stream) {
|
4029 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4030 | }
|
4031 | FS.chmod(stream.node, mode);
|
4032 | },chown:function (path, uid, gid, dontFollow) {
|
4033 | var node;
|
4034 | if (typeof path === 'string') {
|
4035 | var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
4036 | node = lookup.node;
|
4037 | } else {
|
4038 | node = path;
|
4039 | }
|
4040 | if (!node.node_ops.setattr) {
|
4041 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
4042 | }
|
4043 | node.node_ops.setattr(node, {
|
4044 | timestamp: Date.now()
|
4045 |
|
4046 | });
|
4047 | },lchown:function (path, uid, gid) {
|
4048 | FS.chown(path, uid, gid, true);
|
4049 | },fchown:function (fd, uid, gid) {
|
4050 | var stream = FS.getStream(fd);
|
4051 | if (!stream) {
|
4052 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4053 | }
|
4054 | FS.chown(stream.node, uid, gid);
|
4055 | },truncate:function (path, len) {
|
4056 | if (len < 0) {
|
4057 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4058 | }
|
4059 | var node;
|
4060 | if (typeof path === 'string') {
|
4061 | var lookup = FS.lookupPath(path, { follow: true });
|
4062 | node = lookup.node;
|
4063 | } else {
|
4064 | node = path;
|
4065 | }
|
4066 | if (!node.node_ops.setattr) {
|
4067 | throw new FS.ErrnoError(ERRNO_CODES.EPERM);
|
4068 | }
|
4069 | if (FS.isDir(node.mode)) {
|
4070 | throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
|
4071 | }
|
4072 | if (!FS.isFile(node.mode)) {
|
4073 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4074 | }
|
4075 | var err = FS.nodePermissions(node, 'w');
|
4076 | if (err) {
|
4077 | throw new FS.ErrnoError(err);
|
4078 | }
|
4079 | node.node_ops.setattr(node, {
|
4080 | size: len,
|
4081 | timestamp: Date.now()
|
4082 | });
|
4083 | },ftruncate:function (fd, len) {
|
4084 | var stream = FS.getStream(fd);
|
4085 | if (!stream) {
|
4086 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4087 | }
|
4088 | if ((stream.flags & 2097155) === 0) {
|
4089 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4090 | }
|
4091 | FS.truncate(stream.node, len);
|
4092 | },utime:function (path, atime, mtime) {
|
4093 | var lookup = FS.lookupPath(path, { follow: true });
|
4094 | var node = lookup.node;
|
4095 | node.node_ops.setattr(node, {
|
4096 | timestamp: Math.max(atime, mtime)
|
4097 | });
|
4098 | },open:function (path, flags, mode, fd_start, fd_end) {
|
4099 | if (path === "") {
|
4100 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
4101 | }
|
4102 | flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
|
4103 | mode = typeof mode === 'undefined' ? 438 : mode;
|
4104 | if ((flags & 64)) {
|
4105 | mode = (mode & 4095) | 32768;
|
4106 | } else {
|
4107 | mode = 0;
|
4108 | }
|
4109 | var node;
|
4110 | if (typeof path === 'object') {
|
4111 | node = path;
|
4112 | } else {
|
4113 | path = PATH.normalize(path);
|
4114 | try {
|
4115 | var lookup = FS.lookupPath(path, {
|
4116 | follow: !(flags & 131072)
|
4117 | });
|
4118 | node = lookup.node;
|
4119 | } catch (e) {
|
4120 |
|
4121 | }
|
4122 | }
|
4123 |
|
4124 | var created = false;
|
4125 | if ((flags & 64)) {
|
4126 | if (node) {
|
4127 |
|
4128 | if ((flags & 128)) {
|
4129 | throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
|
4130 | }
|
4131 | } else {
|
4132 |
|
4133 | node = FS.mknod(path, mode, 0);
|
4134 | created = true;
|
4135 | }
|
4136 | }
|
4137 | if (!node) {
|
4138 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
4139 | }
|
4140 |
|
4141 | if (FS.isChrdev(node.mode)) {
|
4142 | flags &= ~512;
|
4143 | }
|
4144 |
|
4145 | if ((flags & 65536) && !FS.isDir(node.mode)) {
|
4146 | throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
|
4147 | }
|
4148 |
|
4149 |
|
4150 |
|
4151 | if (!created) {
|
4152 | var err = FS.mayOpen(node, flags);
|
4153 | if (err) {
|
4154 | throw new FS.ErrnoError(err);
|
4155 | }
|
4156 | }
|
4157 |
|
4158 | if ((flags & 512)) {
|
4159 | FS.truncate(node, 0);
|
4160 | }
|
4161 |
|
4162 | flags &= ~(128 | 512);
|
4163 |
|
4164 |
|
4165 | var stream = FS.createStream({
|
4166 | node: node,
|
4167 | path: FS.getPath(node),
|
4168 | flags: flags,
|
4169 | seekable: true,
|
4170 | position: 0,
|
4171 | stream_ops: node.stream_ops,
|
4172 |
|
4173 | ungotten: [],
|
4174 | error: false
|
4175 | }, fd_start, fd_end);
|
4176 |
|
4177 | if (stream.stream_ops.open) {
|
4178 | stream.stream_ops.open(stream);
|
4179 | }
|
4180 | if (Module['logReadFiles'] && !(flags & 1)) {
|
4181 | if (!FS.readFiles) FS.readFiles = {};
|
4182 | if (!(path in FS.readFiles)) {
|
4183 | FS.readFiles[path] = 1;
|
4184 | console.log("FS.trackingDelegate error on read file: " + path);
|
4185 | }
|
4186 | }
|
4187 | try {
|
4188 | if (FS.trackingDelegate['onOpenFile']) {
|
4189 | var trackingFlags = 0;
|
4190 | if ((flags & 2097155) !== 1) {
|
4191 | trackingFlags |= FS.tracking.openFlags.READ;
|
4192 | }
|
4193 | if ((flags & 2097155) !== 0) {
|
4194 | trackingFlags |= FS.tracking.openFlags.WRITE;
|
4195 | }
|
4196 | FS.trackingDelegate['onOpenFile'](path, trackingFlags);
|
4197 | }
|
4198 | } catch(e) {
|
4199 | console.log("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: " + e.message);
|
4200 | }
|
4201 | return stream;
|
4202 | },close:function (stream) {
|
4203 | if (FS.isClosed(stream)) {
|
4204 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4205 | }
|
4206 | if (stream.getdents) stream.getdents = null;
|
4207 | try {
|
4208 | if (stream.stream_ops.close) {
|
4209 | stream.stream_ops.close(stream);
|
4210 | }
|
4211 | } catch (e) {
|
4212 | throw e;
|
4213 | } finally {
|
4214 | FS.closeStream(stream.fd);
|
4215 | }
|
4216 | stream.fd = null;
|
4217 | },isClosed:function (stream) {
|
4218 | return stream.fd === null;
|
4219 | },llseek:function (stream, offset, whence) {
|
4220 | if (FS.isClosed(stream)) {
|
4221 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4222 | }
|
4223 | if (!stream.seekable || !stream.stream_ops.llseek) {
|
4224 | throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
|
4225 | }
|
4226 | stream.position = stream.stream_ops.llseek(stream, offset, whence);
|
4227 | stream.ungotten = [];
|
4228 | return stream.position;
|
4229 | },read:function (stream, buffer, offset, length, position) {
|
4230 | if (length < 0 || position < 0) {
|
4231 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4232 | }
|
4233 | if (FS.isClosed(stream)) {
|
4234 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4235 | }
|
4236 | if ((stream.flags & 2097155) === 1) {
|
4237 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4238 | }
|
4239 | if (FS.isDir(stream.node.mode)) {
|
4240 | throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
|
4241 | }
|
4242 | if (!stream.stream_ops.read) {
|
4243 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4244 | }
|
4245 | var seeking = typeof position !== 'undefined';
|
4246 | if (!seeking) {
|
4247 | position = stream.position;
|
4248 | } else if (!stream.seekable) {
|
4249 | throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
|
4250 | }
|
4251 | var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
|
4252 | if (!seeking) stream.position += bytesRead;
|
4253 | return bytesRead;
|
4254 | },write:function (stream, buffer, offset, length, position, canOwn) {
|
4255 | if (length < 0 || position < 0) {
|
4256 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4257 | }
|
4258 | if (FS.isClosed(stream)) {
|
4259 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4260 | }
|
4261 | if ((stream.flags & 2097155) === 0) {
|
4262 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4263 | }
|
4264 | if (FS.isDir(stream.node.mode)) {
|
4265 | throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
|
4266 | }
|
4267 | if (!stream.stream_ops.write) {
|
4268 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4269 | }
|
4270 | if (stream.flags & 1024) {
|
4271 |
|
4272 | FS.llseek(stream, 0, 2);
|
4273 | }
|
4274 | var seeking = typeof position !== 'undefined';
|
4275 | if (!seeking) {
|
4276 | position = stream.position;
|
4277 | } else if (!stream.seekable) {
|
4278 | throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
|
4279 | }
|
4280 | var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
|
4281 | if (!seeking) stream.position += bytesWritten;
|
4282 | try {
|
4283 | if (stream.path && FS.trackingDelegate['onWriteToFile']) FS.trackingDelegate['onWriteToFile'](stream.path);
|
4284 | } catch(e) {
|
4285 | console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: " + e.message);
|
4286 | }
|
4287 | return bytesWritten;
|
4288 | },allocate:function (stream, offset, length) {
|
4289 | if (FS.isClosed(stream)) {
|
4290 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4291 | }
|
4292 | if (offset < 0 || length <= 0) {
|
4293 | throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
|
4294 | }
|
4295 | if ((stream.flags & 2097155) === 0) {
|
4296 | throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4297 | }
|
4298 | if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
|
4299 | throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
|
4300 | }
|
4301 | if (!stream.stream_ops.allocate) {
|
4302 | throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
|
4303 | }
|
4304 | stream.stream_ops.allocate(stream, offset, length);
|
4305 | },mmap:function (stream, buffer, offset, length, position, prot, flags) {
|
4306 |
|
4307 | if ((stream.flags & 2097155) === 1) {
|
4308 | throw new FS.ErrnoError(ERRNO_CODES.EACCES);
|
4309 | }
|
4310 | if (!stream.stream_ops.mmap) {
|
4311 | throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
|
4312 | }
|
4313 | return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
|
4314 | },msync:function (stream, buffer, offset, length, mmapFlags) {
|
4315 | if (!stream || !stream.stream_ops.msync) {
|
4316 | return 0;
|
4317 | }
|
4318 | return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
|
4319 | },munmap:function (stream) {
|
4320 | return 0;
|
4321 | },ioctl:function (stream, cmd, arg) {
|
4322 | if (!stream.stream_ops.ioctl) {
|
4323 | throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
|
4324 | }
|
4325 | return stream.stream_ops.ioctl(stream, cmd, arg);
|
4326 | },readFile:function (path, opts) {
|
4327 | opts = opts || {};
|
4328 | opts.flags = opts.flags || 'r';
|
4329 | opts.encoding = opts.encoding || 'binary';
|
4330 | if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
|
4331 | throw new Error('Invalid encoding type "' + opts.encoding + '"');
|
4332 | }
|
4333 | var ret;
|
4334 | var stream = FS.open(path, opts.flags);
|
4335 | var stat = FS.stat(path);
|
4336 | var length = stat.size;
|
4337 | var buf = new Uint8Array(length);
|
4338 | FS.read(stream, buf, 0, length, 0);
|
4339 | if (opts.encoding === 'utf8') {
|
4340 | ret = UTF8ArrayToString(buf, 0);
|
4341 | } else if (opts.encoding === 'binary') {
|
4342 | ret = buf;
|
4343 | }
|
4344 | FS.close(stream);
|
4345 | return ret;
|
4346 | },writeFile:function (path, data, opts) {
|
4347 | opts = opts || {};
|
4348 | opts.flags = opts.flags || 'w';
|
4349 | var stream = FS.open(path, opts.flags, opts.mode);
|
4350 | if (typeof data === 'string') {
|
4351 | var buf = new Uint8Array(lengthBytesUTF8(data)+1);
|
4352 | var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
|
4353 | FS.write(stream, buf, 0, actualNumBytes, undefined, opts.canOwn);
|
4354 | } else if (ArrayBuffer.isView(data)) {
|
4355 | FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
|
4356 | } else {
|
4357 | throw new Error('Unsupported data type');
|
4358 | }
|
4359 | FS.close(stream);
|
4360 | },cwd:function () {
|
4361 | return FS.currentPath;
|
4362 | },chdir:function (path) {
|
4363 | var lookup = FS.lookupPath(path, { follow: true });
|
4364 | if (lookup.node === null) {
|
4365 | throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
|
4366 | }
|
4367 | if (!FS.isDir(lookup.node.mode)) {
|
4368 | throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
|
4369 | }
|
4370 | var err = FS.nodePermissions(lookup.node, 'x');
|
4371 | if (err) {
|
4372 | throw new FS.ErrnoError(err);
|
4373 | }
|
4374 | FS.currentPath = lookup.path;
|
4375 | },createDefaultDirectories:function () {
|
4376 | FS.mkdir('/tmp');
|
4377 | FS.mkdir('/home');
|
4378 | FS.mkdir('/home/web_user');
|
4379 | },createDefaultDevices:function () {
|
4380 |
|
4381 | FS.mkdir('/dev');
|
4382 |
|
4383 | FS.registerDevice(FS.makedev(1, 3), {
|
4384 | read: function() { return 0; },
|
4385 | write: function(stream, buffer, offset, length, pos) { return length; }
|
4386 | });
|
4387 | FS.mkdev('/dev/null', FS.makedev(1, 3));
|
4388 |
|
4389 |
|
4390 |
|
4391 | TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
|
4392 | TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
|
4393 | FS.mkdev('/dev/tty', FS.makedev(5, 0));
|
4394 | FS.mkdev('/dev/tty1', FS.makedev(6, 0));
|
4395 |
|
4396 | var random_device;
|
4397 | if (typeof crypto !== 'undefined') {
|
4398 |
|
4399 | var randomBuffer = new Uint8Array(1);
|
4400 | random_device = function() { crypto.getRandomValues(randomBuffer); return randomBuffer[0]; };
|
4401 | } else if (ENVIRONMENT_IS_NODE) {
|
4402 |
|
4403 | random_device = function() { return require('crypto')['randomBytes'](1)[0]; };
|
4404 | } else {
|
4405 |
|
4406 | random_device = function() { abort("random_device"); };
|
4407 | }
|
4408 | FS.createDevice('/dev', 'random', random_device);
|
4409 | FS.createDevice('/dev', 'urandom', random_device);
|
4410 |
|
4411 |
|
4412 | FS.mkdir('/dev/shm');
|
4413 | FS.mkdir('/dev/shm/tmp');
|
4414 | },createSpecialDirectories:function () {
|
4415 |
|
4416 | FS.mkdir('/proc');
|
4417 | FS.mkdir('/proc/self');
|
4418 | FS.mkdir('/proc/self/fd');
|
4419 | FS.mount({
|
4420 | mount: function() {
|
4421 | var node = FS.createNode('/proc/self', 'fd', 16384 | 511 , 73);
|
4422 | node.node_ops = {
|
4423 | lookup: function(parent, name) {
|
4424 | var fd = +name;
|
4425 | var stream = FS.getStream(fd);
|
4426 | if (!stream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4427 | var ret = {
|
4428 | parent: null,
|
4429 | mount: { mountpoint: 'fake' },
|
4430 | node_ops: { readlink: function() { return stream.path } }
|
4431 | };
|
4432 | ret.parent = ret;
|
4433 | return ret;
|
4434 | }
|
4435 | };
|
4436 | return node;
|
4437 | }
|
4438 | }, {}, '/proc/self/fd');
|
4439 | },createStandardStreams:function () {
|
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 |
|
4445 |
|
4446 |
|
4447 |
|
4448 | if (Module['stdin']) {
|
4449 | FS.createDevice('/dev', 'stdin', Module['stdin']);
|
4450 | } else {
|
4451 | FS.symlink('/dev/tty', '/dev/stdin');
|
4452 | }
|
4453 | if (Module['stdout']) {
|
4454 | FS.createDevice('/dev', 'stdout', null, Module['stdout']);
|
4455 | } else {
|
4456 | FS.symlink('/dev/tty', '/dev/stdout');
|
4457 | }
|
4458 | if (Module['stderr']) {
|
4459 | FS.createDevice('/dev', 'stderr', null, Module['stderr']);
|
4460 | } else {
|
4461 | FS.symlink('/dev/tty1', '/dev/stderr');
|
4462 | }
|
4463 |
|
4464 |
|
4465 | var stdin = FS.open('/dev/stdin', 'r');
|
4466 | assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
|
4467 |
|
4468 | var stdout = FS.open('/dev/stdout', 'w');
|
4469 | assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
|
4470 |
|
4471 | var stderr = FS.open('/dev/stderr', 'w');
|
4472 | assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
|
4473 | },ensureErrnoError:function () {
|
4474 | if (FS.ErrnoError) return;
|
4475 | FS.ErrnoError = function ErrnoError(errno, node) {
|
4476 | this.node = node;
|
4477 | this.setErrno = function(errno) {
|
4478 | this.errno = errno;
|
4479 | for (var key in ERRNO_CODES) {
|
4480 | if (ERRNO_CODES[key] === errno) {
|
4481 | this.code = key;
|
4482 | break;
|
4483 | }
|
4484 | }
|
4485 | };
|
4486 | this.setErrno(errno);
|
4487 | this.message = ERRNO_MESSAGES[errno];
|
4488 |
|
4489 | if (this.stack) Object.defineProperty(this, "stack", { value: (new Error).stack, writable: true });
|
4490 | if (this.stack) this.stack = demangleAll(this.stack);
|
4491 | };
|
4492 | FS.ErrnoError.prototype = new Error();
|
4493 | FS.ErrnoError.prototype.constructor = FS.ErrnoError;
|
4494 |
|
4495 | [ERRNO_CODES.ENOENT].forEach(function(code) {
|
4496 | FS.genericErrors[code] = new FS.ErrnoError(code);
|
4497 | FS.genericErrors[code].stack = '<generic error, no stack>';
|
4498 | });
|
4499 | },staticInit:function () {
|
4500 | FS.ensureErrnoError();
|
4501 |
|
4502 | FS.nameTable = new Array(4096);
|
4503 |
|
4504 | FS.mount(MEMFS, {}, '/');
|
4505 |
|
4506 | FS.createDefaultDirectories();
|
4507 | FS.createDefaultDevices();
|
4508 | FS.createSpecialDirectories();
|
4509 |
|
4510 | FS.filesystems = {
|
4511 | 'MEMFS': MEMFS,
|
4512 | 'IDBFS': IDBFS,
|
4513 | 'NODEFS': NODEFS,
|
4514 | 'WORKERFS': WORKERFS,
|
4515 | };
|
4516 | },init:function (input, output, error) {
|
4517 | assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
|
4518 | FS.init.initialized = true;
|
4519 |
|
4520 | FS.ensureErrnoError();
|
4521 |
|
4522 |
|
4523 | Module['stdin'] = input || Module['stdin'];
|
4524 | Module['stdout'] = output || Module['stdout'];
|
4525 | Module['stderr'] = error || Module['stderr'];
|
4526 |
|
4527 | FS.createStandardStreams();
|
4528 | },quit:function () {
|
4529 | FS.init.initialized = false;
|
4530 |
|
4531 | var fflush = Module['_fflush'];
|
4532 | if (fflush) fflush(0);
|
4533 |
|
4534 | for (var i = 0; i < FS.streams.length; i++) {
|
4535 | var stream = FS.streams[i];
|
4536 | if (!stream) {
|
4537 | continue;
|
4538 | }
|
4539 | FS.close(stream);
|
4540 | }
|
4541 | },getMode:function (canRead, canWrite) {
|
4542 | var mode = 0;
|
4543 | if (canRead) mode |= 292 | 73;
|
4544 | if (canWrite) mode |= 146;
|
4545 | return mode;
|
4546 | },joinPath:function (parts, forceRelative) {
|
4547 | var path = PATH.join.apply(null, parts);
|
4548 | if (forceRelative && path[0] == '/') path = path.substr(1);
|
4549 | return path;
|
4550 | },absolutePath:function (relative, base) {
|
4551 | return PATH.resolve(base, relative);
|
4552 | },standardizePath:function (path) {
|
4553 | return PATH.normalize(path);
|
4554 | },findObject:function (path, dontResolveLastLink) {
|
4555 | var ret = FS.analyzePath(path, dontResolveLastLink);
|
4556 | if (ret.exists) {
|
4557 | return ret.object;
|
4558 | } else {
|
4559 | ___setErrNo(ret.error);
|
4560 | return null;
|
4561 | }
|
4562 | },analyzePath:function (path, dontResolveLastLink) {
|
4563 |
|
4564 | try {
|
4565 | var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
|
4566 | path = lookup.path;
|
4567 | } catch (e) {
|
4568 | }
|
4569 | var ret = {
|
4570 | isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
|
4571 | parentExists: false, parentPath: null, parentObject: null
|
4572 | };
|
4573 | try {
|
4574 | var lookup = FS.lookupPath(path, { parent: true });
|
4575 | ret.parentExists = true;
|
4576 | ret.parentPath = lookup.path;
|
4577 | ret.parentObject = lookup.node;
|
4578 | ret.name = PATH.basename(path);
|
4579 | lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
|
4580 | ret.exists = true;
|
4581 | ret.path = lookup.path;
|
4582 | ret.object = lookup.node;
|
4583 | ret.name = lookup.node.name;
|
4584 | ret.isRoot = lookup.path === '/';
|
4585 | } catch (e) {
|
4586 | ret.error = e.errno;
|
4587 | };
|
4588 | return ret;
|
4589 | },createFolder:function (parent, name, canRead, canWrite) {
|
4590 | var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
|
4591 | var mode = FS.getMode(canRead, canWrite);
|
4592 | return FS.mkdir(path, mode);
|
4593 | },createPath:function (parent, path, canRead, canWrite) {
|
4594 | parent = typeof parent === 'string' ? parent : FS.getPath(parent);
|
4595 | var parts = path.split('/').reverse();
|
4596 | while (parts.length) {
|
4597 | var part = parts.pop();
|
4598 | if (!part) continue;
|
4599 | var current = PATH.join2(parent, part);
|
4600 | try {
|
4601 | FS.mkdir(current);
|
4602 | } catch (e) {
|
4603 |
|
4604 | }
|
4605 | parent = current;
|
4606 | }
|
4607 | return current;
|
4608 | },createFile:function (parent, name, properties, canRead, canWrite) {
|
4609 | var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
|
4610 | var mode = FS.getMode(canRead, canWrite);
|
4611 | return FS.create(path, mode);
|
4612 | },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
|
4613 | var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
|
4614 | var mode = FS.getMode(canRead, canWrite);
|
4615 | var node = FS.create(path, mode);
|
4616 | if (data) {
|
4617 | if (typeof data === 'string') {
|
4618 | var arr = new Array(data.length);
|
4619 | for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
|
4620 | data = arr;
|
4621 | }
|
4622 |
|
4623 | FS.chmod(node, mode | 146);
|
4624 | var stream = FS.open(node, 'w');
|
4625 | FS.write(stream, data, 0, data.length, 0, canOwn);
|
4626 | FS.close(stream);
|
4627 | FS.chmod(node, mode);
|
4628 | }
|
4629 | return node;
|
4630 | },createDevice:function (parent, name, input, output) {
|
4631 | var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
|
4632 | var mode = FS.getMode(!!input, !!output);
|
4633 | if (!FS.createDevice.major) FS.createDevice.major = 64;
|
4634 | var dev = FS.makedev(FS.createDevice.major++, 0);
|
4635 |
|
4636 |
|
4637 | FS.registerDevice(dev, {
|
4638 | open: function(stream) {
|
4639 | stream.seekable = false;
|
4640 | },
|
4641 | close: function(stream) {
|
4642 |
|
4643 | if (output && output.buffer && output.buffer.length) {
|
4644 | output(10);
|
4645 | }
|
4646 | },
|
4647 | read: function(stream, buffer, offset, length, pos /* ignored */) {
|
4648 | var bytesRead = 0;
|
4649 | for (var i = 0; i < length; i++) {
|
4650 | var result;
|
4651 | try {
|
4652 | result = input();
|
4653 | } catch (e) {
|
4654 | throw new FS.ErrnoError(ERRNO_CODES.EIO);
|
4655 | }
|
4656 | if (result === undefined && bytesRead === 0) {
|
4657 | throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
|
4658 | }
|
4659 | if (result === null || result === undefined) break;
|
4660 | bytesRead++;
|
4661 | buffer[offset+i] = result;
|
4662 | }
|
4663 | if (bytesRead) {
|
4664 | stream.node.timestamp = Date.now();
|
4665 | }
|
4666 | return bytesRead;
|
4667 | },
|
4668 | write: function(stream, buffer, offset, length, pos) {
|
4669 | for (var i = 0; i < length; i++) {
|
4670 | try {
|
4671 | output(buffer[offset+i]);
|
4672 | } catch (e) {
|
4673 | throw new FS.ErrnoError(ERRNO_CODES.EIO);
|
4674 | }
|
4675 | }
|
4676 | if (length) {
|
4677 | stream.node.timestamp = Date.now();
|
4678 | }
|
4679 | return i;
|
4680 | }
|
4681 | });
|
4682 | return FS.mkdev(path, mode, dev);
|
4683 | },createLink:function (parent, name, target, canRead, canWrite) {
|
4684 | var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
|
4685 | return FS.symlink(target, path);
|
4686 | },forceLoadFile:function (obj) {
|
4687 | if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
|
4688 | var success = true;
|
4689 | if (typeof XMLHttpRequest !== 'undefined') {
|
4690 | throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
|
4691 | } else if (Module['read']) {
|
4692 |
|
4693 | try {
|
4694 |
|
4695 |
|
4696 | obj.contents = intArrayFromString(Module['read'](obj.url), true);
|
4697 | obj.usedBytes = obj.contents.length;
|
4698 | } catch (e) {
|
4699 | success = false;
|
4700 | }
|
4701 | } else {
|
4702 | throw new Error('Cannot load without read() or XMLHttpRequest.');
|
4703 | }
|
4704 | if (!success) ___setErrNo(ERRNO_CODES.EIO);
|
4705 | return success;
|
4706 | },createLazyFile:function (parent, name, url, canRead, canWrite) {
|
4707 |
|
4708 | function LazyUint8Array() {
|
4709 | this.lengthKnown = false;
|
4710 | this.chunks = [];
|
4711 | }
|
4712 | LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
|
4713 | if (idx > this.length-1 || idx < 0) {
|
4714 | return undefined;
|
4715 | }
|
4716 | var chunkOffset = idx % this.chunkSize;
|
4717 | var chunkNum = (idx / this.chunkSize)|0;
|
4718 | return this.getter(chunkNum)[chunkOffset];
|
4719 | }
|
4720 | LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
|
4721 | this.getter = getter;
|
4722 | }
|
4723 | LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
|
4724 |
|
4725 | var xhr = new XMLHttpRequest();
|
4726 | xhr.open('HEAD', url, false);
|
4727 | xhr.send(null);
|
4728 | if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
|
4729 | var datalength = Number(xhr.getResponseHeader("Content-length"));
|
4730 | var header;
|
4731 | var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
|
4732 | var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
|
4733 |
|
4734 | var chunkSize = 1024*1024;
|
4735 |
|
4736 | if (!hasByteServing) chunkSize = datalength;
|
4737 |
|
4738 |
|
4739 | var doXHR = (function(from, to) {
|
4740 | if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
|
4741 | if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
|
4742 |
|
4743 |
|
4744 | var xhr = new XMLHttpRequest();
|
4745 | xhr.open('GET', url, false);
|
4746 | if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
|
4747 |
|
4748 |
|
4749 | if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
|
4750 | if (xhr.overrideMimeType) {
|
4751 | xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
4752 | }
|
4753 |
|
4754 | xhr.send(null);
|
4755 | if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
|
4756 | if (xhr.response !== undefined) {
|
4757 | return new Uint8Array(xhr.response || []);
|
4758 | } else {
|
4759 | return intArrayFromString(xhr.responseText || '', true);
|
4760 | }
|
4761 | });
|
4762 | var lazyArray = this;
|
4763 | lazyArray.setDataGetter(function(chunkNum) {
|
4764 | var start = chunkNum * chunkSize;
|
4765 | var end = (chunkNum+1) * chunkSize - 1;
|
4766 | end = Math.min(end, datalength-1);
|
4767 | if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
|
4768 | lazyArray.chunks[chunkNum] = doXHR(start, end);
|
4769 | }
|
4770 | if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
|
4771 | return lazyArray.chunks[chunkNum];
|
4772 | });
|
4773 |
|
4774 | if (usesGzip || !datalength) {
|
4775 |
|
4776 | chunkSize = datalength = 1;
|
4777 | datalength = this.getter(0).length;
|
4778 | chunkSize = datalength;
|
4779 | console.log("LazyFiles on gzip forces download of the whole file when length is accessed");
|
4780 | }
|
4781 |
|
4782 | this._length = datalength;
|
4783 | this._chunkSize = chunkSize;
|
4784 | this.lengthKnown = true;
|
4785 | }
|
4786 | if (typeof XMLHttpRequest !== 'undefined') {
|
4787 | if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
|
4788 | var lazyArray = new LazyUint8Array();
|
4789 | Object.defineProperties(lazyArray, {
|
4790 | length: {
|
4791 | get: function() {
|
4792 | if(!this.lengthKnown) {
|
4793 | this.cacheLength();
|
4794 | }
|
4795 | return this._length;
|
4796 | }
|
4797 | },
|
4798 | chunkSize: {
|
4799 | get: function() {
|
4800 | if(!this.lengthKnown) {
|
4801 | this.cacheLength();
|
4802 | }
|
4803 | return this._chunkSize;
|
4804 | }
|
4805 | }
|
4806 | });
|
4807 |
|
4808 | var properties = { isDevice: false, contents: lazyArray };
|
4809 | } else {
|
4810 | var properties = { isDevice: false, url: url };
|
4811 | }
|
4812 |
|
4813 | var node = FS.createFile(parent, name, properties, canRead, canWrite);
|
4814 |
|
4815 |
|
4816 |
|
4817 | if (properties.contents) {
|
4818 | node.contents = properties.contents;
|
4819 | } else if (properties.url) {
|
4820 | node.contents = null;
|
4821 | node.url = properties.url;
|
4822 | }
|
4823 |
|
4824 | Object.defineProperties(node, {
|
4825 | usedBytes: {
|
4826 | get: function() { return this.contents.length; }
|
4827 | }
|
4828 | });
|
4829 |
|
4830 | var stream_ops = {};
|
4831 | var keys = Object.keys(node.stream_ops);
|
4832 | keys.forEach(function(key) {
|
4833 | var fn = node.stream_ops[key];
|
4834 | stream_ops[key] = function forceLoadLazyFile() {
|
4835 | if (!FS.forceLoadFile(node)) {
|
4836 | throw new FS.ErrnoError(ERRNO_CODES.EIO);
|
4837 | }
|
4838 | return fn.apply(null, arguments);
|
4839 | };
|
4840 | });
|
4841 |
|
4842 | stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
|
4843 | if (!FS.forceLoadFile(node)) {
|
4844 | throw new FS.ErrnoError(ERRNO_CODES.EIO);
|
4845 | }
|
4846 | var contents = stream.node.contents;
|
4847 | if (position >= contents.length)
|
4848 | return 0;
|
4849 | var size = Math.min(contents.length - position, length);
|
4850 | assert(size >= 0);
|
4851 | if (contents.slice) {
|
4852 | for (var i = 0; i < size; i++) {
|
4853 | buffer[offset + i] = contents[position + i];
|
4854 | }
|
4855 | } else {
|
4856 | for (var i = 0; i < size; i++) {
|
4857 | buffer[offset + i] = contents.get(position + i);
|
4858 | }
|
4859 | }
|
4860 | return size;
|
4861 | };
|
4862 | node.stream_ops = stream_ops;
|
4863 | return node;
|
4864 | },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) {
|
4865 | Browser.init();
|
4866 |
|
4867 |
|
4868 | var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
|
4869 | var dep = getUniqueRunDependency('cp ' + fullname);
|
4870 | function processData(byteArray) {
|
4871 | function finish(byteArray) {
|
4872 | if (preFinish) preFinish();
|
4873 | if (!dontCreateFile) {
|
4874 | FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
|
4875 | }
|
4876 | if (onload) onload();
|
4877 | removeRunDependency(dep);
|
4878 | }
|
4879 | var handled = false;
|
4880 | Module['preloadPlugins'].forEach(function(plugin) {
|
4881 | if (handled) return;
|
4882 | if (plugin['canHandle'](fullname)) {
|
4883 | plugin['handle'](byteArray, fullname, finish, function() {
|
4884 | if (onerror) onerror();
|
4885 | removeRunDependency(dep);
|
4886 | });
|
4887 | handled = true;
|
4888 | }
|
4889 | });
|
4890 | if (!handled) finish(byteArray);
|
4891 | }
|
4892 | addRunDependency(dep);
|
4893 | if (typeof url == 'string') {
|
4894 | Browser.asyncLoad(url, function(byteArray) {
|
4895 | processData(byteArray);
|
4896 | }, onerror);
|
4897 | } else {
|
4898 | processData(url);
|
4899 | }
|
4900 | },indexedDB:function () {
|
4901 | return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
|
4902 | },DB_NAME:function () {
|
4903 | return 'EM_FS_' + window.location.pathname;
|
4904 | },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
|
4905 | onload = onload || function(){};
|
4906 | onerror = onerror || function(){};
|
4907 | var indexedDB = FS.indexedDB();
|
4908 | try {
|
4909 | var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
|
4910 | } catch (e) {
|
4911 | return onerror(e);
|
4912 | }
|
4913 | openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
|
4914 | console.log('creating db');
|
4915 | var db = openRequest.result;
|
4916 | db.createObjectStore(FS.DB_STORE_NAME);
|
4917 | };
|
4918 | openRequest.onsuccess = function openRequest_onsuccess() {
|
4919 | var db = openRequest.result;
|
4920 | var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
|
4921 | var files = transaction.objectStore(FS.DB_STORE_NAME);
|
4922 | var ok = 0, fail = 0, total = paths.length;
|
4923 | function finish() {
|
4924 | if (fail == 0) onload(); else onerror();
|
4925 | }
|
4926 | paths.forEach(function(path) {
|
4927 | var putRequest = files.put(FS.analyzePath(path).object.contents, path);
|
4928 | putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
|
4929 | putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
|
4930 | });
|
4931 | transaction.onerror = onerror;
|
4932 | };
|
4933 | openRequest.onerror = onerror;
|
4934 | },loadFilesFromDB:function (paths, onload, onerror) {
|
4935 | onload = onload || function(){};
|
4936 | onerror = onerror || function(){};
|
4937 | var indexedDB = FS.indexedDB();
|
4938 | try {
|
4939 | var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
|
4940 | } catch (e) {
|
4941 | return onerror(e);
|
4942 | }
|
4943 | openRequest.onupgradeneeded = onerror;
|
4944 | openRequest.onsuccess = function openRequest_onsuccess() {
|
4945 | var db = openRequest.result;
|
4946 | try {
|
4947 | var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
|
4948 | } catch(e) {
|
4949 | onerror(e);
|
4950 | return;
|
4951 | }
|
4952 | var files = transaction.objectStore(FS.DB_STORE_NAME);
|
4953 | var ok = 0, fail = 0, total = paths.length;
|
4954 | function finish() {
|
4955 | if (fail == 0) onload(); else onerror();
|
4956 | }
|
4957 | paths.forEach(function(path) {
|
4958 | var getRequest = files.get(path);
|
4959 | getRequest.onsuccess = function getRequest_onsuccess() {
|
4960 | if (FS.analyzePath(path).exists) {
|
4961 | FS.unlink(path);
|
4962 | }
|
4963 | FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
|
4964 | ok++;
|
4965 | if (ok + fail == total) finish();
|
4966 | };
|
4967 | getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
|
4968 | });
|
4969 | transaction.onerror = onerror;
|
4970 | };
|
4971 | openRequest.onerror = onerror;
|
4972 | }};var SYSCALLS={DEFAULT_POLLMASK:5,mappings:{},umask:511,calculateAt:function (dirfd, path) {
|
4973 | if (path[0] !== '/') {
|
4974 |
|
4975 | var dir;
|
4976 | if (dirfd === -100) {
|
4977 | dir = FS.cwd();
|
4978 | } else {
|
4979 | var dirstream = FS.getStream(dirfd);
|
4980 | if (!dirstream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
4981 | dir = dirstream.path;
|
4982 | }
|
4983 | path = PATH.join2(dir, path);
|
4984 | }
|
4985 | return path;
|
4986 | },doStat:function (func, path, buf) {
|
4987 | try {
|
4988 | var stat = func(path);
|
4989 | } catch (e) {
|
4990 | if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
|
4991 |
|
4992 | return -ERRNO_CODES.ENOTDIR;
|
4993 | }
|
4994 | throw e;
|
4995 | }
|
4996 | HEAP32[((buf)>>2)]=stat.dev;
|
4997 | HEAP32[(((buf)+(4))>>2)]=0;
|
4998 | HEAP32[(((buf)+(8))>>2)]=stat.ino;
|
4999 | HEAP32[(((buf)+(12))>>2)]=stat.mode;
|
5000 | HEAP32[(((buf)+(16))>>2)]=stat.nlink;
|
5001 | HEAP32[(((buf)+(20))>>2)]=stat.uid;
|
5002 | HEAP32[(((buf)+(24))>>2)]=stat.gid;
|
5003 | HEAP32[(((buf)+(28))>>2)]=stat.rdev;
|
5004 | HEAP32[(((buf)+(32))>>2)]=0;
|
5005 | HEAP32[(((buf)+(36))>>2)]=stat.size;
|
5006 | HEAP32[(((buf)+(40))>>2)]=4096;
|
5007 | HEAP32[(((buf)+(44))>>2)]=stat.blocks;
|
5008 | HEAP32[(((buf)+(48))>>2)]=(stat.atime.getTime() / 1000)|0;
|
5009 | HEAP32[(((buf)+(52))>>2)]=0;
|
5010 | HEAP32[(((buf)+(56))>>2)]=(stat.mtime.getTime() / 1000)|0;
|
5011 | HEAP32[(((buf)+(60))>>2)]=0;
|
5012 | HEAP32[(((buf)+(64))>>2)]=(stat.ctime.getTime() / 1000)|0;
|
5013 | HEAP32[(((buf)+(68))>>2)]=0;
|
5014 | HEAP32[(((buf)+(72))>>2)]=stat.ino;
|
5015 | return 0;
|
5016 | },doMsync:function (addr, stream, len, flags) {
|
5017 | var buffer = new Uint8Array(HEAPU8.subarray(addr, addr + len));
|
5018 | FS.msync(stream, buffer, 0, len, flags);
|
5019 | },doMkdir:function (path, mode) {
|
5020 |
|
5021 |
|
5022 | path = PATH.normalize(path);
|
5023 | if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
|
5024 | FS.mkdir(path, mode, 0);
|
5025 | return 0;
|
5026 | },doMknod:function (path, mode, dev) {
|
5027 |
|
5028 | switch (mode & 61440) {
|
5029 | case 32768:
|
5030 | case 8192:
|
5031 | case 24576:
|
5032 | case 4096:
|
5033 | case 49152:
|
5034 | break;
|
5035 | default: return -ERRNO_CODES.EINVAL;
|
5036 | }
|
5037 | FS.mknod(path, mode, dev);
|
5038 | return 0;
|
5039 | },doReadlink:function (path, buf, bufsize) {
|
5040 | if (bufsize <= 0) return -ERRNO_CODES.EINVAL;
|
5041 | var ret = FS.readlink(path);
|
5042 |
|
5043 | var len = Math.min(bufsize, lengthBytesUTF8(ret));
|
5044 | var endChar = HEAP8[buf+len];
|
5045 | stringToUTF8(ret, buf, bufsize+1);
|
5046 |
|
5047 |
|
5048 | HEAP8[buf+len] = endChar;
|
5049 |
|
5050 | return len;
|
5051 | },doAccess:function (path, amode) {
|
5052 | if (amode & ~7) {
|
5053 |
|
5054 | return -ERRNO_CODES.EINVAL;
|
5055 | }
|
5056 | var node;
|
5057 | var lookup = FS.lookupPath(path, { follow: true });
|
5058 | node = lookup.node;
|
5059 | var perms = '';
|
5060 | if (amode & 4) perms += 'r';
|
5061 | if (amode & 2) perms += 'w';
|
5062 | if (amode & 1) perms += 'x';
|
5063 | if (perms && FS.nodePermissions(node, perms)) {
|
5064 | return -ERRNO_CODES.EACCES;
|
5065 | }
|
5066 | return 0;
|
5067 | },doDup:function (path, flags, suggestFD) {
|
5068 | var suggest = FS.getStream(suggestFD);
|
5069 | if (suggest) FS.close(suggest);
|
5070 | return FS.open(path, flags, 0, suggestFD, suggestFD).fd;
|
5071 | },doReadv:function (stream, iov, iovcnt, offset) {
|
5072 | var ret = 0;
|
5073 | for (var i = 0; i < iovcnt; i++) {
|
5074 | var ptr = HEAP32[(((iov)+(i*8))>>2)];
|
5075 | var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
|
5076 | var curr = FS.read(stream, HEAP8,ptr, len, offset);
|
5077 | if (curr < 0) return -1;
|
5078 | ret += curr;
|
5079 | if (curr < len) break;
|
5080 | }
|
5081 | return ret;
|
5082 | },doWritev:function (stream, iov, iovcnt, offset) {
|
5083 | var ret = 0;
|
5084 | for (var i = 0; i < iovcnt; i++) {
|
5085 | var ptr = HEAP32[(((iov)+(i*8))>>2)];
|
5086 | var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
|
5087 | var curr = FS.write(stream, HEAP8,ptr, len, offset);
|
5088 | if (curr < 0) return -1;
|
5089 | ret += curr;
|
5090 | }
|
5091 | return ret;
|
5092 | },varargs:0,get:function (varargs) {
|
5093 | SYSCALLS.varargs += 4;
|
5094 | var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)];
|
5095 | return ret;
|
5096 | },getStr:function () {
|
5097 | var ret = Pointer_stringify(SYSCALLS.get());
|
5098 | return ret;
|
5099 | },getStreamFromFD:function () {
|
5100 | var stream = FS.getStream(SYSCALLS.get());
|
5101 | if (!stream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
5102 | return stream;
|
5103 | },getSocketFromFD:function () {
|
5104 | var socket = SOCKFS.getSocket(SYSCALLS.get());
|
5105 | if (!socket) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
5106 | return socket;
|
5107 | },getSocketAddress:function (allowNull) {
|
5108 | var addrp = SYSCALLS.get(), addrlen = SYSCALLS.get();
|
5109 | if (allowNull && addrp === 0) return null;
|
5110 | var info = __read_sockaddr(addrp, addrlen);
|
5111 | if (info.errno) throw new FS.ErrnoError(info.errno);
|
5112 | info.addr = DNS.lookup_addr(info.addr) || info.addr;
|
5113 | return info;
|
5114 | },get64:function () {
|
5115 | var low = SYSCALLS.get(), high = SYSCALLS.get();
|
5116 | if (low >= 0) assert(high === 0);
|
5117 | else assert(high === -1);
|
5118 | return low;
|
5119 | },getZero:function () {
|
5120 | assert(SYSCALLS.get() === 0);
|
5121 | }};function ___syscall140(which, varargs) {SYSCALLS.varargs = varargs;
|
5122 | try {
|
5123 |
|
5124 | var stream = SYSCALLS.getStreamFromFD(), offset_high = SYSCALLS.get(), offset_low = SYSCALLS.get(), result = SYSCALLS.get(), whence = SYSCALLS.get();
|
5125 |
|
5126 | var offset = offset_low;
|
5127 | FS.llseek(stream, offset, whence);
|
5128 | HEAP32[((result)>>2)]=stream.position;
|
5129 | if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null;
|
5130 | return 0;
|
5131 | } catch (e) {
|
5132 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5133 | return -e.errno;
|
5134 | }
|
5135 | }
|
5136 |
|
5137 | function ___syscall142(which, varargs) {SYSCALLS.varargs = varargs;
|
5138 | try {
|
5139 |
|
5140 |
|
5141 |
|
5142 |
|
5143 |
|
5144 | var nfds = SYSCALLS.get(), readfds = SYSCALLS.get(), writefds = SYSCALLS.get(), exceptfds = SYSCALLS.get(), timeout = SYSCALLS.get();
|
5145 |
|
5146 | assert(nfds <= 64, 'nfds must be less than or equal to 64');
|
5147 | assert(!exceptfds, 'exceptfds not supported');
|
5148 |
|
5149 | var total = 0;
|
5150 |
|
5151 | var srcReadLow = (readfds ? HEAP32[((readfds)>>2)] : 0),
|
5152 | srcReadHigh = (readfds ? HEAP32[(((readfds)+(4))>>2)] : 0);
|
5153 | var srcWriteLow = (writefds ? HEAP32[((writefds)>>2)] : 0),
|
5154 | srcWriteHigh = (writefds ? HEAP32[(((writefds)+(4))>>2)] : 0);
|
5155 | var srcExceptLow = (exceptfds ? HEAP32[((exceptfds)>>2)] : 0),
|
5156 | srcExceptHigh = (exceptfds ? HEAP32[(((exceptfds)+(4))>>2)] : 0);
|
5157 |
|
5158 | var dstReadLow = 0,
|
5159 | dstReadHigh = 0;
|
5160 | var dstWriteLow = 0,
|
5161 | dstWriteHigh = 0;
|
5162 | var dstExceptLow = 0,
|
5163 | dstExceptHigh = 0;
|
5164 |
|
5165 | var allLow = (readfds ? HEAP32[((readfds)>>2)] : 0) |
|
5166 | (writefds ? HEAP32[((writefds)>>2)] : 0) |
|
5167 | (exceptfds ? HEAP32[((exceptfds)>>2)] : 0);
|
5168 | var allHigh = (readfds ? HEAP32[(((readfds)+(4))>>2)] : 0) |
|
5169 | (writefds ? HEAP32[(((writefds)+(4))>>2)] : 0) |
|
5170 | (exceptfds ? HEAP32[(((exceptfds)+(4))>>2)] : 0);
|
5171 |
|
5172 | function check(fd, low, high, val) {
|
5173 | return (fd < 32 ? (low & val) : (high & val));
|
5174 | }
|
5175 |
|
5176 | for (var fd = 0; fd < nfds; fd++) {
|
5177 | var mask = 1 << (fd % 32);
|
5178 | if (!(check(fd, allLow, allHigh, mask))) {
|
5179 | continue;
|
5180 | }
|
5181 |
|
5182 | var stream = FS.getStream(fd);
|
5183 | if (!stream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
|
5184 |
|
5185 | var flags = SYSCALLS.DEFAULT_POLLMASK;
|
5186 |
|
5187 | if (stream.stream_ops.poll) {
|
5188 | flags = stream.stream_ops.poll(stream);
|
5189 | }
|
5190 |
|
5191 | if ((flags & 1) && check(fd, srcReadLow, srcReadHigh, mask)) {
|
5192 | fd < 32 ? (dstReadLow = dstReadLow | mask) : (dstReadHigh = dstReadHigh | mask);
|
5193 | total++;
|
5194 | }
|
5195 | if ((flags & 4) && check(fd, srcWriteLow, srcWriteHigh, mask)) {
|
5196 | fd < 32 ? (dstWriteLow = dstWriteLow | mask) : (dstWriteHigh = dstWriteHigh | mask);
|
5197 | total++;
|
5198 | }
|
5199 | if ((flags & 2) && check(fd, srcExceptLow, srcExceptHigh, mask)) {
|
5200 | fd < 32 ? (dstExceptLow = dstExceptLow | mask) : (dstExceptHigh = dstExceptHigh | mask);
|
5201 | total++;
|
5202 | }
|
5203 | }
|
5204 |
|
5205 | if (readfds) {
|
5206 | HEAP32[((readfds)>>2)]=dstReadLow;
|
5207 | HEAP32[(((readfds)+(4))>>2)]=dstReadHigh;
|
5208 | }
|
5209 | if (writefds) {
|
5210 | HEAP32[((writefds)>>2)]=dstWriteLow;
|
5211 | HEAP32[(((writefds)+(4))>>2)]=dstWriteHigh;
|
5212 | }
|
5213 | if (exceptfds) {
|
5214 | HEAP32[((exceptfds)>>2)]=dstExceptLow;
|
5215 | HEAP32[(((exceptfds)+(4))>>2)]=dstExceptHigh;
|
5216 | }
|
5217 |
|
5218 | return total;
|
5219 | } catch (e) {
|
5220 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5221 | return -e.errno;
|
5222 | }
|
5223 | }
|
5224 |
|
5225 | function ___syscall146(which, varargs) {SYSCALLS.varargs = varargs;
|
5226 | try {
|
5227 |
|
5228 | var stream = SYSCALLS.getStreamFromFD(), iov = SYSCALLS.get(), iovcnt = SYSCALLS.get();
|
5229 | return SYSCALLS.doWritev(stream, iov, iovcnt);
|
5230 | } catch (e) {
|
5231 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5232 | return -e.errno;
|
5233 | }
|
5234 | }
|
5235 |
|
5236 | function ___syscall195(which, varargs) {SYSCALLS.varargs = varargs;
|
5237 | try {
|
5238 |
|
5239 | var path = SYSCALLS.getStr(), buf = SYSCALLS.get();
|
5240 | return SYSCALLS.doStat(FS.stat, path, buf);
|
5241 | } catch (e) {
|
5242 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5243 | return -e.errno;
|
5244 | }
|
5245 | }
|
5246 |
|
5247 | function ___syscall197(which, varargs) {SYSCALLS.varargs = varargs;
|
5248 | try {
|
5249 |
|
5250 | var stream = SYSCALLS.getStreamFromFD(), buf = SYSCALLS.get();
|
5251 | return SYSCALLS.doStat(FS.stat, stream.path, buf);
|
5252 | } catch (e) {
|
5253 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5254 | return -e.errno;
|
5255 | }
|
5256 | }
|
5257 |
|
5258 |
|
5259 | function ___syscall202(which, varargs) {SYSCALLS.varargs = varargs;
|
5260 | try {
|
5261 |
|
5262 | return 0;
|
5263 | } catch (e) {
|
5264 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5265 | return -e.errno;
|
5266 | }
|
5267 | }function ___syscall199() {
|
5268 | return ___syscall202.apply(null, arguments)
|
5269 | }
|
5270 |
|
5271 |
|
5272 | var PROCINFO={ppid:1,pid:42,sid:42,pgid:42};function ___syscall20(which, varargs) {SYSCALLS.varargs = varargs;
|
5273 | try {
|
5274 |
|
5275 | return PROCINFO.pid;
|
5276 | } catch (e) {
|
5277 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5278 | return -e.errno;
|
5279 | }
|
5280 | }
|
5281 |
|
5282 | function ___syscall221(which, varargs) {SYSCALLS.varargs = varargs;
|
5283 | try {
|
5284 |
|
5285 | var stream = SYSCALLS.getStreamFromFD(), cmd = SYSCALLS.get();
|
5286 | switch (cmd) {
|
5287 | case 0: {
|
5288 | var arg = SYSCALLS.get();
|
5289 | if (arg < 0) {
|
5290 | return -ERRNO_CODES.EINVAL;
|
5291 | }
|
5292 | var newStream;
|
5293 | newStream = FS.open(stream.path, stream.flags, 0, arg);
|
5294 | return newStream.fd;
|
5295 | }
|
5296 | case 1:
|
5297 | case 2:
|
5298 | return 0;
|
5299 | case 3:
|
5300 | return stream.flags;
|
5301 | case 4: {
|
5302 | var arg = SYSCALLS.get();
|
5303 | stream.flags |= arg;
|
5304 | return 0;
|
5305 | }
|
5306 | case 12:
|
5307 | case 12: {
|
5308 | var arg = SYSCALLS.get();
|
5309 | var offset = 0;
|
5310 |
|
5311 | HEAP16[(((arg)+(offset))>>1)]=2;
|
5312 | return 0;
|
5313 | }
|
5314 | case 13:
|
5315 | case 14:
|
5316 | case 13:
|
5317 | case 14:
|
5318 | return 0;
|
5319 | case 16:
|
5320 | case 8:
|
5321 | return -ERRNO_CODES.EINVAL;
|
5322 | case 9:
|
5323 |
|
5324 | ___setErrNo(ERRNO_CODES.EINVAL);
|
5325 | return -1;
|
5326 | default: {
|
5327 | return -ERRNO_CODES.EINVAL;
|
5328 | }
|
5329 | }
|
5330 | } catch (e) {
|
5331 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5332 | return -e.errno;
|
5333 | }
|
5334 | }
|
5335 |
|
5336 | function ___syscall3(which, varargs) {SYSCALLS.varargs = varargs;
|
5337 | try {
|
5338 |
|
5339 | var stream = SYSCALLS.getStreamFromFD(), buf = SYSCALLS.get(), count = SYSCALLS.get();
|
5340 | return FS.read(stream, HEAP8,buf, count);
|
5341 | } catch (e) {
|
5342 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5343 | return -e.errno;
|
5344 | }
|
5345 | }
|
5346 |
|
5347 | function ___syscall5(which, varargs) {SYSCALLS.varargs = varargs;
|
5348 | try {
|
5349 |
|
5350 | var pathname = SYSCALLS.getStr(), flags = SYSCALLS.get(), mode = SYSCALLS.get()
|
5351 | var stream = FS.open(pathname, flags, mode);
|
5352 | return stream.fd;
|
5353 | } catch (e) {
|
5354 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5355 | return -e.errno;
|
5356 | }
|
5357 | }
|
5358 |
|
5359 | function ___syscall54(which, varargs) {SYSCALLS.varargs = varargs;
|
5360 | try {
|
5361 |
|
5362 | var stream = SYSCALLS.getStreamFromFD(), op = SYSCALLS.get();
|
5363 | switch (op) {
|
5364 | case 21509:
|
5365 | case 21505: {
|
5366 | if (!stream.tty) return -ERRNO_CODES.ENOTTY;
|
5367 | return 0;
|
5368 | }
|
5369 | case 21510:
|
5370 | case 21511:
|
5371 | case 21512:
|
5372 | case 21506:
|
5373 | case 21507:
|
5374 | case 21508: {
|
5375 | if (!stream.tty) return -ERRNO_CODES.ENOTTY;
|
5376 | return 0;
|
5377 | }
|
5378 | case 21519: {
|
5379 | if (!stream.tty) return -ERRNO_CODES.ENOTTY;
|
5380 | var argp = SYSCALLS.get();
|
5381 | HEAP32[((argp)>>2)]=0;
|
5382 | return 0;
|
5383 | }
|
5384 | case 21520: {
|
5385 | if (!stream.tty) return -ERRNO_CODES.ENOTTY;
|
5386 | return -ERRNO_CODES.EINVAL;
|
5387 | }
|
5388 | case 21531: {
|
5389 | var argp = SYSCALLS.get();
|
5390 | return FS.ioctl(stream, op, argp);
|
5391 | }
|
5392 | case 21523: {
|
5393 |
|
5394 |
|
5395 | if (!stream.tty) return -ERRNO_CODES.ENOTTY;
|
5396 | return 0;
|
5397 | }
|
5398 | case 21524: {
|
5399 |
|
5400 |
|
5401 |
|
5402 | if (!stream.tty) return -ERRNO_CODES.ENOTTY;
|
5403 | return 0;
|
5404 | }
|
5405 | default: abort('bad ioctl syscall ' + op);
|
5406 | }
|
5407 | } catch (e) {
|
5408 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5409 | return -e.errno;
|
5410 | }
|
5411 | }
|
5412 |
|
5413 | function ___syscall6(which, varargs) {SYSCALLS.varargs = varargs;
|
5414 | try {
|
5415 |
|
5416 | var stream = SYSCALLS.getStreamFromFD();
|
5417 | FS.close(stream);
|
5418 | return 0;
|
5419 | } catch (e) {
|
5420 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5421 | return -e.errno;
|
5422 | }
|
5423 | }
|
5424 |
|
5425 | function ___syscall91(which, varargs) {SYSCALLS.varargs = varargs;
|
5426 | try {
|
5427 |
|
5428 | var addr = SYSCALLS.get(), len = SYSCALLS.get();
|
5429 |
|
5430 | var info = SYSCALLS.mappings[addr];
|
5431 | if (!info) return 0;
|
5432 | if (len === info.len) {
|
5433 | var stream = FS.getStream(info.fd);
|
5434 | SYSCALLS.doMsync(addr, stream, len, info.flags)
|
5435 | FS.munmap(stream);
|
5436 | SYSCALLS.mappings[addr] = null;
|
5437 | if (info.allocated) {
|
5438 | _free(info.malloc);
|
5439 | }
|
5440 | }
|
5441 | return 0;
|
5442 | } catch (e) {
|
5443 | if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
|
5444 | return -e.errno;
|
5445 | }
|
5446 | }
|
5447 |
|
5448 | function ___unlock() {}
|
5449 |
|
5450 |
|
5451 | function getShiftFromSize(size) {
|
5452 | switch (size) {
|
5453 | case 1: return 0;
|
5454 | case 2: return 1;
|
5455 | case 4: return 2;
|
5456 | case 8: return 3;
|
5457 | default:
|
5458 | throw new TypeError('Unknown type size: ' + size);
|
5459 | }
|
5460 | }
|
5461 |
|
5462 |
|
5463 |
|
5464 | function embind_init_charCodes() {
|
5465 | var codes = new Array(256);
|
5466 | for (var i = 0; i < 256; ++i) {
|
5467 | codes[i] = String.fromCharCode(i);
|
5468 | }
|
5469 | embind_charCodes = codes;
|
5470 | }var embind_charCodes=undefined;function readLatin1String(ptr) {
|
5471 | var ret = "";
|
5472 | var c = ptr;
|
5473 | while (HEAPU8[c]) {
|
5474 | ret += embind_charCodes[HEAPU8[c++]];
|
5475 | }
|
5476 | return ret;
|
5477 | }
|
5478 |
|
5479 |
|
5480 | var awaitingDependencies={};
|
5481 |
|
5482 | var registeredTypes={};
|
5483 |
|
5484 | var typeDependencies={};
|
5485 |
|
5486 |
|
5487 |
|
5488 |
|
5489 |
|
5490 |
|
5491 | var char_0=48;
|
5492 |
|
5493 | var char_9=57;function makeLegalFunctionName(name) {
|
5494 | if (undefined === name) {
|
5495 | return '_unknown';
|
5496 | }
|
5497 | name = name.replace(/[^a-zA-Z0-9_]/g, '$');
|
5498 | var f = name.charCodeAt(0);
|
5499 | if (f >= char_0 && f <= char_9) {
|
5500 | return '_' + name;
|
5501 | } else {
|
5502 | return name;
|
5503 | }
|
5504 | }function createNamedFunction(name, body) {
|
5505 | name = makeLegalFunctionName(name);
|
5506 |
|
5507 | return new Function(
|
5508 | "body",
|
5509 | "return function " + name + "() {\n" +
|
5510 | " \"use strict\";" +
|
5511 | " return body.apply(this, arguments);\n" +
|
5512 | "};\n"
|
5513 | )(body);
|
5514 | }function extendError(baseErrorType, errorName) {
|
5515 | var errorClass = createNamedFunction(errorName, function(message) {
|
5516 | this.name = errorName;
|
5517 | this.message = message;
|
5518 |
|
5519 | var stack = (new Error(message)).stack;
|
5520 | if (stack !== undefined) {
|
5521 | this.stack = this.toString() + '\n' +
|
5522 | stack.replace(/^Error(:[^\n]*)?\n/, '');
|
5523 | }
|
5524 | });
|
5525 | errorClass.prototype = Object.create(baseErrorType.prototype);
|
5526 | errorClass.prototype.constructor = errorClass;
|
5527 | errorClass.prototype.toString = function() {
|
5528 | if (this.message === undefined) {
|
5529 | return this.name;
|
5530 | } else {
|
5531 | return this.name + ': ' + this.message;
|
5532 | }
|
5533 | };
|
5534 |
|
5535 | return errorClass;
|
5536 | }var BindingError=undefined;function throwBindingError(message) {
|
5537 | throw new BindingError(message);
|
5538 | }
|
5539 |
|
5540 |
|
5541 |
|
5542 | var InternalError=undefined;function throwInternalError(message) {
|
5543 | throw new InternalError(message);
|
5544 | }function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {
|
5545 | myTypes.forEach(function(type) {
|
5546 | typeDependencies[type] = dependentTypes;
|
5547 | });
|
5548 |
|
5549 | function onComplete(typeConverters) {
|
5550 | var myTypeConverters = getTypeConverters(typeConverters);
|
5551 | if (myTypeConverters.length !== myTypes.length) {
|
5552 | throwInternalError('Mismatched type converter count');
|
5553 | }
|
5554 | for (var i = 0; i < myTypes.length; ++i) {
|
5555 | registerType(myTypes[i], myTypeConverters[i]);
|
5556 | }
|
5557 | }
|
5558 |
|
5559 | var typeConverters = new Array(dependentTypes.length);
|
5560 | var unregisteredTypes = [];
|
5561 | var registered = 0;
|
5562 | dependentTypes.forEach(function(dt, i) {
|
5563 | if (registeredTypes.hasOwnProperty(dt)) {
|
5564 | typeConverters[i] = registeredTypes[dt];
|
5565 | } else {
|
5566 | unregisteredTypes.push(dt);
|
5567 | if (!awaitingDependencies.hasOwnProperty(dt)) {
|
5568 | awaitingDependencies[dt] = [];
|
5569 | }
|
5570 | awaitingDependencies[dt].push(function() {
|
5571 | typeConverters[i] = registeredTypes[dt];
|
5572 | ++registered;
|
5573 | if (registered === unregisteredTypes.length) {
|
5574 | onComplete(typeConverters);
|
5575 | }
|
5576 | });
|
5577 | }
|
5578 | });
|
5579 | if (0 === unregisteredTypes.length) {
|
5580 | onComplete(typeConverters);
|
5581 | }
|
5582 | }function registerType(rawType, registeredInstance, options) {
|
5583 | options = options || {};
|
5584 |
|
5585 | if (!('argPackAdvance' in registeredInstance)) {
|
5586 | throw new TypeError('registerType registeredInstance requires argPackAdvance');
|
5587 | }
|
5588 |
|
5589 | var name = registeredInstance.name;
|
5590 | if (!rawType) {
|
5591 | throwBindingError('type "' + name + '" must have a positive integer typeid pointer');
|
5592 | }
|
5593 | if (registeredTypes.hasOwnProperty(rawType)) {
|
5594 | if (options.ignoreDuplicateRegistrations) {
|
5595 | return;
|
5596 | } else {
|
5597 | throwBindingError("Cannot register type '" + name + "' twice");
|
5598 | }
|
5599 | }
|
5600 |
|
5601 | registeredTypes[rawType] = registeredInstance;
|
5602 | delete typeDependencies[rawType];
|
5603 |
|
5604 | if (awaitingDependencies.hasOwnProperty(rawType)) {
|
5605 | var callbacks = awaitingDependencies[rawType];
|
5606 | delete awaitingDependencies[rawType];
|
5607 | callbacks.forEach(function(cb) {
|
5608 | cb();
|
5609 | });
|
5610 | }
|
5611 | }function __embind_register_bool(rawType, name, size, trueValue, falseValue) {
|
5612 | var shift = getShiftFromSize(size);
|
5613 |
|
5614 | name = readLatin1String(name);
|
5615 | registerType(rawType, {
|
5616 | name: name,
|
5617 | 'fromWireType': function(wt) {
|
5618 |
|
5619 |
|
5620 | return !!wt;
|
5621 | },
|
5622 | 'toWireType': function(destructors, o) {
|
5623 | return o ? trueValue : falseValue;
|
5624 | },
|
5625 | 'argPackAdvance': 8,
|
5626 | 'readValueFromPointer': function(pointer) {
|
5627 |
|
5628 | var heap;
|
5629 | if (size === 1) {
|
5630 | heap = HEAP8;
|
5631 | } else if (size === 2) {
|
5632 | heap = HEAP16;
|
5633 | } else if (size === 4) {
|
5634 | heap = HEAP32;
|
5635 | } else {
|
5636 | throw new TypeError("Unknown boolean type size: " + name);
|
5637 | }
|
5638 | return this['fromWireType'](heap[pointer >> shift]);
|
5639 | },
|
5640 | destructorFunction: null,
|
5641 | });
|
5642 | }
|
5643 |
|
5644 |
|
5645 |
|
5646 |
|
5647 | function ClassHandle_isAliasOf(other) {
|
5648 | if (!(this instanceof ClassHandle)) {
|
5649 | return false;
|
5650 | }
|
5651 | if (!(other instanceof ClassHandle)) {
|
5652 | return false;
|
5653 | }
|
5654 |
|
5655 | var leftClass = this.$$.ptrType.registeredClass;
|
5656 | var left = this.$$.ptr;
|
5657 | var rightClass = other.$$.ptrType.registeredClass;
|
5658 | var right = other.$$.ptr;
|
5659 |
|
5660 | while (leftClass.baseClass) {
|
5661 | left = leftClass.upcast(left);
|
5662 | leftClass = leftClass.baseClass;
|
5663 | }
|
5664 |
|
5665 | while (rightClass.baseClass) {
|
5666 | right = rightClass.upcast(right);
|
5667 | rightClass = rightClass.baseClass;
|
5668 | }
|
5669 |
|
5670 | return leftClass === rightClass && left === right;
|
5671 | }
|
5672 |
|
5673 |
|
5674 | function shallowCopyInternalPointer(o) {
|
5675 | return {
|
5676 | count: o.count,
|
5677 | deleteScheduled: o.deleteScheduled,
|
5678 | preservePointerOnDelete: o.preservePointerOnDelete,
|
5679 | ptr: o.ptr,
|
5680 | ptrType: o.ptrType,
|
5681 | smartPtr: o.smartPtr,
|
5682 | smartPtrType: o.smartPtrType,
|
5683 | };
|
5684 | }
|
5685 |
|
5686 | function throwInstanceAlreadyDeleted(obj) {
|
5687 | function getInstanceTypeName(handle) {
|
5688 | return handle.$$.ptrType.registeredClass.name;
|
5689 | }
|
5690 | throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
|
5691 | }function ClassHandle_clone() {
|
5692 | if (!this.$$.ptr) {
|
5693 | throwInstanceAlreadyDeleted(this);
|
5694 | }
|
5695 |
|
5696 | if (this.$$.preservePointerOnDelete) {
|
5697 | this.$$.count.value += 1;
|
5698 | return this;
|
5699 | } else {
|
5700 | var clone = Object.create(Object.getPrototypeOf(this), {
|
5701 | $$: {
|
5702 | value: shallowCopyInternalPointer(this.$$),
|
5703 | }
|
5704 | });
|
5705 |
|
5706 | clone.$$.count.value += 1;
|
5707 | clone.$$.deleteScheduled = false;
|
5708 | return clone;
|
5709 | }
|
5710 | }
|
5711 |
|
5712 |
|
5713 | function runDestructor(handle) {
|
5714 | var $$ = handle.$$;
|
5715 | if ($$.smartPtr) {
|
5716 | $$.smartPtrType.rawDestructor($$.smartPtr);
|
5717 | } else {
|
5718 | $$.ptrType.registeredClass.rawDestructor($$.ptr);
|
5719 | }
|
5720 | }function ClassHandle_delete() {
|
5721 | if (!this.$$.ptr) {
|
5722 | throwInstanceAlreadyDeleted(this);
|
5723 | }
|
5724 |
|
5725 | if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
5726 | throwBindingError('Object already scheduled for deletion');
|
5727 | }
|
5728 |
|
5729 | this.$$.count.value -= 1;
|
5730 | var toDelete = 0 === this.$$.count.value;
|
5731 | if (toDelete) {
|
5732 | runDestructor(this);
|
5733 | }
|
5734 | if (!this.$$.preservePointerOnDelete) {
|
5735 | this.$$.smartPtr = undefined;
|
5736 | this.$$.ptr = undefined;
|
5737 | }
|
5738 | }
|
5739 |
|
5740 | function ClassHandle_isDeleted() {
|
5741 | return !this.$$.ptr;
|
5742 | }
|
5743 |
|
5744 |
|
5745 | var delayFunction=undefined;
|
5746 |
|
5747 | var deletionQueue=[];
|
5748 |
|
5749 | function flushPendingDeletes() {
|
5750 | while (deletionQueue.length) {
|
5751 | var obj = deletionQueue.pop();
|
5752 | obj.$$.deleteScheduled = false;
|
5753 | obj['delete']();
|
5754 | }
|
5755 | }function ClassHandle_deleteLater() {
|
5756 | if (!this.$$.ptr) {
|
5757 | throwInstanceAlreadyDeleted(this);
|
5758 | }
|
5759 | if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
5760 | throwBindingError('Object already scheduled for deletion');
|
5761 | }
|
5762 | deletionQueue.push(this);
|
5763 | if (deletionQueue.length === 1 && delayFunction) {
|
5764 | delayFunction(flushPendingDeletes);
|
5765 | }
|
5766 | this.$$.deleteScheduled = true;
|
5767 | return this;
|
5768 | }function init_ClassHandle() {
|
5769 | ClassHandle.prototype['isAliasOf'] = ClassHandle_isAliasOf;
|
5770 | ClassHandle.prototype['clone'] = ClassHandle_clone;
|
5771 | ClassHandle.prototype['delete'] = ClassHandle_delete;
|
5772 | ClassHandle.prototype['isDeleted'] = ClassHandle_isDeleted;
|
5773 | ClassHandle.prototype['deleteLater'] = ClassHandle_deleteLater;
|
5774 | }function ClassHandle() {
|
5775 | }
|
5776 |
|
5777 | var registeredPointers={};
|
5778 |
|
5779 |
|
5780 | function ensureOverloadTable(proto, methodName, humanName) {
|
5781 | if (undefined === proto[methodName].overloadTable) {
|
5782 | var prevFunc = proto[methodName];
|
5783 |
|
5784 | proto[methodName] = function() {
|
5785 |
|
5786 | if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {
|
5787 | throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
|
5788 | }
|
5789 | return proto[methodName].overloadTable[arguments.length].apply(this, arguments);
|
5790 | };
|
5791 |
|
5792 | proto[methodName].overloadTable = [];
|
5793 | proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
|
5794 | }
|
5795 | }function exposePublicSymbol(name, value, numArguments) {
|
5796 | if (Module.hasOwnProperty(name)) {
|
5797 | if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
|
5798 | throwBindingError("Cannot register public name '" + name + "' twice");
|
5799 | }
|
5800 |
|
5801 |
|
5802 |
|
5803 | ensureOverloadTable(Module, name, name);
|
5804 | if (Module.hasOwnProperty(numArguments)) {
|
5805 | throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
|
5806 | }
|
5807 |
|
5808 | Module[name].overloadTable[numArguments] = value;
|
5809 | }
|
5810 | else {
|
5811 | Module[name] = value;
|
5812 | if (undefined !== numArguments) {
|
5813 | Module[name].numArguments = numArguments;
|
5814 | }
|
5815 | }
|
5816 | }
|
5817 |
|
5818 | function RegisteredClass(
|
5819 | name,
|
5820 | constructor,
|
5821 | instancePrototype,
|
5822 | rawDestructor,
|
5823 | baseClass,
|
5824 | getActualType,
|
5825 | upcast,
|
5826 | downcast
|
5827 | ) {
|
5828 | this.name = name;
|
5829 | this.constructor = constructor;
|
5830 | this.instancePrototype = instancePrototype;
|
5831 | this.rawDestructor = rawDestructor;
|
5832 | this.baseClass = baseClass;
|
5833 | this.getActualType = getActualType;
|
5834 | this.upcast = upcast;
|
5835 | this.downcast = downcast;
|
5836 | this.pureVirtualFunctions = [];
|
5837 | }
|
5838 |
|
5839 |
|
5840 |
|
5841 | function upcastPointer(ptr, ptrClass, desiredClass) {
|
5842 | while (ptrClass !== desiredClass) {
|
5843 | if (!ptrClass.upcast) {
|
5844 | throwBindingError("Expected null or instance of " + desiredClass.name + ", got an instance of " + ptrClass.name);
|
5845 | }
|
5846 | ptr = ptrClass.upcast(ptr);
|
5847 | ptrClass = ptrClass.baseClass;
|
5848 | }
|
5849 | return ptr;
|
5850 | }function constNoSmartPtrRawPointerToWireType(destructors, handle) {
|
5851 | if (handle === null) {
|
5852 | if (this.isReference) {
|
5853 | throwBindingError('null is not a valid ' + this.name);
|
5854 | }
|
5855 | return 0;
|
5856 | }
|
5857 |
|
5858 | if (!handle.$$) {
|
5859 | throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
|
5860 | }
|
5861 | if (!handle.$$.ptr) {
|
5862 | throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
|
5863 | }
|
5864 | var handleClass = handle.$$.ptrType.registeredClass;
|
5865 | var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
5866 | return ptr;
|
5867 | }
|
5868 |
|
5869 | function genericPointerToWireType(destructors, handle) {
|
5870 | var ptr;
|
5871 | if (handle === null) {
|
5872 | if (this.isReference) {
|
5873 | throwBindingError('null is not a valid ' + this.name);
|
5874 | }
|
5875 |
|
5876 | if (this.isSmartPointer) {
|
5877 | ptr = this.rawConstructor();
|
5878 | if (destructors !== null) {
|
5879 | destructors.push(this.rawDestructor, ptr);
|
5880 | }
|
5881 | return ptr;
|
5882 | } else {
|
5883 | return 0;
|
5884 | }
|
5885 | }
|
5886 |
|
5887 | if (!handle.$$) {
|
5888 | throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
|
5889 | }
|
5890 | if (!handle.$$.ptr) {
|
5891 | throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
|
5892 | }
|
5893 | if (!this.isConst && handle.$$.ptrType.isConst) {
|
5894 | throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
|
5895 | }
|
5896 | var handleClass = handle.$$.ptrType.registeredClass;
|
5897 | ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
5898 |
|
5899 | if (this.isSmartPointer) {
|
5900 |
|
5901 |
|
5902 |
|
5903 | if (undefined === handle.$$.smartPtr) {
|
5904 | throwBindingError('Passing raw pointer to smart pointer is illegal');
|
5905 | }
|
5906 |
|
5907 | switch (this.sharingPolicy) {
|
5908 | case 0:
|
5909 |
|
5910 | if (handle.$$.smartPtrType === this) {
|
5911 | ptr = handle.$$.smartPtr;
|
5912 | } else {
|
5913 | throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
|
5914 | }
|
5915 | break;
|
5916 |
|
5917 | case 1:
|
5918 | ptr = handle.$$.smartPtr;
|
5919 | break;
|
5920 |
|
5921 | case 2:
|
5922 | if (handle.$$.smartPtrType === this) {
|
5923 | ptr = handle.$$.smartPtr;
|
5924 | } else {
|
5925 | var clonedHandle = handle['clone']();
|
5926 | ptr = this.rawShare(
|
5927 | ptr,
|
5928 | __emval_register(function() {
|
5929 | clonedHandle['delete']();
|
5930 | })
|
5931 | );
|
5932 | if (destructors !== null) {
|
5933 | destructors.push(this.rawDestructor, ptr);
|
5934 | }
|
5935 | }
|
5936 | break;
|
5937 |
|
5938 | default:
|
5939 | throwBindingError('Unsupporting sharing policy');
|
5940 | }
|
5941 | }
|
5942 | return ptr;
|
5943 | }
|
5944 |
|
5945 | function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {
|
5946 | if (handle === null) {
|
5947 | if (this.isReference) {
|
5948 | throwBindingError('null is not a valid ' + this.name);
|
5949 | }
|
5950 | return 0;
|
5951 | }
|
5952 |
|
5953 | if (!handle.$$) {
|
5954 | throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
|
5955 | }
|
5956 | if (!handle.$$.ptr) {
|
5957 | throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
|
5958 | }
|
5959 | if (handle.$$.ptrType.isConst) {
|
5960 | throwBindingError('Cannot convert argument of type ' + handle.$$.ptrType.name + ' to parameter type ' + this.name);
|
5961 | }
|
5962 | var handleClass = handle.$$.ptrType.registeredClass;
|
5963 | var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
5964 | return ptr;
|
5965 | }
|
5966 |
|
5967 |
|
5968 | function simpleReadValueFromPointer(pointer) {
|
5969 | return this['fromWireType'](HEAPU32[pointer >> 2]);
|
5970 | }
|
5971 |
|
5972 | function RegisteredPointer_getPointee(ptr) {
|
5973 | if (this.rawGetPointee) {
|
5974 | ptr = this.rawGetPointee(ptr);
|
5975 | }
|
5976 | return ptr;
|
5977 | }
|
5978 |
|
5979 | function RegisteredPointer_destructor(ptr) {
|
5980 | if (this.rawDestructor) {
|
5981 | this.rawDestructor(ptr);
|
5982 | }
|
5983 | }
|
5984 |
|
5985 | function RegisteredPointer_deleteObject(handle) {
|
5986 | if (handle !== null) {
|
5987 | handle['delete']();
|
5988 | }
|
5989 | }
|
5990 |
|
5991 |
|
5992 | function downcastPointer(ptr, ptrClass, desiredClass) {
|
5993 | if (ptrClass === desiredClass) {
|
5994 | return ptr;
|
5995 | }
|
5996 | if (undefined === desiredClass.baseClass) {
|
5997 | return null;
|
5998 | }
|
5999 |
|
6000 | var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);
|
6001 | if (rv === null) {
|
6002 | return null;
|
6003 | }
|
6004 | return desiredClass.downcast(rv);
|
6005 | }
|
6006 |
|
6007 |
|
6008 |
|
6009 |
|
6010 | function getInheritedInstanceCount() {
|
6011 | return Object.keys(registeredInstances).length;
|
6012 | }
|
6013 |
|
6014 | function getLiveInheritedInstances() {
|
6015 | var rv = [];
|
6016 | for (var k in registeredInstances) {
|
6017 | if (registeredInstances.hasOwnProperty(k)) {
|
6018 | rv.push(registeredInstances[k]);
|
6019 | }
|
6020 | }
|
6021 | return rv;
|
6022 | }
|
6023 |
|
6024 | function setDelayFunction(fn) {
|
6025 | delayFunction = fn;
|
6026 | if (deletionQueue.length && delayFunction) {
|
6027 | delayFunction(flushPendingDeletes);
|
6028 | }
|
6029 | }function init_embind() {
|
6030 | Module['getInheritedInstanceCount'] = getInheritedInstanceCount;
|
6031 | Module['getLiveInheritedInstances'] = getLiveInheritedInstances;
|
6032 | Module['flushPendingDeletes'] = flushPendingDeletes;
|
6033 | Module['setDelayFunction'] = setDelayFunction;
|
6034 | }var registeredInstances={};
|
6035 |
|
6036 | function getBasestPointer(class_, ptr) {
|
6037 | if (ptr === undefined) {
|
6038 | throwBindingError('ptr should not be undefined');
|
6039 | }
|
6040 | while (class_.baseClass) {
|
6041 | ptr = class_.upcast(ptr);
|
6042 | class_ = class_.baseClass;
|
6043 | }
|
6044 | return ptr;
|
6045 | }function getInheritedInstance(class_, ptr) {
|
6046 | ptr = getBasestPointer(class_, ptr);
|
6047 | return registeredInstances[ptr];
|
6048 | }
|
6049 |
|
6050 | function makeClassHandle(prototype, record) {
|
6051 | if (!record.ptrType || !record.ptr) {
|
6052 | throwInternalError('makeClassHandle requires ptr and ptrType');
|
6053 | }
|
6054 | var hasSmartPtrType = !!record.smartPtrType;
|
6055 | var hasSmartPtr = !!record.smartPtr;
|
6056 | if (hasSmartPtrType !== hasSmartPtr) {
|
6057 | throwInternalError('Both smartPtrType and smartPtr must be specified');
|
6058 | }
|
6059 | record.count = { value: 1 };
|
6060 | return Object.create(prototype, {
|
6061 | $$: {
|
6062 | value: record,
|
6063 | },
|
6064 | });
|
6065 | }function RegisteredPointer_fromWireType(ptr) {
|
6066 |
|
6067 |
|
6068 |
|
6069 | var rawPointer = this.getPointee(ptr);
|
6070 | if (!rawPointer) {
|
6071 | this.destructor(ptr);
|
6072 | return null;
|
6073 | }
|
6074 |
|
6075 | var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);
|
6076 | if (undefined !== registeredInstance) {
|
6077 |
|
6078 | if (0 === registeredInstance.$$.count.value) {
|
6079 | registeredInstance.$$.ptr = rawPointer;
|
6080 | registeredInstance.$$.smartPtr = ptr;
|
6081 | return registeredInstance['clone']();
|
6082 | } else {
|
6083 |
|
6084 |
|
6085 | var rv = registeredInstance['clone']();
|
6086 | this.destructor(ptr);
|
6087 | return rv;
|
6088 | }
|
6089 | }
|
6090 |
|
6091 | function makeDefaultHandle() {
|
6092 | if (this.isSmartPointer) {
|
6093 | return makeClassHandle(this.registeredClass.instancePrototype, {
|
6094 | ptrType: this.pointeeType,
|
6095 | ptr: rawPointer,
|
6096 | smartPtrType: this,
|
6097 | smartPtr: ptr,
|
6098 | });
|
6099 | } else {
|
6100 | return makeClassHandle(this.registeredClass.instancePrototype, {
|
6101 | ptrType: this,
|
6102 | ptr: ptr,
|
6103 | });
|
6104 | }
|
6105 | }
|
6106 |
|
6107 | var actualType = this.registeredClass.getActualType(rawPointer);
|
6108 | var registeredPointerRecord = registeredPointers[actualType];
|
6109 | if (!registeredPointerRecord) {
|
6110 | return makeDefaultHandle.call(this);
|
6111 | }
|
6112 |
|
6113 | var toType;
|
6114 | if (this.isConst) {
|
6115 | toType = registeredPointerRecord.constPointerType;
|
6116 | } else {
|
6117 | toType = registeredPointerRecord.pointerType;
|
6118 | }
|
6119 | var dp = downcastPointer(
|
6120 | rawPointer,
|
6121 | this.registeredClass,
|
6122 | toType.registeredClass);
|
6123 | if (dp === null) {
|
6124 | return makeDefaultHandle.call(this);
|
6125 | }
|
6126 | if (this.isSmartPointer) {
|
6127 | return makeClassHandle(toType.registeredClass.instancePrototype, {
|
6128 | ptrType: toType,
|
6129 | ptr: dp,
|
6130 | smartPtrType: this,
|
6131 | smartPtr: ptr,
|
6132 | });
|
6133 | } else {
|
6134 | return makeClassHandle(toType.registeredClass.instancePrototype, {
|
6135 | ptrType: toType,
|
6136 | ptr: dp,
|
6137 | });
|
6138 | }
|
6139 | }function init_RegisteredPointer() {
|
6140 | RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee;
|
6141 | RegisteredPointer.prototype.destructor = RegisteredPointer_destructor;
|
6142 | RegisteredPointer.prototype['argPackAdvance'] = 8;
|
6143 | RegisteredPointer.prototype['readValueFromPointer'] = simpleReadValueFromPointer;
|
6144 | RegisteredPointer.prototype['deleteObject'] = RegisteredPointer_deleteObject;
|
6145 | RegisteredPointer.prototype['fromWireType'] = RegisteredPointer_fromWireType;
|
6146 | }function RegisteredPointer(
|
6147 | name,
|
6148 | registeredClass,
|
6149 | isReference,
|
6150 | isConst,
|
6151 |
|
6152 | // smart pointer properties
|
6153 | isSmartPointer,
|
6154 | pointeeType,
|
6155 | sharingPolicy,
|
6156 | rawGetPointee,
|
6157 | rawConstructor,
|
6158 | rawShare,
|
6159 | rawDestructor
|
6160 | ) {
|
6161 | this.name = name;
|
6162 | this.registeredClass = registeredClass;
|
6163 | this.isReference = isReference;
|
6164 | this.isConst = isConst;
|
6165 |
|
6166 |
|
6167 | this.isSmartPointer = isSmartPointer;
|
6168 | this.pointeeType = pointeeType;
|
6169 | this.sharingPolicy = sharingPolicy;
|
6170 | this.rawGetPointee = rawGetPointee;
|
6171 | this.rawConstructor = rawConstructor;
|
6172 | this.rawShare = rawShare;
|
6173 | this.rawDestructor = rawDestructor;
|
6174 |
|
6175 | if (!isSmartPointer && registeredClass.baseClass === undefined) {
|
6176 | if (isConst) {
|
6177 | this['toWireType'] = constNoSmartPtrRawPointerToWireType;
|
6178 | this.destructorFunction = null;
|
6179 | } else {
|
6180 | this['toWireType'] = nonConstNoSmartPtrRawPointerToWireType;
|
6181 | this.destructorFunction = null;
|
6182 | }
|
6183 | } else {
|
6184 | this['toWireType'] = genericPointerToWireType;
|
6185 |
|
6186 |
|
6187 |
|
6188 |
|
6189 | }
|
6190 | }
|
6191 |
|
6192 | function replacePublicSymbol(name, value, numArguments) {
|
6193 | if (!Module.hasOwnProperty(name)) {
|
6194 | throwInternalError('Replacing nonexistant public symbol');
|
6195 | }
|
6196 |
|
6197 | if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
|
6198 | Module[name].overloadTable[numArguments] = value;
|
6199 | }
|
6200 | else {
|
6201 | Module[name] = value;
|
6202 | Module[name].argCount = numArguments;
|
6203 | }
|
6204 | }
|
6205 |
|
6206 | function embind__requireFunction(signature, rawFunction) {
|
6207 | signature = readLatin1String(signature);
|
6208 |
|
6209 | function makeDynCaller(dynCall) {
|
6210 | var args = [];
|
6211 | for (var i = 1; i < signature.length; ++i) {
|
6212 | args.push('a' + i);
|
6213 | }
|
6214 |
|
6215 | var name = 'dynCall_' + signature + '_' + rawFunction;
|
6216 | var body = 'return function ' + name + '(' + args.join(', ') + ') {\n';
|
6217 | body += ' return dynCall(rawFunction' + (args.length ? ', ' : '') + args.join(', ') + ');\n';
|
6218 | body += '};\n';
|
6219 |
|
6220 | return (new Function('dynCall', 'rawFunction', body))(dynCall, rawFunction);
|
6221 | }
|
6222 |
|
6223 | var fp;
|
6224 | if (Module['FUNCTION_TABLE_' + signature] !== undefined) {
|
6225 | fp = Module['FUNCTION_TABLE_' + signature][rawFunction];
|
6226 | } else if (typeof FUNCTION_TABLE !== "undefined") {
|
6227 | fp = FUNCTION_TABLE[rawFunction];
|
6228 | } else {
|
6229 |
|
6230 |
|
6231 |
|
6232 |
|
6233 |
|
6234 |
|
6235 |
|
6236 |
|
6237 |
|
6238 | var dc = Module['dynCall_' + signature];
|
6239 | if (dc === undefined) {
|
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 | dc = Module['dynCall_' + signature.replace(/f/g, 'd')];
|
6245 | if (dc === undefined) {
|
6246 | throwBindingError("No dynCall invoker for signature: " + signature);
|
6247 | }
|
6248 | }
|
6249 | fp = makeDynCaller(dc);
|
6250 | }
|
6251 |
|
6252 | if (typeof fp !== "function") {
|
6253 | throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
|
6254 | }
|
6255 | return fp;
|
6256 | }
|
6257 |
|
6258 |
|
6259 | var UnboundTypeError=undefined;
|
6260 |
|
6261 | function getTypeName(type) {
|
6262 | var ptr = ___getTypeName(type);
|
6263 | var rv = readLatin1String(ptr);
|
6264 | _free(ptr);
|
6265 | return rv;
|
6266 | }function throwUnboundTypeError(message, types) {
|
6267 | var unboundTypes = [];
|
6268 | var seen = {};
|
6269 | function visit(type) {
|
6270 | if (seen[type]) {
|
6271 | return;
|
6272 | }
|
6273 | if (registeredTypes[type]) {
|
6274 | return;
|
6275 | }
|
6276 | if (typeDependencies[type]) {
|
6277 | typeDependencies[type].forEach(visit);
|
6278 | return;
|
6279 | }
|
6280 | unboundTypes.push(type);
|
6281 | seen[type] = true;
|
6282 | }
|
6283 | types.forEach(visit);
|
6284 |
|
6285 | throw new UnboundTypeError(message + ': ' + unboundTypes.map(getTypeName).join([', ']));
|
6286 | }function __embind_register_class(
|
6287 | rawType,
|
6288 | rawPointerType,
|
6289 | rawConstPointerType,
|
6290 | baseClassRawType,
|
6291 | getActualTypeSignature,
|
6292 | getActualType,
|
6293 | upcastSignature,
|
6294 | upcast,
|
6295 | downcastSignature,
|
6296 | downcast,
|
6297 | name,
|
6298 | destructorSignature,
|
6299 | rawDestructor
|
6300 | ) {
|
6301 | name = readLatin1String(name);
|
6302 | getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
|
6303 | if (upcast) {
|
6304 | upcast = embind__requireFunction(upcastSignature, upcast);
|
6305 | }
|
6306 | if (downcast) {
|
6307 | downcast = embind__requireFunction(downcastSignature, downcast);
|
6308 | }
|
6309 | rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
|
6310 | var legalFunctionName = makeLegalFunctionName(name);
|
6311 |
|
6312 | exposePublicSymbol(legalFunctionName, function() {
|
6313 |
|
6314 | throwUnboundTypeError('Cannot construct ' + name + ' due to unbound types', [baseClassRawType]);
|
6315 | });
|
6316 |
|
6317 | whenDependentTypesAreResolved(
|
6318 | [rawType, rawPointerType, rawConstPointerType],
|
6319 | baseClassRawType ? [baseClassRawType] : [],
|
6320 | function(base) {
|
6321 | base = base[0];
|
6322 |
|
6323 | var baseClass;
|
6324 | var basePrototype;
|
6325 | if (baseClassRawType) {
|
6326 | baseClass = base.registeredClass;
|
6327 | basePrototype = baseClass.instancePrototype;
|
6328 | } else {
|
6329 | basePrototype = ClassHandle.prototype;
|
6330 | }
|
6331 |
|
6332 | var constructor = createNamedFunction(legalFunctionName, function() {
|
6333 | if (Object.getPrototypeOf(this) !== instancePrototype) {
|
6334 | throw new BindingError("Use 'new' to construct " + name);
|
6335 | }
|
6336 | if (undefined === registeredClass.constructor_body) {
|
6337 | throw new BindingError(name + " has no accessible constructor");
|
6338 | }
|
6339 | var body = registeredClass.constructor_body[arguments.length];
|
6340 | if (undefined === body) {
|
6341 | throw new BindingError("Tried to invoke ctor of " + name + " with invalid number of parameters (" + arguments.length + ") - expected (" + Object.keys(registeredClass.constructor_body).toString() + ") parameters instead!");
|
6342 | }
|
6343 | return body.apply(this, arguments);
|
6344 | });
|
6345 |
|
6346 | var instancePrototype = Object.create(basePrototype, {
|
6347 | constructor: { value: constructor },
|
6348 | });
|
6349 |
|
6350 | constructor.prototype = instancePrototype;
|
6351 |
|
6352 | var registeredClass = new RegisteredClass(
|
6353 | name,
|
6354 | constructor,
|
6355 | instancePrototype,
|
6356 | rawDestructor,
|
6357 | baseClass,
|
6358 | getActualType,
|
6359 | upcast,
|
6360 | downcast);
|
6361 |
|
6362 | var referenceConverter = new RegisteredPointer(
|
6363 | name,
|
6364 | registeredClass,
|
6365 | true,
|
6366 | false,
|
6367 | false);
|
6368 |
|
6369 | var pointerConverter = new RegisteredPointer(
|
6370 | name + '*',
|
6371 | registeredClass,
|
6372 | false,
|
6373 | false,
|
6374 | false);
|
6375 |
|
6376 | var constPointerConverter = new RegisteredPointer(
|
6377 | name + ' const*',
|
6378 | registeredClass,
|
6379 | false,
|
6380 | true,
|
6381 | false);
|
6382 |
|
6383 | registeredPointers[rawType] = {
|
6384 | pointerType: pointerConverter,
|
6385 | constPointerType: constPointerConverter
|
6386 | };
|
6387 |
|
6388 | replacePublicSymbol(legalFunctionName, constructor);
|
6389 |
|
6390 | return [referenceConverter, pointerConverter, constPointerConverter];
|
6391 | }
|
6392 | );
|
6393 | }
|
6394 |
|
6395 |
|
6396 | function heap32VectorToArray(count, firstElement) {
|
6397 | var array = [];
|
6398 | for (var i = 0; i < count; i++) {
|
6399 | array.push(HEAP32[(firstElement >> 2) + i]);
|
6400 | }
|
6401 | return array;
|
6402 | }
|
6403 |
|
6404 | function runDestructors(destructors) {
|
6405 | while (destructors.length) {
|
6406 | var ptr = destructors.pop();
|
6407 | var del = destructors.pop();
|
6408 | del(ptr);
|
6409 | }
|
6410 | }function __embind_register_class_constructor(
|
6411 | rawClassType,
|
6412 | argCount,
|
6413 | rawArgTypesAddr,
|
6414 | invokerSignature,
|
6415 | invoker,
|
6416 | rawConstructor
|
6417 | ) {
|
6418 | var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
6419 | invoker = embind__requireFunction(invokerSignature, invoker);
|
6420 |
|
6421 | whenDependentTypesAreResolved([], [rawClassType], function(classType) {
|
6422 | classType = classType[0];
|
6423 | var humanName = 'constructor ' + classType.name;
|
6424 |
|
6425 | if (undefined === classType.registeredClass.constructor_body) {
|
6426 | classType.registeredClass.constructor_body = [];
|
6427 | }
|
6428 | if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
|
6429 | throw new BindingError("Cannot register multiple constructors with identical number of parameters (" + (argCount-1) + ") for class '" + classType.name + "'! Overload resolution is currently only performed using the parameter count, not actual type info!");
|
6430 | }
|
6431 | classType.registeredClass.constructor_body[argCount - 1] = function unboundTypeHandler() {
|
6432 | throwUnboundTypeError('Cannot construct ' + classType.name + ' due to unbound types', rawArgTypes);
|
6433 | };
|
6434 |
|
6435 | whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {
|
6436 | classType.registeredClass.constructor_body[argCount - 1] = function constructor_body() {
|
6437 | if (arguments.length !== argCount - 1) {
|
6438 | throwBindingError(humanName + ' called with ' + arguments.length + ' arguments, expected ' + (argCount-1));
|
6439 | }
|
6440 | var destructors = [];
|
6441 | var args = new Array(argCount);
|
6442 | args[0] = rawConstructor;
|
6443 | for (var i = 1; i < argCount; ++i) {
|
6444 | args[i] = argTypes[i]['toWireType'](destructors, arguments[i - 1]);
|
6445 | }
|
6446 |
|
6447 | var ptr = invoker.apply(null, args);
|
6448 | runDestructors(destructors);
|
6449 |
|
6450 | return argTypes[0]['fromWireType'](ptr);
|
6451 | };
|
6452 | return [];
|
6453 | });
|
6454 | return [];
|
6455 | });
|
6456 | }
|
6457 |
|
6458 |
|
6459 |
|
6460 | function new_(constructor, argumentList) {
|
6461 | if (!(constructor instanceof Function)) {
|
6462 | throw new TypeError('new_ called with constructor type ' + typeof(constructor) + " which is not a function");
|
6463 | }
|
6464 |
|
6465 | /*
|
6466 | * Previously, the following line was just:
|
6467 |
|
6468 | function dummy() {};
|
6469 |
|
6470 | * Unfortunately, Chrome was preserving 'dummy' as the object's name, even though at creation, the 'dummy' has the
|
6471 | * correct constructor name. Thus, objects created with IMVU.new would show up in the debugger as 'dummy', which
|
6472 | * isn't very helpful. Using IMVU.createNamedFunction addresses the issue. Doublely-unfortunately, there's no way
|
6473 | * to write a test for this behavior. -NRD 2013.02.22
|
6474 | */
|
6475 | var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
|
6476 | dummy.prototype = constructor.prototype;
|
6477 | var obj = new dummy;
|
6478 |
|
6479 | var r = constructor.apply(obj, argumentList);
|
6480 | return (r instanceof Object) ? r : obj;
|
6481 | }function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc) {
|
6482 |
|
6483 |
|
6484 |
|
6485 |
|
6486 |
|
6487 |
|
6488 |
|
6489 |
|
6490 | var argCount = argTypes.length;
|
6491 |
|
6492 | if (argCount < 2) {
|
6493 | throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
6494 | }
|
6495 |
|
6496 | var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
|
6497 |
|
6498 |
|
6499 |
|
6500 |
|
6501 |
|
6502 |
|
6503 |
|
6504 |
|
6505 |
|
6506 |
|
6507 | var needsDestructorStack = false;
|
6508 |
|
6509 | for(var i = 1; i < argTypes.length; ++i) {
|
6510 | if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
|
6511 | needsDestructorStack = true;
|
6512 | break;
|
6513 | }
|
6514 | }
|
6515 |
|
6516 | var returns = (argTypes[0].name !== "void");
|
6517 |
|
6518 | var argsList = "";
|
6519 | var argsListWired = "";
|
6520 | for(var i = 0; i < argCount - 2; ++i) {
|
6521 | argsList += (i!==0?", ":"")+"arg"+i;
|
6522 | argsListWired += (i!==0?", ":"")+"arg"+i+"Wired";
|
6523 | }
|
6524 |
|
6525 | var invokerFnBody =
|
6526 | "return function "+makeLegalFunctionName(humanName)+"("+argsList+") {\n" +
|
6527 | "if (arguments.length !== "+(argCount - 2)+") {\n" +
|
6528 | "throwBindingError('function "+humanName+" called with ' + arguments.length + ' arguments, expected "+(argCount - 2)+" args!');\n" +
|
6529 | "}\n";
|
6530 |
|
6531 |
|
6532 | if (needsDestructorStack) {
|
6533 | invokerFnBody +=
|
6534 | "var destructors = [];\n";
|
6535 | }
|
6536 |
|
6537 | var dtorStack = needsDestructorStack ? "destructors" : "null";
|
6538 | var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
6539 | var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
6540 |
|
6541 |
|
6542 | if (isClassMethodFunc) {
|
6543 | invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
|
6544 | }
|
6545 |
|
6546 | for(var i = 0; i < argCount - 2; ++i) {
|
6547 | invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
|
6548 | args1.push("argType"+i);
|
6549 | args2.push(argTypes[i+2]);
|
6550 | }
|
6551 |
|
6552 | if (isClassMethodFunc) {
|
6553 | argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
|
6554 | }
|
6555 |
|
6556 | invokerFnBody +=
|
6557 | (returns?"var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
|
6558 |
|
6559 | if (needsDestructorStack) {
|
6560 | invokerFnBody += "runDestructors(destructors);\n";
|
6561 | } else {
|
6562 | for(var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) {
|
6563 | var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
|
6564 | if (argTypes[i].destructorFunction !== null) {
|
6565 | invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
|
6566 | args1.push(paramName+"_dtor");
|
6567 | args2.push(argTypes[i].destructorFunction);
|
6568 | }
|
6569 | }
|
6570 | }
|
6571 |
|
6572 | if (returns) {
|
6573 | invokerFnBody += "var ret = retType.fromWireType(rv);\n" +
|
6574 | "return ret;\n";
|
6575 | } else {
|
6576 | }
|
6577 | invokerFnBody += "}\n";
|
6578 |
|
6579 | args1.push(invokerFnBody);
|
6580 |
|
6581 | var invokerFunction = new_(Function, args1).apply(null, args2);
|
6582 | return invokerFunction;
|
6583 | }function __embind_register_class_function(
|
6584 | rawClassType,
|
6585 | methodName,
|
6586 | argCount,
|
6587 | rawArgTypesAddr, // [ReturnType, ThisType, Args...]
|
6588 | invokerSignature,
|
6589 | rawInvoker,
|
6590 | context,
|
6591 | isPureVirtual
|
6592 | ) {
|
6593 | var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
6594 | methodName = readLatin1String(methodName);
|
6595 | rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);
|
6596 |
|
6597 | whenDependentTypesAreResolved([], [rawClassType], function(classType) {
|
6598 | classType = classType[0];
|
6599 | var humanName = classType.name + '.' + methodName;
|
6600 |
|
6601 | if (isPureVirtual) {
|
6602 | classType.registeredClass.pureVirtualFunctions.push(methodName);
|
6603 | }
|
6604 |
|
6605 | function unboundTypesHandler() {
|
6606 | throwUnboundTypeError('Cannot call ' + humanName + ' due to unbound types', rawArgTypes);
|
6607 | }
|
6608 |
|
6609 | var proto = classType.registeredClass.instancePrototype;
|
6610 | var method = proto[methodName];
|
6611 | if (undefined === method || (undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2)) {
|
6612 |
|
6613 | unboundTypesHandler.argCount = argCount - 2;
|
6614 | unboundTypesHandler.className = classType.name;
|
6615 | proto[methodName] = unboundTypesHandler;
|
6616 | } else {
|
6617 |
|
6618 | ensureOverloadTable(proto, methodName, humanName);
|
6619 | proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
|
6620 | }
|
6621 |
|
6622 | whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {
|
6623 |
|
6624 | var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context);
|
6625 |
|
6626 |
|
6627 |
|
6628 | if (undefined === proto[methodName].overloadTable) {
|
6629 |
|
6630 | memberFunction.argCount = argCount - 2;
|
6631 | proto[methodName] = memberFunction;
|
6632 | } else {
|
6633 | proto[methodName].overloadTable[argCount - 2] = memberFunction;
|
6634 | }
|
6635 |
|
6636 | return [];
|
6637 | });
|
6638 | return [];
|
6639 | });
|
6640 | }
|
6641 |
|
6642 |
|
6643 |
|
6644 | var emval_free_list=[];
|
6645 |
|
6646 | var emval_handle_array=[{},{value:undefined},{value:null},{value:true},{value:false}];function __emval_decref(handle) {
|
6647 | if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {
|
6648 | emval_handle_array[handle] = undefined;
|
6649 | emval_free_list.push(handle);
|
6650 | }
|
6651 | }
|
6652 |
|
6653 |
|
6654 |
|
6655 | function count_emval_handles() {
|
6656 | var count = 0;
|
6657 | for (var i = 5; i < emval_handle_array.length; ++i) {
|
6658 | if (emval_handle_array[i] !== undefined) {
|
6659 | ++count;
|
6660 | }
|
6661 | }
|
6662 | return count;
|
6663 | }
|
6664 |
|
6665 | function get_first_emval() {
|
6666 | for (var i = 5; i < emval_handle_array.length; ++i) {
|
6667 | if (emval_handle_array[i] !== undefined) {
|
6668 | return emval_handle_array[i];
|
6669 | }
|
6670 | }
|
6671 | return null;
|
6672 | }function init_emval() {
|
6673 | Module['count_emval_handles'] = count_emval_handles;
|
6674 | Module['get_first_emval'] = get_first_emval;
|
6675 | }function __emval_register(value) {
|
6676 |
|
6677 | switch(value){
|
6678 | case undefined :{ return 1; }
|
6679 | case null :{ return 2; }
|
6680 | case true :{ return 3; }
|
6681 | case false :{ return 4; }
|
6682 | default:{
|
6683 | var handle = emval_free_list.length ?
|
6684 | emval_free_list.pop() :
|
6685 | emval_handle_array.length;
|
6686 |
|
6687 | emval_handle_array[handle] = {refcount: 1, value: value};
|
6688 | return handle;
|
6689 | }
|
6690 | }
|
6691 | }function __embind_register_emval(rawType, name) {
|
6692 | name = readLatin1String(name);
|
6693 | registerType(rawType, {
|
6694 | name: name,
|
6695 | 'fromWireType': function(handle) {
|
6696 | var rv = emval_handle_array[handle].value;
|
6697 | __emval_decref(handle);
|
6698 | return rv;
|
6699 | },
|
6700 | 'toWireType': function(destructors, value) {
|
6701 | return __emval_register(value);
|
6702 | },
|
6703 | 'argPackAdvance': 8,
|
6704 | 'readValueFromPointer': simpleReadValueFromPointer,
|
6705 | destructorFunction: null,
|
6706 |
|
6707 |
|
6708 |
|
6709 | });
|
6710 | }
|
6711 |
|
6712 |
|
6713 | function _embind_repr(v) {
|
6714 | if (v === null) {
|
6715 | return 'null';
|
6716 | }
|
6717 | var t = typeof v;
|
6718 | if (t === 'object' || t === 'array' || t === 'function') {
|
6719 | return v.toString();
|
6720 | } else {
|
6721 | return '' + v;
|
6722 | }
|
6723 | }
|
6724 |
|
6725 | function floatReadValueFromPointer(name, shift) {
|
6726 | switch (shift) {
|
6727 | case 2: return function(pointer) {
|
6728 | return this['fromWireType'](HEAPF32[pointer >> 2]);
|
6729 | };
|
6730 | case 3: return function(pointer) {
|
6731 | return this['fromWireType'](HEAPF64[pointer >> 3]);
|
6732 | };
|
6733 | default:
|
6734 | throw new TypeError("Unknown float type: " + name);
|
6735 | }
|
6736 | }function __embind_register_float(rawType, name, size) {
|
6737 | var shift = getShiftFromSize(size);
|
6738 | name = readLatin1String(name);
|
6739 | registerType(rawType, {
|
6740 | name: name,
|
6741 | 'fromWireType': function(value) {
|
6742 | return value;
|
6743 | },
|
6744 | 'toWireType': function(destructors, value) {
|
6745 |
|
6746 |
|
6747 | if (typeof value !== "number" && typeof value !== "boolean") {
|
6748 | throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
|
6749 | }
|
6750 | return value;
|
6751 | },
|
6752 | 'argPackAdvance': 8,
|
6753 | 'readValueFromPointer': floatReadValueFromPointer(name, shift),
|
6754 | destructorFunction: null,
|
6755 | });
|
6756 | }
|
6757 |
|
6758 |
|
6759 | function integerReadValueFromPointer(name, shift, signed) {
|
6760 |
|
6761 | switch (shift) {
|
6762 | case 0: return signed ?
|
6763 | function readS8FromPointer(pointer) { return HEAP8[pointer]; } :
|
6764 | function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
|
6765 | case 1: return signed ?
|
6766 | function readS16FromPointer(pointer) { return HEAP16[pointer >> 1]; } :
|
6767 | function readU16FromPointer(pointer) { return HEAPU16[pointer >> 1]; };
|
6768 | case 2: return signed ?
|
6769 | function readS32FromPointer(pointer) { return HEAP32[pointer >> 2]; } :
|
6770 | function readU32FromPointer(pointer) { return HEAPU32[pointer >> 2]; };
|
6771 | default:
|
6772 | throw new TypeError("Unknown integer type: " + name);
|
6773 | }
|
6774 | }function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {
|
6775 | name = readLatin1String(name);
|
6776 | if (maxRange === -1) {
|
6777 | maxRange = 4294967295;
|
6778 | }
|
6779 |
|
6780 | var shift = getShiftFromSize(size);
|
6781 |
|
6782 | var fromWireType = function(value) {
|
6783 | return value;
|
6784 | };
|
6785 |
|
6786 | if (minRange === 0) {
|
6787 | var bitshift = 32 - 8*size;
|
6788 | fromWireType = function(value) {
|
6789 | return (value << bitshift) >>> bitshift;
|
6790 | };
|
6791 | }
|
6792 |
|
6793 | var isUnsignedType = (name.indexOf('unsigned') != -1);
|
6794 |
|
6795 | registerType(primitiveType, {
|
6796 | name: name,
|
6797 | 'fromWireType': fromWireType,
|
6798 | 'toWireType': function(destructors, value) {
|
6799 |
|
6800 |
|
6801 | if (typeof value !== "number" && typeof value !== "boolean") {
|
6802 | throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
|
6803 | }
|
6804 | if (value < minRange || value > maxRange) {
|
6805 | throw new TypeError('Passing a number "' + _embind_repr(value) + '" from JS side to C/C++ side to an argument of type "' + name + '", which is outside the valid range [' + minRange + ', ' + maxRange + ']!');
|
6806 | }
|
6807 | return isUnsignedType ? (value >>> 0) : (value | 0);
|
6808 | },
|
6809 | 'argPackAdvance': 8,
|
6810 | 'readValueFromPointer': integerReadValueFromPointer(name, shift, minRange !== 0),
|
6811 | destructorFunction: null,
|
6812 | });
|
6813 | }
|
6814 |
|
6815 | function __embind_register_memory_view(rawType, dataTypeIndex, name) {
|
6816 | var typeMapping = [
|
6817 | Int8Array,
|
6818 | Uint8Array,
|
6819 | Int16Array,
|
6820 | Uint16Array,
|
6821 | Int32Array,
|
6822 | Uint32Array,
|
6823 | Float32Array,
|
6824 | Float64Array,
|
6825 | ];
|
6826 |
|
6827 | var TA = typeMapping[dataTypeIndex];
|
6828 |
|
6829 | function decodeMemoryView(handle) {
|
6830 | handle = handle >> 2;
|
6831 | var heap = HEAPU32;
|
6832 | var size = heap[handle];
|
6833 | var data = heap[handle + 1];
|
6834 | return new TA(heap['buffer'], data, size);
|
6835 | }
|
6836 |
|
6837 | name = readLatin1String(name);
|
6838 | registerType(rawType, {
|
6839 | name: name,
|
6840 | 'fromWireType': decodeMemoryView,
|
6841 | 'argPackAdvance': 8,
|
6842 | 'readValueFromPointer': decodeMemoryView,
|
6843 | }, {
|
6844 | ignoreDuplicateRegistrations: true,
|
6845 | });
|
6846 | }
|
6847 |
|
6848 | function __embind_register_std_string(rawType, name) {
|
6849 | name = readLatin1String(name);
|
6850 | var stdStringIsUTF8
|
6851 |
|
6852 | = (name === "std::string");
|
6853 |
|
6854 | registerType(rawType, {
|
6855 | name: name,
|
6856 | 'fromWireType': function(value) {
|
6857 | var length = HEAPU32[value >> 2];
|
6858 |
|
6859 | var str;
|
6860 | if(stdStringIsUTF8) {
|
6861 |
|
6862 | var endChar = HEAPU8[value + 4 + length];
|
6863 | var endCharSwap = 0;
|
6864 | if(endChar != 0)
|
6865 | {
|
6866 | endCharSwap = endChar;
|
6867 | HEAPU8[value + 4 + length] = 0;
|
6868 | }
|
6869 |
|
6870 | var decodeStartPtr = value + 4;
|
6871 |
|
6872 | for (var i = 0; i <= length; ++i) {
|
6873 | var currentBytePtr = value + 4 + i;
|
6874 | if(HEAPU8[currentBytePtr] == 0)
|
6875 | {
|
6876 | var stringSegment = UTF8ToString(decodeStartPtr);
|
6877 | if(str === undefined)
|
6878 | str = stringSegment;
|
6879 | else
|
6880 | {
|
6881 | str += String.fromCharCode(0);
|
6882 | str += stringSegment;
|
6883 | }
|
6884 | decodeStartPtr = currentBytePtr + 1;
|
6885 | }
|
6886 | }
|
6887 |
|
6888 | if(endCharSwap != 0)
|
6889 | HEAPU8[value + 4 + length] = endCharSwap;
|
6890 | } else {
|
6891 | var a = new Array(length);
|
6892 | for (var i = 0; i < length; ++i) {
|
6893 | a[i] = String.fromCharCode(HEAPU8[value + 4 + i]);
|
6894 | }
|
6895 | str = a.join('');
|
6896 | }
|
6897 |
|
6898 | _free(value);
|
6899 |
|
6900 | return str;
|
6901 | },
|
6902 | 'toWireType': function(destructors, value) {
|
6903 | if (value instanceof ArrayBuffer) {
|
6904 | value = new Uint8Array(value);
|
6905 | }
|
6906 |
|
6907 | var getLength;
|
6908 | var valueIsOfTypeString = (typeof value === 'string');
|
6909 |
|
6910 | if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
|
6911 | throwBindingError('Cannot pass non-string to std::string');
|
6912 | }
|
6913 | if (stdStringIsUTF8 && valueIsOfTypeString) {
|
6914 | getLength = function() {return lengthBytesUTF8(value);};
|
6915 | } else {
|
6916 | getLength = function() {return value.length;};
|
6917 | }
|
6918 |
|
6919 |
|
6920 | var length = getLength();
|
6921 | var ptr = _malloc(4 + length + 1);
|
6922 | HEAPU32[ptr >> 2] = length;
|
6923 |
|
6924 | if (stdStringIsUTF8 && valueIsOfTypeString) {
|
6925 | stringToUTF8(value, ptr + 4, length + 1);
|
6926 | } else {
|
6927 | if(valueIsOfTypeString) {
|
6928 | for (var i = 0; i < length; ++i) {
|
6929 | var charCode = value.charCodeAt(i);
|
6930 | if (charCode > 255) {
|
6931 | _free(ptr);
|
6932 | throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
|
6933 | }
|
6934 | HEAPU8[ptr + 4 + i] = charCode;
|
6935 | }
|
6936 | } else {
|
6937 | for (var i = 0; i < length; ++i) {
|
6938 | HEAPU8[ptr + 4 + i] = value[i];
|
6939 | }
|
6940 | }
|
6941 | }
|
6942 |
|
6943 | if (destructors !== null) {
|
6944 | destructors.push(_free, ptr);
|
6945 | }
|
6946 | return ptr;
|
6947 | },
|
6948 | 'argPackAdvance': 8,
|
6949 | 'readValueFromPointer': simpleReadValueFromPointer,
|
6950 | destructorFunction: function(ptr) { _free(ptr); },
|
6951 | });
|
6952 | }
|
6953 |
|
6954 | function __embind_register_std_wstring(rawType, charSize, name) {
|
6955 |
|
6956 | name = readLatin1String(name);
|
6957 | var getHeap, shift;
|
6958 | if (charSize === 2) {
|
6959 | getHeap = function() { return HEAPU16; };
|
6960 | shift = 1;
|
6961 | } else if (charSize === 4) {
|
6962 | getHeap = function() { return HEAPU32; };
|
6963 | shift = 2;
|
6964 | }
|
6965 | registerType(rawType, {
|
6966 | name: name,
|
6967 | 'fromWireType': function(value) {
|
6968 | var HEAP = getHeap();
|
6969 | var length = HEAPU32[value >> 2];
|
6970 | var a = new Array(length);
|
6971 | var start = (value + 4) >> shift;
|
6972 | for (var i = 0; i < length; ++i) {
|
6973 | a[i] = String.fromCharCode(HEAP[start + i]);
|
6974 | }
|
6975 | _free(value);
|
6976 | return a.join('');
|
6977 | },
|
6978 | 'toWireType': function(destructors, value) {
|
6979 |
|
6980 | var HEAP = getHeap();
|
6981 | var length = value.length;
|
6982 | var ptr = _malloc(4 + length * charSize);
|
6983 | HEAPU32[ptr >> 2] = length;
|
6984 | var start = (ptr + 4) >> shift;
|
6985 | for (var i = 0; i < length; ++i) {
|
6986 | HEAP[start + i] = value.charCodeAt(i);
|
6987 | }
|
6988 | if (destructors !== null) {
|
6989 | destructors.push(_free, ptr);
|
6990 | }
|
6991 | return ptr;
|
6992 | },
|
6993 | 'argPackAdvance': 8,
|
6994 | 'readValueFromPointer': simpleReadValueFromPointer,
|
6995 | destructorFunction: function(ptr) { _free(ptr); },
|
6996 | });
|
6997 | }
|
6998 |
|
6999 | function __embind_register_void(rawType, name) {
|
7000 | name = readLatin1String(name);
|
7001 | registerType(rawType, {
|
7002 | isVoid: true,
|
7003 | name: name,
|
7004 | 'argPackAdvance': 0,
|
7005 | 'fromWireType': function() {
|
7006 | return undefined;
|
7007 | },
|
7008 | 'toWireType': function(destructors, o) {
|
7009 |
|
7010 | return undefined;
|
7011 | },
|
7012 | });
|
7013 | }
|
7014 |
|
7015 |
|
7016 | function requireHandle(handle) {
|
7017 | if (!handle) {
|
7018 | throwBindingError('Cannot use deleted val. handle = ' + handle);
|
7019 | }
|
7020 | return emval_handle_array[handle].value;
|
7021 | }
|
7022 |
|
7023 | function requireRegisteredType(rawType, humanName) {
|
7024 | var impl = registeredTypes[rawType];
|
7025 | if (undefined === impl) {
|
7026 | throwBindingError(humanName + " has unknown type " + getTypeName(rawType));
|
7027 | }
|
7028 | return impl;
|
7029 | }function __emval_as(handle, returnType, destructorsRef) {
|
7030 | handle = requireHandle(handle);
|
7031 | returnType = requireRegisteredType(returnType, 'emval::as');
|
7032 | var destructors = [];
|
7033 | var rd = __emval_register(destructors);
|
7034 | HEAP32[destructorsRef >> 2] = rd;
|
7035 | return returnType['toWireType'](destructors, handle);
|
7036 | }
|
7037 |
|
7038 |
|
7039 | function __emval_allocateDestructors(destructorsRef) {
|
7040 | var destructors = [];
|
7041 | HEAP32[destructorsRef >> 2] = __emval_register(destructors);
|
7042 | return destructors;
|
7043 | }
|
7044 |
|
7045 |
|
7046 | var emval_symbols={};function getStringOrSymbol(address) {
|
7047 | var symbol = emval_symbols[address];
|
7048 | if (symbol === undefined) {
|
7049 | return readLatin1String(address);
|
7050 | } else {
|
7051 | return symbol;
|
7052 | }
|
7053 | }
|
7054 |
|
7055 | var emval_methodCallers=[];function __emval_call_method(caller, handle, methodName, destructorsRef, args) {
|
7056 | caller = emval_methodCallers[caller];
|
7057 | handle = requireHandle(handle);
|
7058 | methodName = getStringOrSymbol(methodName);
|
7059 | return caller(handle, methodName, __emval_allocateDestructors(destructorsRef), args);
|
7060 | }
|
7061 |
|
7062 |
|
7063 |
|
7064 | function emval_get_global() { return (function(){return Function;})()('return this')(); }function __emval_get_global(name) {
|
7065 | if(name===0){
|
7066 | return __emval_register(emval_get_global());
|
7067 | } else {
|
7068 | name = getStringOrSymbol(name);
|
7069 | return __emval_register(emval_get_global()[name]);
|
7070 | }
|
7071 | }
|
7072 |
|
7073 |
|
7074 | function __emval_addMethodCaller(caller) {
|
7075 | var id = emval_methodCallers.length;
|
7076 | emval_methodCallers.push(caller);
|
7077 | return id;
|
7078 | }
|
7079 |
|
7080 | function __emval_lookupTypes(argCount, argTypes, argWireTypes) {
|
7081 | var a = new Array(argCount);
|
7082 | for (var i = 0; i < argCount; ++i) {
|
7083 | a[i] = requireRegisteredType(
|
7084 | HEAP32[(argTypes >> 2) + i],
|
7085 | "parameter " + i);
|
7086 | }
|
7087 | return a;
|
7088 | }function __emval_get_method_caller(argCount, argTypes) {
|
7089 | var types = __emval_lookupTypes(argCount, argTypes);
|
7090 |
|
7091 | var retType = types[0];
|
7092 | var signatureName = retType.name + "_$" + types.slice(1).map(function (t) { return t.name; }).join("_") + "$";
|
7093 |
|
7094 | var params = ["retType"];
|
7095 | var args = [retType];
|
7096 |
|
7097 | var argsList = "";
|
7098 | for (var i = 0; i < argCount - 1; ++i) {
|
7099 | argsList += (i !== 0 ? ", " : "") + "arg" + i;
|
7100 | params.push("argType" + i);
|
7101 | args.push(types[1 + i]);
|
7102 | }
|
7103 |
|
7104 | var functionName = makeLegalFunctionName("methodCaller_" + signatureName);
|
7105 | var functionBody =
|
7106 | "return function " + functionName + "(handle, name, destructors, args) {\n";
|
7107 |
|
7108 | var offset = 0;
|
7109 | for (var i = 0; i < argCount - 1; ++i) {
|
7110 | functionBody +=
|
7111 | " var arg" + i + " = argType" + i + ".readValueFromPointer(args" + (offset ? ("+"+offset) : "") + ");\n";
|
7112 | offset += types[i + 1]['argPackAdvance'];
|
7113 | }
|
7114 | functionBody +=
|
7115 | " var rv = handle[name](" + argsList + ");\n";
|
7116 | for (var i = 0; i < argCount - 1; ++i) {
|
7117 | if (types[i + 1]['deleteObject']) {
|
7118 | functionBody +=
|
7119 | " argType" + i + ".deleteObject(arg" + i + ");\n";
|
7120 | }
|
7121 | }
|
7122 | if (!retType.isVoid) {
|
7123 | functionBody +=
|
7124 | " return retType.toWireType(destructors, rv);\n";
|
7125 | }
|
7126 | functionBody +=
|
7127 | "};\n";
|
7128 |
|
7129 | params.push(functionBody);
|
7130 | var invokerFunction = new_(Function, params).apply(null, args);
|
7131 | return __emval_addMethodCaller(invokerFunction);
|
7132 | }
|
7133 |
|
7134 | function __emval_get_property(handle, key) {
|
7135 | handle = requireHandle(handle);
|
7136 | key = requireHandle(key);
|
7137 | return __emval_register(handle[key]);
|
7138 | }
|
7139 |
|
7140 | function __emval_incref(handle) {
|
7141 | if (handle > 4) {
|
7142 | emval_handle_array[handle].refcount += 1;
|
7143 | }
|
7144 | }
|
7145 |
|
7146 | function __emval_new_array() {
|
7147 | return __emval_register([]);
|
7148 | }
|
7149 |
|
7150 | function __emval_new_cstring(v) {
|
7151 | return __emval_register(getStringOrSymbol(v));
|
7152 | }
|
7153 |
|
7154 | function __emval_new_object() {
|
7155 | return __emval_register({});
|
7156 | }
|
7157 |
|
7158 | function __emval_run_destructors(handle) {
|
7159 | var destructors = emval_handle_array[handle].value;
|
7160 | runDestructors(destructors);
|
7161 | __emval_decref(handle);
|
7162 | }
|
7163 |
|
7164 | function __emval_set_property(handle, key, value) {
|
7165 | handle = requireHandle(handle);
|
7166 | key = requireHandle(key);
|
7167 | value = requireHandle(value);
|
7168 | handle[key] = value;
|
7169 | }
|
7170 |
|
7171 | function __emval_take_value(type, argv) {
|
7172 | type = requireRegisteredType(type, '_emval_take_value');
|
7173 | var v = type['readValueFromPointer'](argv);
|
7174 | return __emval_register(v);
|
7175 | }
|
7176 |
|
7177 | function _abort() {
|
7178 | Module['abort']();
|
7179 | }
|
7180 |
|
7181 | function _atexit(func, arg) {
|
7182 | warnOnce('atexit() called, but EXIT_RUNTIME is not set, so atexits() will not be called. set EXIT_RUNTIME to 1 (see the FAQ)');
|
7183 | __ATEXIT__.unshift({ func: func, arg: arg });
|
7184 | }
|
7185 |
|
7186 | function _getenv(name) {
|
7187 |
|
7188 |
|
7189 | if (name === 0) return 0;
|
7190 | name = Pointer_stringify(name);
|
7191 | if (!ENV.hasOwnProperty(name)) return 0;
|
7192 |
|
7193 | if (_getenv.ret) _free(_getenv.ret);
|
7194 | _getenv.ret = allocateUTF8(ENV[name]);
|
7195 | return _getenv.ret;
|
7196 | }
|
7197 |
|
7198 | function _gettimeofday(ptr) {
|
7199 | var now = Date.now();
|
7200 | HEAP32[((ptr)>>2)]=(now/1000)|0;
|
7201 | HEAP32[(((ptr)+(4))>>2)]=((now % 1000)*1000)|0;
|
7202 | return 0;
|
7203 | }
|
7204 |
|
7205 |
|
7206 |
|
7207 | function _llvm_stackrestore(p) {
|
7208 | var self = _llvm_stacksave;
|
7209 | var ret = self.LLVM_SAVEDSTACKS[p];
|
7210 | self.LLVM_SAVEDSTACKS.splice(p, 1);
|
7211 | stackRestore(ret);
|
7212 | }
|
7213 |
|
7214 | function _llvm_stacksave() {
|
7215 | var self = _llvm_stacksave;
|
7216 | if (!self.LLVM_SAVEDSTACKS) {
|
7217 | self.LLVM_SAVEDSTACKS = [];
|
7218 | }
|
7219 | self.LLVM_SAVEDSTACKS.push(stackSave());
|
7220 | return self.LLVM_SAVEDSTACKS.length-1;
|
7221 | }
|
7222 |
|
7223 | function _llvm_trap() {
|
7224 | abort('trap!');
|
7225 | }
|
7226 |
|
7227 |
|
7228 | function _emscripten_memcpy_big(dest, src, num) {
|
7229 | HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
|
7230 | return dest;
|
7231 | }
|
7232 |
|
7233 |
|
7234 |
|
7235 |
|
7236 |
|
7237 |
|
7238 |
|
7239 | function _pthread_cond_wait() { return 0; }
|
7240 |
|
7241 |
|
7242 | var PTHREAD_SPECIFIC={};function _pthread_getspecific(key) {
|
7243 | return PTHREAD_SPECIFIC[key] || 0;
|
7244 | }
|
7245 |
|
7246 |
|
7247 | var PTHREAD_SPECIFIC_NEXT_KEY=1;function _pthread_key_create(key, destructor) {
|
7248 | if (key == 0) {
|
7249 | return ERRNO_CODES.EINVAL;
|
7250 | }
|
7251 | HEAP32[((key)>>2)]=PTHREAD_SPECIFIC_NEXT_KEY;
|
7252 |
|
7253 | PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY] = 0;
|
7254 | PTHREAD_SPECIFIC_NEXT_KEY++;
|
7255 | return 0;
|
7256 | }
|
7257 |
|
7258 |
|
7259 |
|
7260 |
|
7261 |
|
7262 | function _pthread_once(ptr, func) {
|
7263 | if (!_pthread_once.seen) _pthread_once.seen = {};
|
7264 | if (ptr in _pthread_once.seen) return;
|
7265 | Module['dynCall_v'](func);
|
7266 | _pthread_once.seen[ptr] = 1;
|
7267 | }
|
7268 |
|
7269 | function _pthread_rwlock_destroy() { return 0; }
|
7270 |
|
7271 | function _pthread_rwlock_init() { return 0; }
|
7272 |
|
7273 | function _pthread_rwlock_rdlock() { return 0; }
|
7274 |
|
7275 | function _pthread_rwlock_unlock() { return 0; }
|
7276 |
|
7277 | function _pthread_rwlock_wrlock() { return 0; }
|
7278 |
|
7279 | function _pthread_setspecific(key, value) {
|
7280 | if (!(key in PTHREAD_SPECIFIC)) {
|
7281 | return ERRNO_CODES.EINVAL;
|
7282 | }
|
7283 | PTHREAD_SPECIFIC[key] = value;
|
7284 | return 0;
|
7285 | }
|
7286 |
|
7287 |
|
7288 |
|
7289 |
|
7290 |
|
7291 | function __isLeapYear(year) {
|
7292 | return year%4 === 0 && (year%100 !== 0 || year%400 === 0);
|
7293 | }
|
7294 |
|
7295 | function __arraySum(array, index) {
|
7296 | var sum = 0;
|
7297 | for (var i = 0; i <= index; sum += array[i++]);
|
7298 | return sum;
|
7299 | }
|
7300 |
|
7301 |
|
7302 | var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];
|
7303 |
|
7304 | var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date, days) {
|
7305 | var newDate = new Date(date.getTime());
|
7306 | while(days > 0) {
|
7307 | var leap = __isLeapYear(newDate.getFullYear());
|
7308 | var currentMonth = newDate.getMonth();
|
7309 | var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];
|
7310 |
|
7311 | if (days > daysInCurrentMonth-newDate.getDate()) {
|
7312 |
|
7313 | days -= (daysInCurrentMonth-newDate.getDate()+1);
|
7314 | newDate.setDate(1);
|
7315 | if (currentMonth < 11) {
|
7316 | newDate.setMonth(currentMonth+1)
|
7317 | } else {
|
7318 | newDate.setMonth(0);
|
7319 | newDate.setFullYear(newDate.getFullYear()+1);
|
7320 | }
|
7321 | } else {
|
7322 |
|
7323 | newDate.setDate(newDate.getDate()+days);
|
7324 | return newDate;
|
7325 | }
|
7326 | }
|
7327 |
|
7328 | return newDate;
|
7329 | }function _strftime(s, maxsize, format, tm) {
|
7330 |
|
7331 |
|
7332 |
|
7333 | var tm_zone = HEAP32[(((tm)+(40))>>2)];
|
7334 |
|
7335 | var date = {
|
7336 | tm_sec: HEAP32[((tm)>>2)],
|
7337 | tm_min: HEAP32[(((tm)+(4))>>2)],
|
7338 | tm_hour: HEAP32[(((tm)+(8))>>2)],
|
7339 | tm_mday: HEAP32[(((tm)+(12))>>2)],
|
7340 | tm_mon: HEAP32[(((tm)+(16))>>2)],
|
7341 | tm_year: HEAP32[(((tm)+(20))>>2)],
|
7342 | tm_wday: HEAP32[(((tm)+(24))>>2)],
|
7343 | tm_yday: HEAP32[(((tm)+(28))>>2)],
|
7344 | tm_isdst: HEAP32[(((tm)+(32))>>2)],
|
7345 | tm_gmtoff: HEAP32[(((tm)+(36))>>2)],
|
7346 | tm_zone: tm_zone ? Pointer_stringify(tm_zone) : ''
|
7347 | };
|
7348 |
|
7349 | var pattern = Pointer_stringify(format);
|
7350 |
|
7351 |
|
7352 | var EXPANSION_RULES_1 = {
|
7353 | '%c': '%a %b %d %H:%M:%S %Y',
|
7354 | '%D': '%m/%d/%y',
|
7355 | '%F': '%Y-%m-%d',
|
7356 | '%h': '%b',
|
7357 | '%r': '%I:%M:%S %p',
|
7358 | '%R': '%H:%M',
|
7359 | '%T': '%H:%M:%S',
|
7360 | '%x': '%m/%d/%y',
|
7361 | '%X': '%H:%M:%S'
|
7362 | };
|
7363 | for (var rule in EXPANSION_RULES_1) {
|
7364 | pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_1[rule]);
|
7365 | }
|
7366 |
|
7367 | var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
7368 | var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
7369 |
|
7370 | function leadingSomething(value, digits, character) {
|
7371 | var str = typeof value === 'number' ? value.toString() : (value || '');
|
7372 | while (str.length < digits) {
|
7373 | str = character[0]+str;
|
7374 | }
|
7375 | return str;
|
7376 | };
|
7377 |
|
7378 | function leadingNulls(value, digits) {
|
7379 | return leadingSomething(value, digits, '0');
|
7380 | };
|
7381 |
|
7382 | function compareByDay(date1, date2) {
|
7383 | function sgn(value) {
|
7384 | return value < 0 ? -1 : (value > 0 ? 1 : 0);
|
7385 | };
|
7386 |
|
7387 | var compare;
|
7388 | if ((compare = sgn(date1.getFullYear()-date2.getFullYear())) === 0) {
|
7389 | if ((compare = sgn(date1.getMonth()-date2.getMonth())) === 0) {
|
7390 | compare = sgn(date1.getDate()-date2.getDate());
|
7391 | }
|
7392 | }
|
7393 | return compare;
|
7394 | };
|
7395 |
|
7396 | function getFirstWeekStartDate(janFourth) {
|
7397 | switch (janFourth.getDay()) {
|
7398 | case 0:
|
7399 | return new Date(janFourth.getFullYear()-1, 11, 29);
|
7400 | case 1:
|
7401 | return janFourth;
|
7402 | case 2:
|
7403 | return new Date(janFourth.getFullYear(), 0, 3);
|
7404 | case 3:
|
7405 | return new Date(janFourth.getFullYear(), 0, 2);
|
7406 | case 4:
|
7407 | return new Date(janFourth.getFullYear(), 0, 1);
|
7408 | case 5:
|
7409 | return new Date(janFourth.getFullYear()-1, 11, 31);
|
7410 | case 6:
|
7411 | return new Date(janFourth.getFullYear()-1, 11, 30);
|
7412 | }
|
7413 | };
|
7414 |
|
7415 | function getWeekBasedYear(date) {
|
7416 | var thisDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
|
7417 |
|
7418 | var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);
|
7419 | var janFourthNextYear = new Date(thisDate.getFullYear()+1, 0, 4);
|
7420 |
|
7421 | var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
|
7422 | var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
|
7423 |
|
7424 | if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {
|
7425 |
|
7426 | if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {
|
7427 | return thisDate.getFullYear()+1;
|
7428 | } else {
|
7429 | return thisDate.getFullYear();
|
7430 | }
|
7431 | } else {
|
7432 | return thisDate.getFullYear()-1;
|
7433 | }
|
7434 | };
|
7435 |
|
7436 | var EXPANSION_RULES_2 = {
|
7437 | '%a': function(date) {
|
7438 | return WEEKDAYS[date.tm_wday].substring(0,3);
|
7439 | },
|
7440 | '%A': function(date) {
|
7441 | return WEEKDAYS[date.tm_wday];
|
7442 | },
|
7443 | '%b': function(date) {
|
7444 | return MONTHS[date.tm_mon].substring(0,3);
|
7445 | },
|
7446 | '%B': function(date) {
|
7447 | return MONTHS[date.tm_mon];
|
7448 | },
|
7449 | '%C': function(date) {
|
7450 | var year = date.tm_year+1900;
|
7451 | return leadingNulls((year/100)|0,2);
|
7452 | },
|
7453 | '%d': function(date) {
|
7454 | return leadingNulls(date.tm_mday, 2);
|
7455 | },
|
7456 | '%e': function(date) {
|
7457 | return leadingSomething(date.tm_mday, 2, ' ');
|
7458 | },
|
7459 | '%g': function(date) {
|
7460 |
|
7461 |
|
7462 |
|
7463 |
|
7464 |
|
7465 |
|
7466 |
|
7467 |
|
7468 |
|
7469 |
|
7470 | return getWeekBasedYear(date).toString().substring(2);
|
7471 | },
|
7472 | '%G': function(date) {
|
7473 | return getWeekBasedYear(date);
|
7474 | },
|
7475 | '%H': function(date) {
|
7476 | return leadingNulls(date.tm_hour, 2);
|
7477 | },
|
7478 | '%I': function(date) {
|
7479 | var twelveHour = date.tm_hour;
|
7480 | if (twelveHour == 0) twelveHour = 12;
|
7481 | else if (twelveHour > 12) twelveHour -= 12;
|
7482 | return leadingNulls(twelveHour, 2);
|
7483 | },
|
7484 | '%j': function(date) {
|
7485 |
|
7486 | return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date.tm_mon-1), 3);
|
7487 | },
|
7488 | '%m': function(date) {
|
7489 | return leadingNulls(date.tm_mon+1, 2);
|
7490 | },
|
7491 | '%M': function(date) {
|
7492 | return leadingNulls(date.tm_min, 2);
|
7493 | },
|
7494 | '%n': function() {
|
7495 | return '\n';
|
7496 | },
|
7497 | '%p': function(date) {
|
7498 | if (date.tm_hour >= 0 && date.tm_hour < 12) {
|
7499 | return 'AM';
|
7500 | } else {
|
7501 | return 'PM';
|
7502 | }
|
7503 | },
|
7504 | '%S': function(date) {
|
7505 | return leadingNulls(date.tm_sec, 2);
|
7506 | },
|
7507 | '%t': function() {
|
7508 | return '\t';
|
7509 | },
|
7510 | '%u': function(date) {
|
7511 | var day = new Date(date.tm_year+1900, date.tm_mon+1, date.tm_mday, 0, 0, 0, 0);
|
7512 | return day.getDay() || 7;
|
7513 | },
|
7514 | '%U': function(date) {
|
7515 |
|
7516 |
|
7517 |
|
7518 | var janFirst = new Date(date.tm_year+1900, 0, 1);
|
7519 | var firstSunday = janFirst.getDay() === 0 ? janFirst : __addDays(janFirst, 7-janFirst.getDay());
|
7520 | var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
|
7521 |
|
7522 |
|
7523 | if (compareByDay(firstSunday, endDate) < 0) {
|
7524 |
|
7525 | var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
|
7526 | var firstSundayUntilEndJanuary = 31-firstSunday.getDate();
|
7527 | var days = firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
|
7528 | return leadingNulls(Math.ceil(days/7), 2);
|
7529 | }
|
7530 |
|
7531 | return compareByDay(firstSunday, janFirst) === 0 ? '01': '00';
|
7532 | },
|
7533 | '%V': function(date) {
|
7534 |
|
7535 |
|
7536 |
|
7537 |
|
7538 |
|
7539 | var janFourthThisYear = new Date(date.tm_year+1900, 0, 4);
|
7540 | var janFourthNextYear = new Date(date.tm_year+1901, 0, 4);
|
7541 |
|
7542 | var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
|
7543 | var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
|
7544 |
|
7545 | var endDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
|
7546 |
|
7547 | if (compareByDay(endDate, firstWeekStartThisYear) < 0) {
|
7548 |
|
7549 | return '53';
|
7550 | }
|
7551 |
|
7552 | if (compareByDay(firstWeekStartNextYear, endDate) <= 0) {
|
7553 |
|
7554 | return '01';
|
7555 | }
|
7556 |
|
7557 |
|
7558 | var daysDifference;
|
7559 | if (firstWeekStartThisYear.getFullYear() < date.tm_year+1900) {
|
7560 |
|
7561 | daysDifference = date.tm_yday+32-firstWeekStartThisYear.getDate()
|
7562 | } else {
|
7563 |
|
7564 | daysDifference = date.tm_yday+1-firstWeekStartThisYear.getDate();
|
7565 | }
|
7566 | return leadingNulls(Math.ceil(daysDifference/7), 2);
|
7567 | },
|
7568 | '%w': function(date) {
|
7569 | var day = new Date(date.tm_year+1900, date.tm_mon+1, date.tm_mday, 0, 0, 0, 0);
|
7570 | return day.getDay();
|
7571 | },
|
7572 | '%W': function(date) {
|
7573 |
|
7574 |
|
7575 |
|
7576 | var janFirst = new Date(date.tm_year, 0, 1);
|
7577 | var firstMonday = janFirst.getDay() === 1 ? janFirst : __addDays(janFirst, janFirst.getDay() === 0 ? 1 : 7-janFirst.getDay()+1);
|
7578 | var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
|
7579 |
|
7580 |
|
7581 | if (compareByDay(firstMonday, endDate) < 0) {
|
7582 | var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
|
7583 | var firstMondayUntilEndJanuary = 31-firstMonday.getDate();
|
7584 | var days = firstMondayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
|
7585 | return leadingNulls(Math.ceil(days/7), 2);
|
7586 | }
|
7587 | return compareByDay(firstMonday, janFirst) === 0 ? '01': '00';
|
7588 | },
|
7589 | '%y': function(date) {
|
7590 |
|
7591 | return (date.tm_year+1900).toString().substring(2);
|
7592 | },
|
7593 | '%Y': function(date) {
|
7594 |
|
7595 | return date.tm_year+1900;
|
7596 | },
|
7597 | '%z': function(date) {
|
7598 |
|
7599 |
|
7600 | var off = date.tm_gmtoff;
|
7601 | var ahead = off >= 0;
|
7602 | off = Math.abs(off) / 60;
|
7603 |
|
7604 | off = (off / 60)*100 + (off % 60);
|
7605 | return (ahead ? '+' : '-') + String("0000" + off).slice(-4);
|
7606 | },
|
7607 | '%Z': function(date) {
|
7608 | return date.tm_zone;
|
7609 | },
|
7610 | '%%': function() {
|
7611 | return '%';
|
7612 | }
|
7613 | };
|
7614 | for (var rule in EXPANSION_RULES_2) {
|
7615 | if (pattern.indexOf(rule) >= 0) {
|
7616 | pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_2[rule](date));
|
7617 | }
|
7618 | }
|
7619 |
|
7620 | var bytes = intArrayFromString(pattern, false);
|
7621 | if (bytes.length > maxsize) {
|
7622 | return 0;
|
7623 | }
|
7624 |
|
7625 | writeArrayToMemory(bytes, s);
|
7626 | return bytes.length-1;
|
7627 | }function _strftime_l(s, maxsize, format, tm) {
|
7628 | return _strftime(s, maxsize, format, tm);
|
7629 | }
|
7630 |
|
7631 | function _time(ptr) {
|
7632 | var ret = (Date.now()/1000)|0;
|
7633 | if (ptr) {
|
7634 | HEAP32[((ptr)>>2)]=ret;
|
7635 | }
|
7636 | return ret;
|
7637 | }
|
7638 | FS.staticInit();__ATINIT__.unshift(function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() });__ATMAIN__.push(function() { FS.ignorePermissions = false });__ATEXIT__.push(function() { FS.quit() });;
|
7639 | __ATINIT__.unshift(function() { TTY.init() });__ATEXIT__.push(function() { TTY.shutdown() });;
|
7640 | if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); var NODEJS_PATH = require("path"); NODEFS.staticInit(); };
|
7641 | embind_init_charCodes();
|
7642 | BindingError = Module['BindingError'] = extendError(Error, 'BindingError');;
|
7643 | InternalError = Module['InternalError'] = extendError(Error, 'InternalError');;
|
7644 | init_ClassHandle();
|
7645 | init_RegisteredPointer();
|
7646 | init_embind();;
|
7647 | UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
|
7648 | init_emval();;
|
7649 | DYNAMICTOP_PTR = staticAlloc(4);
|
7650 |
|
7651 | STACK_BASE = STACKTOP = alignMemory(STATICTOP);
|
7652 |
|
7653 | STACK_MAX = STACK_BASE + TOTAL_STACK;
|
7654 |
|
7655 | DYNAMIC_BASE = alignMemory(STACK_MAX);
|
7656 |
|
7657 | HEAP32[DYNAMICTOP_PTR>>2] = DYNAMIC_BASE;
|
7658 |
|
7659 | staticSealed = true;
|
7660 |
|
7661 | assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
|
7662 |
|
7663 | var ASSERTIONS = true;
|
7664 |
|
7665 |
|
7666 |
|
7667 |
|
7668 |
|
7669 |
|
7670 |
|
7671 | function intArrayFromString(stringy, dontAddNull, length) {
|
7672 | var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
|
7673 | var u8array = new Array(len);
|
7674 | var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
7675 | if (dontAddNull) u8array.length = numBytesWritten;
|
7676 | return u8array;
|
7677 | }
|
7678 |
|
7679 | function intArrayToString(array) {
|
7680 | var ret = [];
|
7681 | for (var i = 0; i < array.length; i++) {
|
7682 | var chr = array[i];
|
7683 | if (chr > 0xFF) {
|
7684 | if (ASSERTIONS) {
|
7685 | assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
|
7686 | }
|
7687 | chr &= 0xFF;
|
7688 | }
|
7689 | ret.push(String.fromCharCode(chr));
|
7690 | }
|
7691 | return ret.join('');
|
7692 | }
|
7693 |
|
7694 |
|
7695 |
|
7696 | function nullFunc_i(x) { err("Invalid function pointer called with signature 'i'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7697 |
|
7698 | function nullFunc_ii(x) { err("Invalid function pointer called with signature 'ii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7699 |
|
7700 | function nullFunc_iii(x) { err("Invalid function pointer called with signature 'iii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7701 |
|
7702 | function nullFunc_iiid(x) { err("Invalid function pointer called with signature 'iiid'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7703 |
|
7704 | function nullFunc_iiii(x) { err("Invalid function pointer called with signature 'iiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7705 |
|
7706 | function nullFunc_iiiii(x) { err("Invalid function pointer called with signature 'iiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7707 |
|
7708 | function nullFunc_iiiiid(x) { err("Invalid function pointer called with signature 'iiiiid'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7709 |
|
7710 | function nullFunc_iiiiii(x) { err("Invalid function pointer called with signature 'iiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7711 |
|
7712 | function nullFunc_iiiiiid(x) { err("Invalid function pointer called with signature 'iiiiiid'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7713 |
|
7714 | function nullFunc_iiiiiii(x) { err("Invalid function pointer called with signature 'iiiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7715 |
|
7716 | function nullFunc_iiiiiiii(x) { err("Invalid function pointer called with signature 'iiiiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7717 |
|
7718 | function nullFunc_iiiiiiiii(x) { err("Invalid function pointer called with signature 'iiiiiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7719 |
|
7720 | function nullFunc_iiiiij(x) { err("Invalid function pointer called with signature 'iiiiij'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7721 |
|
7722 | function nullFunc_v(x) { err("Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7723 |
|
7724 | function nullFunc_vi(x) { err("Invalid function pointer called with signature 'vi'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7725 |
|
7726 | function nullFunc_vii(x) { err("Invalid function pointer called with signature 'vii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7727 |
|
7728 | function nullFunc_viii(x) { err("Invalid function pointer called with signature 'viii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7729 |
|
7730 | function nullFunc_viiii(x) { err("Invalid function pointer called with signature 'viiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7731 |
|
7732 | function nullFunc_viiiii(x) { err("Invalid function pointer called with signature 'viiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7733 |
|
7734 | function nullFunc_viiiiii(x) { err("Invalid function pointer called with signature 'viiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7735 |
|
7736 | function nullFunc_viiiiiii(x) { err("Invalid function pointer called with signature 'viiiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7737 |
|
7738 | function nullFunc_viiiiiiii(x) { err("Invalid function pointer called with signature 'viiiiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7739 |
|
7740 | function nullFunc_viijii(x) { err("Invalid function pointer called with signature 'viijii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); err("Build with ASSERTIONS=2 for more info.");abort(x) }
|
7741 |
|
7742 | Module['wasmTableSize'] = 17409;
|
7743 |
|
7744 | Module['wasmMaxTableSize'] = 17409;
|
7745 |
|
7746 | Module.asmGlobalArg = {};
|
7747 |
|
7748 | Module.asmLibraryArg = { "abort": abort, "assert": assert, "enlargeMemory": enlargeMemory, "getTotalMemory": getTotalMemory, "abortOnCannotGrowMemory": abortOnCannotGrowMemory, "abortStackOverflow": abortStackOverflow, "nullFunc_i": nullFunc_i, "nullFunc_ii": nullFunc_ii, "nullFunc_iii": nullFunc_iii, "nullFunc_iiid": nullFunc_iiid, "nullFunc_iiii": nullFunc_iiii, "nullFunc_iiiii": nullFunc_iiiii, "nullFunc_iiiiid": nullFunc_iiiiid, "nullFunc_iiiiii": nullFunc_iiiiii, "nullFunc_iiiiiid": nullFunc_iiiiiid, "nullFunc_iiiiiii": nullFunc_iiiiiii, "nullFunc_iiiiiiii": nullFunc_iiiiiiii, "nullFunc_iiiiiiiii": nullFunc_iiiiiiiii, "nullFunc_iiiiij": nullFunc_iiiiij, "nullFunc_v": nullFunc_v, "nullFunc_vi": nullFunc_vi, "nullFunc_vii": nullFunc_vii, "nullFunc_viii": nullFunc_viii, "nullFunc_viiii": nullFunc_viiii, "nullFunc_viiiii": nullFunc_viiiii, "nullFunc_viiiiii": nullFunc_viiiiii, "nullFunc_viiiiiii": nullFunc_viiiiiii, "nullFunc_viiiiiiii": nullFunc_viiiiiiii, "nullFunc_viijii": nullFunc_viijii, "ClassHandle": ClassHandle, "ClassHandle_clone": ClassHandle_clone, "ClassHandle_delete": ClassHandle_delete, "ClassHandle_deleteLater": ClassHandle_deleteLater, "ClassHandle_isAliasOf": ClassHandle_isAliasOf, "ClassHandle_isDeleted": ClassHandle_isDeleted, "RegisteredClass": RegisteredClass, "RegisteredPointer": RegisteredPointer, "RegisteredPointer_deleteObject": RegisteredPointer_deleteObject, "RegisteredPointer_destructor": RegisteredPointer_destructor, "RegisteredPointer_fromWireType": RegisteredPointer_fromWireType, "RegisteredPointer_getPointee": RegisteredPointer_getPointee, "___assert_fail": ___assert_fail, "___buildEnvironment": ___buildEnvironment, "___cxa_allocate_exception": ___cxa_allocate_exception, "___cxa_begin_catch": ___cxa_begin_catch, "___cxa_find_matching_catch": ___cxa_find_matching_catch, "___cxa_pure_virtual": ___cxa_pure_virtual, "___cxa_throw": ___cxa_throw, "___cxa_uncaught_exception": ___cxa_uncaught_exception, "___gxx_personality_v0": ___gxx_personality_v0, "___lock": ___lock, "___map_file": ___map_file, "___resumeException": ___resumeException, "___setErrNo": ___setErrNo, "___syscall140": ___syscall140, "___syscall142": ___syscall142, "___syscall146": ___syscall146, "___syscall195": ___syscall195, "___syscall197": ___syscall197, "___syscall199": ___syscall199, "___syscall20": ___syscall20, "___syscall202": ___syscall202, "___syscall221": ___syscall221, "___syscall3": ___syscall3, "___syscall5": ___syscall5, "___syscall54": ___syscall54, "___syscall6": ___syscall6, "___syscall91": ___syscall91, "___unlock": ___unlock, "__addDays": __addDays, "__arraySum": __arraySum, "__embind_register_bool": __embind_register_bool, "__embind_register_class": __embind_register_class, "__embind_register_class_constructor": __embind_register_class_constructor, "__embind_register_class_function": __embind_register_class_function, "__embind_register_emval": __embind_register_emval, "__embind_register_float": __embind_register_float, "__embind_register_integer": __embind_register_integer, "__embind_register_memory_view": __embind_register_memory_view, "__embind_register_std_string": __embind_register_std_string, "__embind_register_std_wstring": __embind_register_std_wstring, "__embind_register_void": __embind_register_void, "__emval_addMethodCaller": __emval_addMethodCaller, "__emval_allocateDestructors": __emval_allocateDestructors, "__emval_as": __emval_as, "__emval_call_method": __emval_call_method, "__emval_decref": __emval_decref, "__emval_get_global": __emval_get_global, "__emval_get_method_caller": __emval_get_method_caller, "__emval_get_property": __emval_get_property, "__emval_incref": __emval_incref, "__emval_lookupTypes": __emval_lookupTypes, "__emval_new_array": __emval_new_array, "__emval_new_cstring": __emval_new_cstring, "__emval_new_object": __emval_new_object, "__emval_register": __emval_register, "__emval_run_destructors": __emval_run_destructors, "__emval_set_property": __emval_set_property, "__emval_take_value": __emval_take_value, "__isLeapYear": __isLeapYear, "_abort": _abort, "_atexit": _atexit, "_embind_repr": _embind_repr, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_getenv": _getenv, "_gettimeofday": _gettimeofday, "_llvm_stackrestore": _llvm_stackrestore, "_llvm_stacksave": _llvm_stacksave, "_llvm_trap": _llvm_trap, "_pthread_cond_wait": _pthread_cond_wait, "_pthread_getspecific": _pthread_getspecific, "_pthread_key_create": _pthread_key_create, "_pthread_once": _pthread_once, "_pthread_rwlock_destroy": _pthread_rwlock_destroy, "_pthread_rwlock_init": _pthread_rwlock_init, "_pthread_rwlock_rdlock": _pthread_rwlock_rdlock, "_pthread_rwlock_unlock": _pthread_rwlock_unlock, "_pthread_rwlock_wrlock": _pthread_rwlock_wrlock, "_pthread_setspecific": _pthread_setspecific, "_strftime": _strftime, "_strftime_l": _strftime_l, "_time": _time, "constNoSmartPtrRawPointerToWireType": constNoSmartPtrRawPointerToWireType, "count_emval_handles": count_emval_handles, "craftInvokerFunction": craftInvokerFunction, "createNamedFunction": createNamedFunction, "downcastPointer": downcastPointer, "embind__requireFunction": embind__requireFunction, "embind_init_charCodes": embind_init_charCodes, "emval_get_global": emval_get_global, "ensureOverloadTable": ensureOverloadTable, "exposePublicSymbol": exposePublicSymbol, "extendError": extendError, "floatReadValueFromPointer": floatReadValueFromPointer, "flushPendingDeletes": flushPendingDeletes, "genericPointerToWireType": genericPointerToWireType, "getBasestPointer": getBasestPointer, "getInheritedInstance": getInheritedInstance, "getInheritedInstanceCount": getInheritedInstanceCount, "getLiveInheritedInstances": getLiveInheritedInstances, "getShiftFromSize": getShiftFromSize, "getStringOrSymbol": getStringOrSymbol, "getTypeName": getTypeName, "get_first_emval": get_first_emval, "heap32VectorToArray": heap32VectorToArray, "init_ClassHandle": init_ClassHandle, "init_RegisteredPointer": init_RegisteredPointer, "init_embind": init_embind, "init_emval": init_emval, "integerReadValueFromPointer": integerReadValueFromPointer, "makeClassHandle": makeClassHandle, "makeLegalFunctionName": makeLegalFunctionName, "new_": new_, "nonConstNoSmartPtrRawPointerToWireType": nonConstNoSmartPtrRawPointerToWireType, "readLatin1String": readLatin1String, "registerType": registerType, "replacePublicSymbol": replacePublicSymbol, "requireHandle": requireHandle, "requireRegisteredType": requireRegisteredType, "runDestructor": runDestructor, "runDestructors": runDestructors, "setDelayFunction": setDelayFunction, "shallowCopyInternalPointer": shallowCopyInternalPointer, "simpleReadValueFromPointer": simpleReadValueFromPointer, "throwBindingError": throwBindingError, "throwInstanceAlreadyDeleted": throwInstanceAlreadyDeleted, "throwInternalError": throwInternalError, "throwUnboundTypeError": throwUnboundTypeError, "upcastPointer": upcastPointer, "whenDependentTypesAreResolved": whenDependentTypesAreResolved, "DYNAMICTOP_PTR": DYNAMICTOP_PTR, "tempDoublePtr": tempDoublePtr, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX };
|
7749 |
|
7750 | var asm =Module["asm"]
|
7751 | (Module.asmGlobalArg, Module.asmLibraryArg, buffer);
|
7752 |
|
7753 | var real___GLOBAL__sub_I_base64_cc = asm["__GLOBAL__sub_I_base64_cc"]; asm["__GLOBAL__sub_I_base64_cc"] = function() {
|
7754 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7755 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7756 | return real___GLOBAL__sub_I_base64_cc.apply(null, arguments);
|
7757 | };
|
7758 |
|
7759 | var real___GLOBAL__sub_I_bind_cpp = asm["__GLOBAL__sub_I_bind_cpp"]; asm["__GLOBAL__sub_I_bind_cpp"] = function() {
|
7760 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7761 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7762 | return real___GLOBAL__sub_I_bind_cpp.apply(null, arguments);
|
7763 | };
|
7764 |
|
7765 | var real___GLOBAL__sub_I_jsoncpp_cpp = asm["__GLOBAL__sub_I_jsoncpp_cpp"]; asm["__GLOBAL__sub_I_jsoncpp_cpp"] = function() {
|
7766 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7767 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7768 | return real___GLOBAL__sub_I_jsoncpp_cpp.apply(null, arguments);
|
7769 | };
|
7770 |
|
7771 | var real___GLOBAL__sub_I_parser_cc = asm["__GLOBAL__sub_I_parser_cc"]; asm["__GLOBAL__sub_I_parser_cc"] = function() {
|
7772 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7773 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7774 | return real___GLOBAL__sub_I_parser_cc.apply(null, arguments);
|
7775 | };
|
7776 |
|
7777 | var real___GLOBAL__sub_I_redirects_cpp = asm["__GLOBAL__sub_I_redirects_cpp"]; asm["__GLOBAL__sub_I_redirects_cpp"] = function() {
|
7778 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7779 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7780 | return real___GLOBAL__sub_I_redirects_cpp.apply(null, arguments);
|
7781 | };
|
7782 |
|
7783 | var real___GLOBAL__sub_I_rule_cc = asm["__GLOBAL__sub_I_rule_cc"]; asm["__GLOBAL__sub_I_rule_cc"] = function() {
|
7784 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7785 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7786 | return real___GLOBAL__sub_I_rule_cc.apply(null, arguments);
|
7787 | };
|
7788 |
|
7789 | var real___ZSt18uncaught_exceptionv = asm["__ZSt18uncaught_exceptionv"]; asm["__ZSt18uncaught_exceptionv"] = function() {
|
7790 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7791 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7792 | return real___ZSt18uncaught_exceptionv.apply(null, arguments);
|
7793 | };
|
7794 |
|
7795 | var real____cxa_can_catch = asm["___cxa_can_catch"]; asm["___cxa_can_catch"] = function() {
|
7796 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7797 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7798 | return real____cxa_can_catch.apply(null, arguments);
|
7799 | };
|
7800 |
|
7801 | var real____cxa_demangle = asm["___cxa_demangle"]; asm["___cxa_demangle"] = function() {
|
7802 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7803 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7804 | return real____cxa_demangle.apply(null, arguments);
|
7805 | };
|
7806 |
|
7807 | var real____cxa_is_pointer_type = asm["___cxa_is_pointer_type"]; asm["___cxa_is_pointer_type"] = function() {
|
7808 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7809 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7810 | return real____cxa_is_pointer_type.apply(null, arguments);
|
7811 | };
|
7812 |
|
7813 | var real____emscripten_environ_constructor = asm["___emscripten_environ_constructor"]; asm["___emscripten_environ_constructor"] = function() {
|
7814 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7815 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7816 | return real____emscripten_environ_constructor.apply(null, arguments);
|
7817 | };
|
7818 |
|
7819 | var real____errno_location = asm["___errno_location"]; asm["___errno_location"] = function() {
|
7820 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7821 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7822 | return real____errno_location.apply(null, arguments);
|
7823 | };
|
7824 |
|
7825 | var real____getTypeName = asm["___getTypeName"]; asm["___getTypeName"] = function() {
|
7826 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7827 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7828 | return real____getTypeName.apply(null, arguments);
|
7829 | };
|
7830 |
|
7831 | var real___get_environ = asm["__get_environ"]; asm["__get_environ"] = function() {
|
7832 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7833 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7834 | return real___get_environ.apply(null, arguments);
|
7835 | };
|
7836 |
|
7837 | var real__fflush = asm["_fflush"]; asm["_fflush"] = function() {
|
7838 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7839 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7840 | return real__fflush.apply(null, arguments);
|
7841 | };
|
7842 |
|
7843 | var real__free = asm["_free"]; asm["_free"] = function() {
|
7844 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7845 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7846 | return real__free.apply(null, arguments);
|
7847 | };
|
7848 |
|
7849 | var real__llvm_bswap_i32 = asm["_llvm_bswap_i32"]; asm["_llvm_bswap_i32"] = function() {
|
7850 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7851 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7852 | return real__llvm_bswap_i32.apply(null, arguments);
|
7853 | };
|
7854 |
|
7855 | var real__malloc = asm["_malloc"]; asm["_malloc"] = function() {
|
7856 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7857 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7858 | return real__malloc.apply(null, arguments);
|
7859 | };
|
7860 |
|
7861 | var real__memalign = asm["_memalign"]; asm["_memalign"] = function() {
|
7862 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7863 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7864 | return real__memalign.apply(null, arguments);
|
7865 | };
|
7866 |
|
7867 | var real__memmove = asm["_memmove"]; asm["_memmove"] = function() {
|
7868 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7869 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7870 | return real__memmove.apply(null, arguments);
|
7871 | };
|
7872 |
|
7873 | var real__pthread_cond_broadcast = asm["_pthread_cond_broadcast"]; asm["_pthread_cond_broadcast"] = function() {
|
7874 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7875 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7876 | return real__pthread_cond_broadcast.apply(null, arguments);
|
7877 | };
|
7878 |
|
7879 | var real__pthread_mutex_lock = asm["_pthread_mutex_lock"]; asm["_pthread_mutex_lock"] = function() {
|
7880 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7881 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7882 | return real__pthread_mutex_lock.apply(null, arguments);
|
7883 | };
|
7884 |
|
7885 | var real__pthread_mutex_unlock = asm["_pthread_mutex_unlock"]; asm["_pthread_mutex_unlock"] = function() {
|
7886 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7887 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7888 | return real__pthread_mutex_unlock.apply(null, arguments);
|
7889 | };
|
7890 |
|
7891 | var real__sbrk = asm["_sbrk"]; asm["_sbrk"] = function() {
|
7892 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7893 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7894 | return real__sbrk.apply(null, arguments);
|
7895 | };
|
7896 |
|
7897 | var real_establishStackSpace = asm["establishStackSpace"]; asm["establishStackSpace"] = function() {
|
7898 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7899 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7900 | return real_establishStackSpace.apply(null, arguments);
|
7901 | };
|
7902 |
|
7903 | var real_getTempRet0 = asm["getTempRet0"]; asm["getTempRet0"] = function() {
|
7904 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7905 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7906 | return real_getTempRet0.apply(null, arguments);
|
7907 | };
|
7908 |
|
7909 | var real_setTempRet0 = asm["setTempRet0"]; asm["setTempRet0"] = function() {
|
7910 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7911 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7912 | return real_setTempRet0.apply(null, arguments);
|
7913 | };
|
7914 |
|
7915 | var real_setThrew = asm["setThrew"]; asm["setThrew"] = function() {
|
7916 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7917 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7918 | return real_setThrew.apply(null, arguments);
|
7919 | };
|
7920 |
|
7921 | var real_stackAlloc = asm["stackAlloc"]; asm["stackAlloc"] = function() {
|
7922 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7923 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7924 | return real_stackAlloc.apply(null, arguments);
|
7925 | };
|
7926 |
|
7927 | var real_stackRestore = asm["stackRestore"]; asm["stackRestore"] = function() {
|
7928 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7929 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7930 | return real_stackRestore.apply(null, arguments);
|
7931 | };
|
7932 |
|
7933 | var real_stackSave = asm["stackSave"]; asm["stackSave"] = function() {
|
7934 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7935 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7936 | return real_stackSave.apply(null, arguments);
|
7937 | };
|
7938 | Module["asm"] = asm;
|
7939 | var __GLOBAL__sub_I_base64_cc = Module["__GLOBAL__sub_I_base64_cc"] = function() {
|
7940 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7941 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7942 | return Module["asm"]["__GLOBAL__sub_I_base64_cc"].apply(null, arguments) };
|
7943 | var __GLOBAL__sub_I_bind_cpp = Module["__GLOBAL__sub_I_bind_cpp"] = function() {
|
7944 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7945 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7946 | return Module["asm"]["__GLOBAL__sub_I_bind_cpp"].apply(null, arguments) };
|
7947 | var __GLOBAL__sub_I_jsoncpp_cpp = Module["__GLOBAL__sub_I_jsoncpp_cpp"] = function() {
|
7948 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7949 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7950 | return Module["asm"]["__GLOBAL__sub_I_jsoncpp_cpp"].apply(null, arguments) };
|
7951 | var __GLOBAL__sub_I_parser_cc = Module["__GLOBAL__sub_I_parser_cc"] = function() {
|
7952 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7953 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7954 | return Module["asm"]["__GLOBAL__sub_I_parser_cc"].apply(null, arguments) };
|
7955 | var __GLOBAL__sub_I_redirects_cpp = Module["__GLOBAL__sub_I_redirects_cpp"] = function() {
|
7956 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7957 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7958 | return Module["asm"]["__GLOBAL__sub_I_redirects_cpp"].apply(null, arguments) };
|
7959 | var __GLOBAL__sub_I_rule_cc = Module["__GLOBAL__sub_I_rule_cc"] = function() {
|
7960 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7961 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7962 | return Module["asm"]["__GLOBAL__sub_I_rule_cc"].apply(null, arguments) };
|
7963 | var __ZSt18uncaught_exceptionv = Module["__ZSt18uncaught_exceptionv"] = function() {
|
7964 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7965 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7966 | return Module["asm"]["__ZSt18uncaught_exceptionv"].apply(null, arguments) };
|
7967 | var ___cxa_can_catch = Module["___cxa_can_catch"] = function() {
|
7968 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7969 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7970 | return Module["asm"]["___cxa_can_catch"].apply(null, arguments) };
|
7971 | var ___cxa_demangle = Module["___cxa_demangle"] = function() {
|
7972 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7973 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7974 | return Module["asm"]["___cxa_demangle"].apply(null, arguments) };
|
7975 | var ___cxa_is_pointer_type = Module["___cxa_is_pointer_type"] = function() {
|
7976 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7977 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7978 | return Module["asm"]["___cxa_is_pointer_type"].apply(null, arguments) };
|
7979 | var ___emscripten_environ_constructor = Module["___emscripten_environ_constructor"] = function() {
|
7980 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7981 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7982 | return Module["asm"]["___emscripten_environ_constructor"].apply(null, arguments) };
|
7983 | var ___errno_location = Module["___errno_location"] = function() {
|
7984 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7985 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7986 | return Module["asm"]["___errno_location"].apply(null, arguments) };
|
7987 | var ___getTypeName = Module["___getTypeName"] = function() {
|
7988 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7989 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7990 | return Module["asm"]["___getTypeName"].apply(null, arguments) };
|
7991 | var __get_environ = Module["__get_environ"] = function() {
|
7992 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7993 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7994 | return Module["asm"]["__get_environ"].apply(null, arguments) };
|
7995 | var _fflush = Module["_fflush"] = function() {
|
7996 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
7997 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
7998 | return Module["asm"]["_fflush"].apply(null, arguments) };
|
7999 | var _free = Module["_free"] = function() {
|
8000 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8001 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8002 | return Module["asm"]["_free"].apply(null, arguments) };
|
8003 | var _llvm_bswap_i32 = Module["_llvm_bswap_i32"] = function() {
|
8004 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8005 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8006 | return Module["asm"]["_llvm_bswap_i32"].apply(null, arguments) };
|
8007 | var _malloc = Module["_malloc"] = function() {
|
8008 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8009 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8010 | return Module["asm"]["_malloc"].apply(null, arguments) };
|
8011 | var _memalign = Module["_memalign"] = function() {
|
8012 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8013 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8014 | return Module["asm"]["_memalign"].apply(null, arguments) };
|
8015 | var _memcpy = Module["_memcpy"] = function() {
|
8016 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8017 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8018 | return Module["asm"]["_memcpy"].apply(null, arguments) };
|
8019 | var _memmove = Module["_memmove"] = function() {
|
8020 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8021 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8022 | return Module["asm"]["_memmove"].apply(null, arguments) };
|
8023 | var _memset = Module["_memset"] = function() {
|
8024 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8025 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8026 | return Module["asm"]["_memset"].apply(null, arguments) };
|
8027 | var _pthread_cond_broadcast = Module["_pthread_cond_broadcast"] = function() {
|
8028 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8029 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8030 | return Module["asm"]["_pthread_cond_broadcast"].apply(null, arguments) };
|
8031 | var _pthread_mutex_lock = Module["_pthread_mutex_lock"] = function() {
|
8032 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8033 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8034 | return Module["asm"]["_pthread_mutex_lock"].apply(null, arguments) };
|
8035 | var _pthread_mutex_unlock = Module["_pthread_mutex_unlock"] = function() {
|
8036 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8037 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8038 | return Module["asm"]["_pthread_mutex_unlock"].apply(null, arguments) };
|
8039 | var _sbrk = Module["_sbrk"] = function() {
|
8040 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8041 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8042 | return Module["asm"]["_sbrk"].apply(null, arguments) };
|
8043 | var establishStackSpace = Module["establishStackSpace"] = function() {
|
8044 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8045 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8046 | return Module["asm"]["establishStackSpace"].apply(null, arguments) };
|
8047 | var getTempRet0 = Module["getTempRet0"] = function() {
|
8048 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8049 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8050 | return Module["asm"]["getTempRet0"].apply(null, arguments) };
|
8051 | var runPostSets = Module["runPostSets"] = function() {
|
8052 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8053 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8054 | return Module["asm"]["runPostSets"].apply(null, arguments) };
|
8055 | var setTempRet0 = Module["setTempRet0"] = function() {
|
8056 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8057 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8058 | return Module["asm"]["setTempRet0"].apply(null, arguments) };
|
8059 | var setThrew = Module["setThrew"] = function() {
|
8060 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8061 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8062 | return Module["asm"]["setThrew"].apply(null, arguments) };
|
8063 | var stackAlloc = Module["stackAlloc"] = function() {
|
8064 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8065 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8066 | return Module["asm"]["stackAlloc"].apply(null, arguments) };
|
8067 | var stackRestore = Module["stackRestore"] = function() {
|
8068 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8069 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8070 | return Module["asm"]["stackRestore"].apply(null, arguments) };
|
8071 | var stackSave = Module["stackSave"] = function() {
|
8072 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8073 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8074 | return Module["asm"]["stackSave"].apply(null, arguments) };
|
8075 | var dynCall_i = Module["dynCall_i"] = function() {
|
8076 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8077 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8078 | return Module["asm"]["dynCall_i"].apply(null, arguments) };
|
8079 | var dynCall_ii = Module["dynCall_ii"] = function() {
|
8080 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8081 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8082 | return Module["asm"]["dynCall_ii"].apply(null, arguments) };
|
8083 | var dynCall_iii = Module["dynCall_iii"] = function() {
|
8084 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8085 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8086 | return Module["asm"]["dynCall_iii"].apply(null, arguments) };
|
8087 | var dynCall_iiid = Module["dynCall_iiid"] = function() {
|
8088 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8089 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8090 | return Module["asm"]["dynCall_iiid"].apply(null, arguments) };
|
8091 | var dynCall_iiii = Module["dynCall_iiii"] = function() {
|
8092 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8093 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8094 | return Module["asm"]["dynCall_iiii"].apply(null, arguments) };
|
8095 | var dynCall_iiiii = Module["dynCall_iiiii"] = function() {
|
8096 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8097 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8098 | return Module["asm"]["dynCall_iiiii"].apply(null, arguments) };
|
8099 | var dynCall_iiiiid = Module["dynCall_iiiiid"] = function() {
|
8100 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8101 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8102 | return Module["asm"]["dynCall_iiiiid"].apply(null, arguments) };
|
8103 | var dynCall_iiiiii = Module["dynCall_iiiiii"] = function() {
|
8104 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8105 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8106 | return Module["asm"]["dynCall_iiiiii"].apply(null, arguments) };
|
8107 | var dynCall_iiiiiid = Module["dynCall_iiiiiid"] = function() {
|
8108 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8109 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8110 | return Module["asm"]["dynCall_iiiiiid"].apply(null, arguments) };
|
8111 | var dynCall_iiiiiii = Module["dynCall_iiiiiii"] = function() {
|
8112 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8113 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8114 | return Module["asm"]["dynCall_iiiiiii"].apply(null, arguments) };
|
8115 | var dynCall_iiiiiiii = Module["dynCall_iiiiiiii"] = function() {
|
8116 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8117 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8118 | return Module["asm"]["dynCall_iiiiiiii"].apply(null, arguments) };
|
8119 | var dynCall_iiiiiiiii = Module["dynCall_iiiiiiiii"] = function() {
|
8120 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8121 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8122 | return Module["asm"]["dynCall_iiiiiiiii"].apply(null, arguments) };
|
8123 | var dynCall_iiiiij = Module["dynCall_iiiiij"] = function() {
|
8124 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8125 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8126 | return Module["asm"]["dynCall_iiiiij"].apply(null, arguments) };
|
8127 | var dynCall_v = Module["dynCall_v"] = function() {
|
8128 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8129 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8130 | return Module["asm"]["dynCall_v"].apply(null, arguments) };
|
8131 | var dynCall_vi = Module["dynCall_vi"] = function() {
|
8132 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8133 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8134 | return Module["asm"]["dynCall_vi"].apply(null, arguments) };
|
8135 | var dynCall_vii = Module["dynCall_vii"] = function() {
|
8136 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8137 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8138 | return Module["asm"]["dynCall_vii"].apply(null, arguments) };
|
8139 | var dynCall_viii = Module["dynCall_viii"] = function() {
|
8140 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8141 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8142 | return Module["asm"]["dynCall_viii"].apply(null, arguments) };
|
8143 | var dynCall_viiii = Module["dynCall_viiii"] = function() {
|
8144 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8145 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8146 | return Module["asm"]["dynCall_viiii"].apply(null, arguments) };
|
8147 | var dynCall_viiiii = Module["dynCall_viiiii"] = function() {
|
8148 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8149 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8150 | return Module["asm"]["dynCall_viiiii"].apply(null, arguments) };
|
8151 | var dynCall_viiiiii = Module["dynCall_viiiiii"] = function() {
|
8152 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8153 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8154 | return Module["asm"]["dynCall_viiiiii"].apply(null, arguments) };
|
8155 | var dynCall_viiiiiii = Module["dynCall_viiiiiii"] = function() {
|
8156 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8157 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8158 | return Module["asm"]["dynCall_viiiiiii"].apply(null, arguments) };
|
8159 | var dynCall_viiiiiiii = Module["dynCall_viiiiiiii"] = function() {
|
8160 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8161 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8162 | return Module["asm"]["dynCall_viiiiiiii"].apply(null, arguments) };
|
8163 | var dynCall_viijii = Module["dynCall_viijii"] = function() {
|
8164 | assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
|
8165 | assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
|
8166 | return Module["asm"]["dynCall_viijii"].apply(null, arguments) };
|
8167 | ;
|
8168 |
|
8169 |
|
8170 |
|
8171 |
|
8172 |
|
8173 | Module['asm'] = asm;
|
8174 |
|
8175 | if (!Module["intArrayFromString"]) Module["intArrayFromString"] = function() { abort("'intArrayFromString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8176 | if (!Module["intArrayToString"]) Module["intArrayToString"] = function() { abort("'intArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8177 | if (!Module["ccall"]) Module["ccall"] = function() { abort("'ccall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8178 | if (!Module["cwrap"]) Module["cwrap"] = function() { abort("'cwrap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8179 | if (!Module["setValue"]) Module["setValue"] = function() { abort("'setValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8180 | if (!Module["getValue"]) Module["getValue"] = function() { abort("'getValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8181 | if (!Module["allocate"]) Module["allocate"] = function() { abort("'allocate' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8182 | if (!Module["getMemory"]) Module["getMemory"] = function() { abort("'getMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8183 | if (!Module["Pointer_stringify"]) Module["Pointer_stringify"] = function() { abort("'Pointer_stringify' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8184 | if (!Module["AsciiToString"]) Module["AsciiToString"] = function() { abort("'AsciiToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8185 | if (!Module["stringToAscii"]) Module["stringToAscii"] = function() { abort("'stringToAscii' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8186 | if (!Module["UTF8ArrayToString"]) Module["UTF8ArrayToString"] = function() { abort("'UTF8ArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8187 | if (!Module["UTF8ToString"]) Module["UTF8ToString"] = function() { abort("'UTF8ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8188 | if (!Module["stringToUTF8Array"]) Module["stringToUTF8Array"] = function() { abort("'stringToUTF8Array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8189 | if (!Module["stringToUTF8"]) Module["stringToUTF8"] = function() { abort("'stringToUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8190 | if (!Module["lengthBytesUTF8"]) Module["lengthBytesUTF8"] = function() { abort("'lengthBytesUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8191 | if (!Module["UTF16ToString"]) Module["UTF16ToString"] = function() { abort("'UTF16ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8192 | if (!Module["stringToUTF16"]) Module["stringToUTF16"] = function() { abort("'stringToUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8193 | if (!Module["lengthBytesUTF16"]) Module["lengthBytesUTF16"] = function() { abort("'lengthBytesUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8194 | if (!Module["UTF32ToString"]) Module["UTF32ToString"] = function() { abort("'UTF32ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8195 | if (!Module["stringToUTF32"]) Module["stringToUTF32"] = function() { abort("'stringToUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8196 | if (!Module["lengthBytesUTF32"]) Module["lengthBytesUTF32"] = function() { abort("'lengthBytesUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8197 | if (!Module["allocateUTF8"]) Module["allocateUTF8"] = function() { abort("'allocateUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8198 | if (!Module["stackTrace"]) Module["stackTrace"] = function() { abort("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8199 | if (!Module["addOnPreRun"]) Module["addOnPreRun"] = function() { abort("'addOnPreRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8200 | if (!Module["addOnInit"]) Module["addOnInit"] = function() { abort("'addOnInit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8201 | if (!Module["addOnPreMain"]) Module["addOnPreMain"] = function() { abort("'addOnPreMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8202 | if (!Module["addOnExit"]) Module["addOnExit"] = function() { abort("'addOnExit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8203 | if (!Module["addOnPostRun"]) Module["addOnPostRun"] = function() { abort("'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8204 | if (!Module["writeStringToMemory"]) Module["writeStringToMemory"] = function() { abort("'writeStringToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8205 | if (!Module["writeArrayToMemory"]) Module["writeArrayToMemory"] = function() { abort("'writeArrayToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8206 | if (!Module["writeAsciiToMemory"]) Module["writeAsciiToMemory"] = function() { abort("'writeAsciiToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8207 | if (!Module["addRunDependency"]) Module["addRunDependency"] = function() { abort("'addRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8208 | if (!Module["removeRunDependency"]) Module["removeRunDependency"] = function() { abort("'removeRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8209 | if (!Module["ENV"]) Module["ENV"] = function() { abort("'ENV' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8210 | if (!Module["FS"]) Module["FS"] = function() { abort("'FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8211 | if (!Module["FS_createFolder"]) Module["FS_createFolder"] = function() { abort("'FS_createFolder' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8212 | if (!Module["FS_createPath"]) Module["FS_createPath"] = function() { abort("'FS_createPath' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8213 | if (!Module["FS_createDataFile"]) Module["FS_createDataFile"] = function() { abort("'FS_createDataFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8214 | if (!Module["FS_createPreloadedFile"]) Module["FS_createPreloadedFile"] = function() { abort("'FS_createPreloadedFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8215 | if (!Module["FS_createLazyFile"]) Module["FS_createLazyFile"] = function() { abort("'FS_createLazyFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8216 | if (!Module["FS_createLink"]) Module["FS_createLink"] = function() { abort("'FS_createLink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8217 | if (!Module["FS_createDevice"]) Module["FS_createDevice"] = function() { abort("'FS_createDevice' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8218 | if (!Module["FS_unlink"]) Module["FS_unlink"] = function() { abort("'FS_unlink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
|
8219 | if (!Module["GL"]) Module["GL"] = function() { abort("'GL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8220 | if (!Module["staticAlloc"]) Module["staticAlloc"] = function() { abort("'staticAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8221 | if (!Module["dynamicAlloc"]) Module["dynamicAlloc"] = function() { abort("'dynamicAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8222 | if (!Module["warnOnce"]) Module["warnOnce"] = function() { abort("'warnOnce' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8223 | if (!Module["loadDynamicLibrary"]) Module["loadDynamicLibrary"] = function() { abort("'loadDynamicLibrary' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8224 | if (!Module["loadWebAssemblyModule"]) Module["loadWebAssemblyModule"] = function() { abort("'loadWebAssemblyModule' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8225 | if (!Module["getLEB"]) Module["getLEB"] = function() { abort("'getLEB' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8226 | if (!Module["getFunctionTables"]) Module["getFunctionTables"] = function() { abort("'getFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8227 | if (!Module["alignFunctionTables"]) Module["alignFunctionTables"] = function() { abort("'alignFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8228 | if (!Module["registerFunctions"]) Module["registerFunctions"] = function() { abort("'registerFunctions' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8229 | if (!Module["addFunction"]) Module["addFunction"] = function() { abort("'addFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8230 | if (!Module["removeFunction"]) Module["removeFunction"] = function() { abort("'removeFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8231 | if (!Module["getFuncWrapper"]) Module["getFuncWrapper"] = function() { abort("'getFuncWrapper' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8232 | if (!Module["prettyPrint"]) Module["prettyPrint"] = function() { abort("'prettyPrint' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8233 | if (!Module["makeBigInt"]) Module["makeBigInt"] = function() { abort("'makeBigInt' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8234 | if (!Module["dynCall"]) Module["dynCall"] = function() { abort("'dynCall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8235 | if (!Module["getCompilerSetting"]) Module["getCompilerSetting"] = function() { abort("'getCompilerSetting' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8236 | if (!Module["stackSave"]) Module["stackSave"] = function() { abort("'stackSave' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8237 | if (!Module["stackRestore"]) Module["stackRestore"] = function() { abort("'stackRestore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8238 | if (!Module["stackAlloc"]) Module["stackAlloc"] = function() { abort("'stackAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8239 | if (!Module["establishStackSpace"]) Module["establishStackSpace"] = function() { abort("'establishStackSpace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8240 | if (!Module["print"]) Module["print"] = function() { abort("'print' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
|
8241 | if (!Module["printErr"]) Module["printErr"] = function() { abort("'printErr' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };if (!Module["ALLOC_NORMAL"]) Object.defineProperty(Module, "ALLOC_NORMAL", { get: function() { abort("'ALLOC_NORMAL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
|
8242 | if (!Module["ALLOC_STACK"]) Object.defineProperty(Module, "ALLOC_STACK", { get: function() { abort("'ALLOC_STACK' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
|
8243 | if (!Module["ALLOC_STATIC"]) Object.defineProperty(Module, "ALLOC_STATIC", { get: function() { abort("'ALLOC_STATIC' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
|
8244 | if (!Module["ALLOC_DYNAMIC"]) Object.defineProperty(Module, "ALLOC_DYNAMIC", { get: function() { abort("'ALLOC_DYNAMIC' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
|
8245 | if (!Module["ALLOC_NONE"]) Object.defineProperty(Module, "ALLOC_NONE", { get: function() { abort("'ALLOC_NONE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
|
8246 |
|
8247 |
|
8248 |
|
8249 |
|
8250 |
|
8251 |
|
8252 |
|
8253 |
|
8254 |
|
8255 | function ExitStatus(status) {
|
8256 | this.name = "ExitStatus";
|
8257 | this.message = "Program terminated with exit(" + status + ")";
|
8258 | this.status = status;
|
8259 | };
|
8260 | ExitStatus.prototype = new Error();
|
8261 | ExitStatus.prototype.constructor = ExitStatus;
|
8262 |
|
8263 | var initialStackTop;
|
8264 | var calledMain = false;
|
8265 |
|
8266 | dependenciesFulfilled = function runCaller() {
|
8267 |
|
8268 | if (!Module['calledRun']) run();
|
8269 | if (!Module['calledRun']) dependenciesFulfilled = runCaller;
|
8270 | }
|
8271 |
|
8272 |
|
8273 |
|
8274 |
|
8275 |
|
8276 |
|
8277 | function run(args) {
|
8278 | args = args || Module['arguments'];
|
8279 |
|
8280 | if (runDependencies > 0) {
|
8281 | return;
|
8282 | }
|
8283 |
|
8284 | writeStackCookie();
|
8285 |
|
8286 | preRun();
|
8287 |
|
8288 | if (runDependencies > 0) return;
|
8289 | if (Module['calledRun']) return;
|
8290 |
|
8291 | function doRun() {
|
8292 | if (Module['calledRun']) return;
|
8293 | Module['calledRun'] = true;
|
8294 |
|
8295 | if (ABORT) return;
|
8296 |
|
8297 | ensureInitRuntime();
|
8298 |
|
8299 | preMain();
|
8300 |
|
8301 | if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
|
8302 |
|
8303 | assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
|
8304 |
|
8305 | postRun();
|
8306 | }
|
8307 |
|
8308 | if (Module['setStatus']) {
|
8309 | Module['setStatus']('Running...');
|
8310 | setTimeout(function() {
|
8311 | setTimeout(function() {
|
8312 | Module['setStatus']('');
|
8313 | }, 1);
|
8314 | doRun();
|
8315 | }, 1);
|
8316 | } else {
|
8317 | doRun();
|
8318 | }
|
8319 | checkStackCookie();
|
8320 | }
|
8321 | Module['run'] = run;
|
8322 |
|
8323 | function checkUnflushedContent() {
|
8324 |
|
8325 |
|
8326 |
|
8327 |
|
8328 |
|
8329 |
|
8330 |
|
8331 |
|
8332 |
|
8333 |
|
8334 |
|
8335 | var print = out;
|
8336 | var printErr = err;
|
8337 | var has = false;
|
8338 | out = err = function(x) {
|
8339 | has = true;
|
8340 | }
|
8341 | try {
|
8342 | var flush = Module['_fflush'];
|
8343 | if (flush) flush(0);
|
8344 |
|
8345 | var hasFS = true;
|
8346 | if (hasFS) {
|
8347 | ['stdout', 'stderr'].forEach(function(name) {
|
8348 | var info = FS.analyzePath('/dev/' + name);
|
8349 | if (!info) return;
|
8350 | var stream = info.object;
|
8351 | var rdev = stream.rdev;
|
8352 | var tty = TTY.ttys[rdev];
|
8353 | if (tty && tty.output && tty.output.length) {
|
8354 | has = true;
|
8355 | }
|
8356 | });
|
8357 | }
|
8358 | } catch(e) {}
|
8359 | out = print;
|
8360 | err = printErr;
|
8361 | if (has) {
|
8362 | warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc.');
|
8363 | }
|
8364 | }
|
8365 |
|
8366 | function exit(status, implicit) {
|
8367 | checkUnflushedContent();
|
8368 |
|
8369 |
|
8370 |
|
8371 |
|
8372 |
|
8373 | if (implicit && Module['noExitRuntime'] && status === 0) {
|
8374 | return;
|
8375 | }
|
8376 |
|
8377 | if (Module['noExitRuntime']) {
|
8378 |
|
8379 | if (!implicit) {
|
8380 | err('exit(' + status + ') called, but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)');
|
8381 | }
|
8382 | } else {
|
8383 |
|
8384 | ABORT = true;
|
8385 | EXITSTATUS = status;
|
8386 | STACKTOP = initialStackTop;
|
8387 |
|
8388 | exitRuntime();
|
8389 |
|
8390 | if (Module['onExit']) Module['onExit'](status);
|
8391 | }
|
8392 |
|
8393 | Module['quit'](status, new ExitStatus(status));
|
8394 | }
|
8395 |
|
8396 | var abortDecorators = [];
|
8397 |
|
8398 | function abort(what) {
|
8399 | if (Module['onAbort']) {
|
8400 | Module['onAbort'](what);
|
8401 | }
|
8402 |
|
8403 | if (what !== undefined) {
|
8404 | out(what);
|
8405 | err(what);
|
8406 | what = JSON.stringify(what)
|
8407 | } else {
|
8408 | what = '';
|
8409 | }
|
8410 |
|
8411 | ABORT = true;
|
8412 | EXITSTATUS = 1;
|
8413 |
|
8414 | var extra = '';
|
8415 | var output = 'abort(' + what + ') at ' + stackTrace() + extra;
|
8416 | if (abortDecorators) {
|
8417 | abortDecorators.forEach(function(decorator) {
|
8418 | output = decorator(output, what);
|
8419 | });
|
8420 | }
|
8421 | throw output;
|
8422 | }
|
8423 | Module['abort'] = abort;
|
8424 |
|
8425 | if (Module['preInit']) {
|
8426 | if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
|
8427 | while (Module['preInit'].length > 0) {
|
8428 | Module['preInit'].pop()();
|
8429 | }
|
8430 | }
|
8431 |
|
8432 |
|
8433 | Module["noExitRuntime"] = true;
|
8434 |
|
8435 | run();
|
8436 |
|
8437 |
|
8438 |
|
8439 |
|
8440 |
|
8441 |
|
8442 |
|
8443 |
|
8444 |
|