sql.js 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/Dockerfile +1 -1
- package/.eslintrc.js +1 -0
- package/CONTRIBUTING.md +1 -2
- package/README.md +27 -0
- package/dist/sql-asm-debug.js +47177 -45836
- package/dist/sql-asm-memory-growth.js +112 -110
- package/dist/sql-asm.js +115 -112
- package/dist/sql-wasm-debug.js +1416 -1209
- package/dist/sql-wasm-debug.wasm +0 -0
- package/dist/sql-wasm.js +96 -95
- package/dist/sql-wasm.wasm +0 -0
- package/dist/sqljs-all.zip +0 -0
- package/dist/sqljs-wasm.zip +0 -0
- package/dist/sqljs-worker-wasm.zip +0 -0
- package/dist/worker.sql-asm-debug.js +47178 -45837
- package/dist/worker.sql-asm.js +115 -112
- package/dist/worker.sql-wasm-debug.js +1416 -1209
- package/dist/worker.sql-wasm.js +96 -95
- package/package.json +2 -2
package/dist/sql-wasm-debug.js
CHANGED
|
@@ -88,6 +88,8 @@ var Module = typeof Module != 'undefined' ? Module : {};
|
|
|
88
88
|
|
|
89
89
|
// See https://caniuse.com/mdn-javascript_builtins_object_assign
|
|
90
90
|
|
|
91
|
+
// See https://caniuse.com/mdn-javascript_builtins_bigint64array
|
|
92
|
+
|
|
91
93
|
// --pre-jses are emitted after the Module integration code, so that they can
|
|
92
94
|
// refer to Module (if they choose; they can also define Module)
|
|
93
95
|
/* global
|
|
@@ -317,6 +319,14 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
317
319
|
"",
|
|
318
320
|
["number", "string", "number"]
|
|
319
321
|
);
|
|
322
|
+
|
|
323
|
+
// https://www.sqlite.org/c3ref/aggregate_context.html
|
|
324
|
+
// void *sqlite3_aggregate_context(sqlite3_context*, int nBytes)
|
|
325
|
+
var sqlite3_aggregate_context = cwrap(
|
|
326
|
+
"sqlite3_aggregate_context",
|
|
327
|
+
"number",
|
|
328
|
+
["number", "number"]
|
|
329
|
+
);
|
|
320
330
|
var registerExtensionFunctions = cwrap(
|
|
321
331
|
"RegisterExtensionFunctions",
|
|
322
332
|
"number",
|
|
@@ -1223,81 +1233,90 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
1223
1233
|
return sqlite3_changes(this.db);
|
|
1224
1234
|
};
|
|
1225
1235
|
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1236
|
+
var extract_blob = function extract_blob(ptr) {
|
|
1237
|
+
var size = sqlite3_value_bytes(ptr);
|
|
1238
|
+
var blob_ptr = sqlite3_value_blob(ptr);
|
|
1239
|
+
var blob_arg = new Uint8Array(size);
|
|
1240
|
+
for (var j = 0; j < size; j += 1) {
|
|
1241
|
+
blob_arg[j] = HEAP8[blob_ptr + j];
|
|
1242
|
+
}
|
|
1243
|
+
return blob_arg;
|
|
1244
|
+
};
|
|
1230
1245
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1246
|
+
var parseFunctionArguments = function parseFunctionArguments(argc, argv) {
|
|
1247
|
+
var args = [];
|
|
1248
|
+
for (var i = 0; i < argc; i += 1) {
|
|
1249
|
+
var value_ptr = getValue(argv + (4 * i), "i32");
|
|
1250
|
+
var value_type = sqlite3_value_type(value_ptr);
|
|
1251
|
+
var arg;
|
|
1252
|
+
if (
|
|
1253
|
+
value_type === SQLITE_INTEGER
|
|
1254
|
+
|| value_type === SQLITE_FLOAT
|
|
1255
|
+
) {
|
|
1256
|
+
arg = sqlite3_value_double(value_ptr);
|
|
1257
|
+
} else if (value_type === SQLITE_TEXT) {
|
|
1258
|
+
arg = sqlite3_value_text(value_ptr);
|
|
1259
|
+
} else if (value_type === SQLITE_BLOB) {
|
|
1260
|
+
arg = extract_blob(value_ptr);
|
|
1261
|
+
} else arg = null;
|
|
1262
|
+
args.push(arg);
|
|
1263
|
+
}
|
|
1264
|
+
return args;
|
|
1265
|
+
};
|
|
1266
|
+
var setFunctionResult = function setFunctionResult(cx, result) {
|
|
1267
|
+
switch (typeof result) {
|
|
1268
|
+
case "boolean":
|
|
1269
|
+
sqlite3_result_int(cx, result ? 1 : 0);
|
|
1270
|
+
break;
|
|
1271
|
+
case "number":
|
|
1272
|
+
sqlite3_result_double(cx, result);
|
|
1273
|
+
break;
|
|
1274
|
+
case "string":
|
|
1275
|
+
sqlite3_result_text(cx, result, -1, -1);
|
|
1276
|
+
break;
|
|
1277
|
+
case "object":
|
|
1278
|
+
if (result === null) {
|
|
1279
|
+
sqlite3_result_null(cx);
|
|
1280
|
+
} else if (result.length != null) {
|
|
1281
|
+
var blobptr = allocate(result, ALLOC_NORMAL);
|
|
1282
|
+
sqlite3_result_blob(cx, blobptr, result.length, -1);
|
|
1283
|
+
_free(blobptr);
|
|
1284
|
+
} else {
|
|
1285
|
+
sqlite3_result_error(cx, (
|
|
1286
|
+
"Wrong API use : tried to return a value "
|
|
1287
|
+
+ "of an unknown type (" + result + ")."
|
|
1288
|
+
), -1);
|
|
1289
|
+
}
|
|
1290
|
+
break;
|
|
1291
|
+
default:
|
|
1292
|
+
sqlite3_result_null(cx);
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
/** Register a custom function with SQLite
|
|
1297
|
+
@example <caption>Register a simple function</caption>
|
|
1298
|
+
db.create_function("addOne", function (x) {return x+1;})
|
|
1299
|
+
db.exec("SELECT addOne(1)") // = 2
|
|
1300
|
+
|
|
1301
|
+
@param {string} name the name of the function as referenced in
|
|
1302
|
+
SQL statements.
|
|
1303
|
+
@param {function} func the actual function to be executed.
|
|
1304
|
+
@return {Database} The database object. Useful for method chaining
|
|
1305
|
+
*/
|
|
1236
1306
|
Database.prototype["create_function"] = function create_function(
|
|
1237
1307
|
name,
|
|
1238
1308
|
func
|
|
1239
1309
|
) {
|
|
1240
1310
|
function wrapped_func(cx, argc, argv) {
|
|
1311
|
+
var args = parseFunctionArguments(argc, argv);
|
|
1241
1312
|
var result;
|
|
1242
|
-
function extract_blob(ptr) {
|
|
1243
|
-
var size = sqlite3_value_bytes(ptr);
|
|
1244
|
-
var blob_ptr = sqlite3_value_blob(ptr);
|
|
1245
|
-
var blob_arg = new Uint8Array(size);
|
|
1246
|
-
for (var j = 0; j < size; j += 1) {
|
|
1247
|
-
blob_arg[j] = HEAP8[blob_ptr + j];
|
|
1248
|
-
}
|
|
1249
|
-
return blob_arg;
|
|
1250
|
-
}
|
|
1251
|
-
var args = [];
|
|
1252
|
-
for (var i = 0; i < argc; i += 1) {
|
|
1253
|
-
var value_ptr = getValue(argv + (4 * i), "i32");
|
|
1254
|
-
var value_type = sqlite3_value_type(value_ptr);
|
|
1255
|
-
var arg;
|
|
1256
|
-
if (
|
|
1257
|
-
value_type === SQLITE_INTEGER
|
|
1258
|
-
|| value_type === SQLITE_FLOAT
|
|
1259
|
-
) {
|
|
1260
|
-
arg = sqlite3_value_double(value_ptr);
|
|
1261
|
-
} else if (value_type === SQLITE_TEXT) {
|
|
1262
|
-
arg = sqlite3_value_text(value_ptr);
|
|
1263
|
-
} else if (value_type === SQLITE_BLOB) {
|
|
1264
|
-
arg = extract_blob(value_ptr);
|
|
1265
|
-
} else arg = null;
|
|
1266
|
-
args.push(arg);
|
|
1267
|
-
}
|
|
1268
1313
|
try {
|
|
1269
1314
|
result = func.apply(null, args);
|
|
1270
1315
|
} catch (error) {
|
|
1271
1316
|
sqlite3_result_error(cx, error, -1);
|
|
1272
1317
|
return;
|
|
1273
1318
|
}
|
|
1274
|
-
|
|
1275
|
-
case "boolean":
|
|
1276
|
-
sqlite3_result_int(cx, result ? 1 : 0);
|
|
1277
|
-
break;
|
|
1278
|
-
case "number":
|
|
1279
|
-
sqlite3_result_double(cx, result);
|
|
1280
|
-
break;
|
|
1281
|
-
case "string":
|
|
1282
|
-
sqlite3_result_text(cx, result, -1, -1);
|
|
1283
|
-
break;
|
|
1284
|
-
case "object":
|
|
1285
|
-
if (result === null) {
|
|
1286
|
-
sqlite3_result_null(cx);
|
|
1287
|
-
} else if (result.length != null) {
|
|
1288
|
-
var blobptr = allocate(result, ALLOC_NORMAL);
|
|
1289
|
-
sqlite3_result_blob(cx, blobptr, result.length, -1);
|
|
1290
|
-
_free(blobptr);
|
|
1291
|
-
} else {
|
|
1292
|
-
sqlite3_result_error(cx, (
|
|
1293
|
-
"Wrong API use : tried to return a value "
|
|
1294
|
-
+ "of an unknown type (" + result + ")."
|
|
1295
|
-
), -1);
|
|
1296
|
-
}
|
|
1297
|
-
break;
|
|
1298
|
-
default:
|
|
1299
|
-
sqlite3_result_null(cx);
|
|
1300
|
-
}
|
|
1319
|
+
setFunctionResult(cx, result);
|
|
1301
1320
|
}
|
|
1302
1321
|
if (Object.prototype.hasOwnProperty.call(this.functions, name)) {
|
|
1303
1322
|
removeFunction(this.functions[name]);
|
|
@@ -1321,6 +1340,137 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
1321
1340
|
return this;
|
|
1322
1341
|
};
|
|
1323
1342
|
|
|
1343
|
+
/** Register a custom aggregate with SQLite
|
|
1344
|
+
@example <caption>Register a custom sum function</caption>
|
|
1345
|
+
db.create_aggregate("js_sum", {
|
|
1346
|
+
init: () => 0,
|
|
1347
|
+
step: (state, value) => state + value,
|
|
1348
|
+
finalize: state => state
|
|
1349
|
+
});
|
|
1350
|
+
db.exec("SELECT js_sum(column1) FROM (VALUES (1), (2))"); // = 3
|
|
1351
|
+
|
|
1352
|
+
@param {string} name the name of the aggregate as referenced in
|
|
1353
|
+
SQL statements.
|
|
1354
|
+
@param {object} aggregateFunctions
|
|
1355
|
+
object containing at least a step function.
|
|
1356
|
+
@param {function(): T} [aggregateFunctions.init = ()=>null]
|
|
1357
|
+
a function receiving no arguments and returning an initial
|
|
1358
|
+
value for the aggregate function. The initial value will be
|
|
1359
|
+
null if this key is omitted.
|
|
1360
|
+
@param {function(T, any) : T} aggregateFunctions.step
|
|
1361
|
+
a function receiving the current state and a value to aggregate
|
|
1362
|
+
and returning a new state.
|
|
1363
|
+
Will receive the value from init for the first step.
|
|
1364
|
+
@param {function(T): any} [aggregateFunctions.finalize = (state)=>state]
|
|
1365
|
+
a function returning the result of the aggregate function
|
|
1366
|
+
given its final state.
|
|
1367
|
+
If omitted, the value returned by the last step
|
|
1368
|
+
will be used as the final value.
|
|
1369
|
+
@return {Database} The database object. Useful for method chaining
|
|
1370
|
+
@template T
|
|
1371
|
+
*/
|
|
1372
|
+
Database.prototype["create_aggregate"] = function create_aggregate(
|
|
1373
|
+
name,
|
|
1374
|
+
aggregateFunctions
|
|
1375
|
+
) {
|
|
1376
|
+
// Default initializer and finalizer
|
|
1377
|
+
var init = aggregateFunctions["init"]
|
|
1378
|
+
|| function init() { return null; };
|
|
1379
|
+
var finalize = aggregateFunctions["finalize"]
|
|
1380
|
+
|| function finalize(state) { return state; };
|
|
1381
|
+
var step = aggregateFunctions["step"];
|
|
1382
|
+
|
|
1383
|
+
if (!step) {
|
|
1384
|
+
throw "An aggregate function must have a step function in " + name;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// state is a state object; we'll use the pointer p to serve as the
|
|
1388
|
+
// key for where we hold our state so that multiple invocations of
|
|
1389
|
+
// this function never step on each other
|
|
1390
|
+
var state = {};
|
|
1391
|
+
|
|
1392
|
+
function wrapped_step(cx, argc, argv) {
|
|
1393
|
+
// > The first time the sqlite3_aggregate_context(C,N) routine is
|
|
1394
|
+
// > called for a particular aggregate function, SQLite allocates N
|
|
1395
|
+
// > bytes of memory, zeroes out that memory, and returns a pointer
|
|
1396
|
+
// > to the new memory.
|
|
1397
|
+
//
|
|
1398
|
+
// We're going to use that pointer as a key to our state array,
|
|
1399
|
+
// since using sqlite3_aggregate_context as it's meant to be used
|
|
1400
|
+
// through webassembly seems to be very difficult. Just allocate
|
|
1401
|
+
// one byte.
|
|
1402
|
+
var p = sqlite3_aggregate_context(cx, 1);
|
|
1403
|
+
|
|
1404
|
+
// If this is the first invocation of wrapped_step, call `init`
|
|
1405
|
+
//
|
|
1406
|
+
// Make sure that every path through the step and finalize
|
|
1407
|
+
// functions deletes the value state[p] when it's done so we don't
|
|
1408
|
+
// leak memory and possibly stomp the init value of future calls
|
|
1409
|
+
if (!Object.hasOwnProperty.call(state, p)) state[p] = init();
|
|
1410
|
+
|
|
1411
|
+
var args = parseFunctionArguments(argc, argv);
|
|
1412
|
+
var mergedArgs = [state[p]].concat(args);
|
|
1413
|
+
try {
|
|
1414
|
+
state[p] = step.apply(null, mergedArgs);
|
|
1415
|
+
} catch (error) {
|
|
1416
|
+
delete state[p];
|
|
1417
|
+
sqlite3_result_error(cx, error, -1);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
function wrapped_finalize(cx) {
|
|
1422
|
+
var result;
|
|
1423
|
+
var p = sqlite3_aggregate_context(cx, 1);
|
|
1424
|
+
try {
|
|
1425
|
+
result = finalize(state[p]);
|
|
1426
|
+
} catch (error) {
|
|
1427
|
+
delete state[p];
|
|
1428
|
+
sqlite3_result_error(cx, error, -1);
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
setFunctionResult(cx, result);
|
|
1432
|
+
delete state[p];
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
if (Object.hasOwnProperty.call(this.functions, name)) {
|
|
1436
|
+
removeFunction(this.functions[name]);
|
|
1437
|
+
delete this.functions[name];
|
|
1438
|
+
}
|
|
1439
|
+
var finalize_name = name + "__finalize";
|
|
1440
|
+
if (Object.hasOwnProperty.call(this.functions, finalize_name)) {
|
|
1441
|
+
removeFunction(this.functions[finalize_name]);
|
|
1442
|
+
delete this.functions[finalize_name];
|
|
1443
|
+
}
|
|
1444
|
+
// The signature of the wrapped function is :
|
|
1445
|
+
// void wrapped(sqlite3_context *db, int argc, sqlite3_value **argv)
|
|
1446
|
+
var step_ptr = addFunction(wrapped_step, "viii");
|
|
1447
|
+
|
|
1448
|
+
// The signature of the wrapped function is :
|
|
1449
|
+
// void wrapped(sqlite3_context *db)
|
|
1450
|
+
var finalize_ptr = addFunction(wrapped_finalize, "vi");
|
|
1451
|
+
this.functions[name] = step_ptr;
|
|
1452
|
+
this.functions[finalize_name] = finalize_ptr;
|
|
1453
|
+
|
|
1454
|
+
// passing null to the sixth parameter defines this as an aggregate
|
|
1455
|
+
// function
|
|
1456
|
+
//
|
|
1457
|
+
// > An aggregate SQL function requires an implementation of xStep and
|
|
1458
|
+
// > xFinal and NULL pointer must be passed for xFunc.
|
|
1459
|
+
// - http://www.sqlite.org/c3ref/create_function.html
|
|
1460
|
+
this.handleError(sqlite3_create_function_v2(
|
|
1461
|
+
this.db,
|
|
1462
|
+
name,
|
|
1463
|
+
step.length - 1,
|
|
1464
|
+
SQLITE_UTF8,
|
|
1465
|
+
0,
|
|
1466
|
+
0,
|
|
1467
|
+
step_ptr,
|
|
1468
|
+
finalize_ptr,
|
|
1469
|
+
0
|
|
1470
|
+
));
|
|
1471
|
+
return this;
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1324
1474
|
// export Database to Module
|
|
1325
1475
|
Module.Database = Database;
|
|
1326
1476
|
};
|
|
@@ -1351,7 +1501,7 @@ var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions
|
|
|
1351
1501
|
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
1352
1502
|
|
|
1353
1503
|
if (Module['ENVIRONMENT']) {
|
|
1354
|
-
throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -
|
|
1504
|
+
throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
|
|
1355
1505
|
}
|
|
1356
1506
|
|
|
1357
1507
|
// `/` should be present at the end if `scriptDirectory` is not empty
|
|
@@ -1390,7 +1540,7 @@ var nodePath;
|
|
|
1390
1540
|
var requireNodeFS;
|
|
1391
1541
|
|
|
1392
1542
|
if (ENVIRONMENT_IS_NODE) {
|
|
1393
|
-
if (
|
|
1543
|
+
if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
1394
1544
|
if (ENVIRONMENT_IS_WORKER) {
|
|
1395
1545
|
scriptDirectory = require('path').dirname(scriptDirectory) + '/';
|
|
1396
1546
|
} else {
|
|
@@ -1614,8 +1764,7 @@ var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js
|
|
|
1614
1764
|
var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
|
|
1615
1765
|
var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
|
|
1616
1766
|
|
|
1617
|
-
|
|
1618
|
-
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-s ENVIRONMENT` to enable.");
|
|
1767
|
+
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");
|
|
1619
1768
|
|
|
1620
1769
|
|
|
1621
1770
|
|
|
@@ -1625,199 +1774,26 @@ var POINTER_SIZE = 4;
|
|
|
1625
1774
|
|
|
1626
1775
|
function getNativeTypeSize(type) {
|
|
1627
1776
|
switch (type) {
|
|
1628
|
-
case 'i1': case 'i8': return 1;
|
|
1629
|
-
case 'i16': return 2;
|
|
1630
|
-
case 'i32': return 4;
|
|
1631
|
-
case 'i64': return 8;
|
|
1777
|
+
case 'i1': case 'i8': case 'u8': return 1;
|
|
1778
|
+
case 'i16': case 'u16': return 2;
|
|
1779
|
+
case 'i32': case 'u32': return 4;
|
|
1780
|
+
case 'i64': case 'u64': return 8;
|
|
1632
1781
|
case 'float': return 4;
|
|
1633
1782
|
case 'double': return 8;
|
|
1634
1783
|
default: {
|
|
1635
1784
|
if (type[type.length - 1] === '*') {
|
|
1636
1785
|
return POINTER_SIZE;
|
|
1637
|
-
}
|
|
1786
|
+
}
|
|
1787
|
+
if (type[0] === 'i') {
|
|
1638
1788
|
const bits = Number(type.substr(1));
|
|
1639
1789
|
assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type);
|
|
1640
1790
|
return bits / 8;
|
|
1641
|
-
} else {
|
|
1642
|
-
return 0;
|
|
1643
1791
|
}
|
|
1792
|
+
return 0;
|
|
1644
1793
|
}
|
|
1645
1794
|
}
|
|
1646
1795
|
}
|
|
1647
1796
|
|
|
1648
|
-
function warnOnce(text) {
|
|
1649
|
-
if (!warnOnce.shown) warnOnce.shown = {};
|
|
1650
|
-
if (!warnOnce.shown[text]) {
|
|
1651
|
-
warnOnce.shown[text] = 1;
|
|
1652
|
-
err(text);
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
// include: runtime_functions.js
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
// Wraps a JS function as a wasm function with a given signature.
|
|
1660
|
-
function convertJsFunctionToWasm(func, sig) {
|
|
1661
|
-
|
|
1662
|
-
// If the type reflection proposal is available, use the new
|
|
1663
|
-
// "WebAssembly.Function" constructor.
|
|
1664
|
-
// Otherwise, construct a minimal wasm module importing the JS function and
|
|
1665
|
-
// re-exporting it.
|
|
1666
|
-
if (typeof WebAssembly.Function == "function") {
|
|
1667
|
-
var typeNames = {
|
|
1668
|
-
'i': 'i32',
|
|
1669
|
-
'j': 'i64',
|
|
1670
|
-
'f': 'f32',
|
|
1671
|
-
'd': 'f64'
|
|
1672
|
-
};
|
|
1673
|
-
var type = {
|
|
1674
|
-
parameters: [],
|
|
1675
|
-
results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
|
|
1676
|
-
};
|
|
1677
|
-
for (var i = 1; i < sig.length; ++i) {
|
|
1678
|
-
type.parameters.push(typeNames[sig[i]]);
|
|
1679
|
-
}
|
|
1680
|
-
return new WebAssembly.Function(type, func);
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
// The module is static, with the exception of the type section, which is
|
|
1684
|
-
// generated based on the signature passed in.
|
|
1685
|
-
var typeSection = [
|
|
1686
|
-
0x01, // id: section,
|
|
1687
|
-
0x00, // length: 0 (placeholder)
|
|
1688
|
-
0x01, // count: 1
|
|
1689
|
-
0x60, // form: func
|
|
1690
|
-
];
|
|
1691
|
-
var sigRet = sig.slice(0, 1);
|
|
1692
|
-
var sigParam = sig.slice(1);
|
|
1693
|
-
var typeCodes = {
|
|
1694
|
-
'i': 0x7f, // i32
|
|
1695
|
-
'j': 0x7e, // i64
|
|
1696
|
-
'f': 0x7d, // f32
|
|
1697
|
-
'd': 0x7c, // f64
|
|
1698
|
-
};
|
|
1699
|
-
|
|
1700
|
-
// Parameters, length + signatures
|
|
1701
|
-
typeSection.push(sigParam.length);
|
|
1702
|
-
for (var i = 0; i < sigParam.length; ++i) {
|
|
1703
|
-
typeSection.push(typeCodes[sigParam[i]]);
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
// Return values, length + signatures
|
|
1707
|
-
// With no multi-return in MVP, either 0 (void) or 1 (anything else)
|
|
1708
|
-
if (sigRet == 'v') {
|
|
1709
|
-
typeSection.push(0x00);
|
|
1710
|
-
} else {
|
|
1711
|
-
typeSection = typeSection.concat([0x01, typeCodes[sigRet]]);
|
|
1712
|
-
}
|
|
1713
|
-
|
|
1714
|
-
// Write the overall length of the type section back into the section header
|
|
1715
|
-
// (excepting the 2 bytes for the section id and length)
|
|
1716
|
-
typeSection[1] = typeSection.length - 2;
|
|
1717
|
-
|
|
1718
|
-
// Rest of the module is static
|
|
1719
|
-
var bytes = new Uint8Array([
|
|
1720
|
-
0x00, 0x61, 0x73, 0x6d, // magic ("\0asm")
|
|
1721
|
-
0x01, 0x00, 0x00, 0x00, // version: 1
|
|
1722
|
-
].concat(typeSection, [
|
|
1723
|
-
0x02, 0x07, // import section
|
|
1724
|
-
// (import "e" "f" (func 0 (type 0)))
|
|
1725
|
-
0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00,
|
|
1726
|
-
0x07, 0x05, // export section
|
|
1727
|
-
// (export "f" (func 0 (type 0)))
|
|
1728
|
-
0x01, 0x01, 0x66, 0x00, 0x00,
|
|
1729
|
-
]));
|
|
1730
|
-
|
|
1731
|
-
// We can compile this wasm module synchronously because it is very small.
|
|
1732
|
-
// This accepts an import (at "e.f"), that it reroutes to an export (at "f")
|
|
1733
|
-
var module = new WebAssembly.Module(bytes);
|
|
1734
|
-
var instance = new WebAssembly.Instance(module, {
|
|
1735
|
-
'e': {
|
|
1736
|
-
'f': func
|
|
1737
|
-
}
|
|
1738
|
-
});
|
|
1739
|
-
var wrappedFunc = instance.exports['f'];
|
|
1740
|
-
return wrappedFunc;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
var freeTableIndexes = [];
|
|
1744
|
-
|
|
1745
|
-
// Weak map of functions in the table to their indexes, created on first use.
|
|
1746
|
-
var functionsInTableMap;
|
|
1747
|
-
|
|
1748
|
-
function getEmptyTableSlot() {
|
|
1749
|
-
// Reuse a free index if there is one, otherwise grow.
|
|
1750
|
-
if (freeTableIndexes.length) {
|
|
1751
|
-
return freeTableIndexes.pop();
|
|
1752
|
-
}
|
|
1753
|
-
// Grow the table
|
|
1754
|
-
try {
|
|
1755
|
-
wasmTable.grow(1);
|
|
1756
|
-
} catch (err) {
|
|
1757
|
-
if (!(err instanceof RangeError)) {
|
|
1758
|
-
throw err;
|
|
1759
|
-
}
|
|
1760
|
-
throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
|
|
1761
|
-
}
|
|
1762
|
-
return wasmTable.length - 1;
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
function updateTableMap(offset, count) {
|
|
1766
|
-
for (var i = offset; i < offset + count; i++) {
|
|
1767
|
-
var item = getWasmTableEntry(i);
|
|
1768
|
-
// Ignore null values.
|
|
1769
|
-
if (item) {
|
|
1770
|
-
functionsInTableMap.set(item, i);
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
/**
|
|
1776
|
-
* Add a function to the table.
|
|
1777
|
-
* 'sig' parameter is required if the function being added is a JS function.
|
|
1778
|
-
* @param {string=} sig
|
|
1779
|
-
*/
|
|
1780
|
-
function addFunction(func, sig) {
|
|
1781
|
-
assert(typeof func != 'undefined');
|
|
1782
|
-
|
|
1783
|
-
// Check if the function is already in the table, to ensure each function
|
|
1784
|
-
// gets a unique index. First, create the map if this is the first use.
|
|
1785
|
-
if (!functionsInTableMap) {
|
|
1786
|
-
functionsInTableMap = new WeakMap();
|
|
1787
|
-
updateTableMap(0, wasmTable.length);
|
|
1788
|
-
}
|
|
1789
|
-
if (functionsInTableMap.has(func)) {
|
|
1790
|
-
return functionsInTableMap.get(func);
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
// It's not in the table, add it now.
|
|
1794
|
-
|
|
1795
|
-
var ret = getEmptyTableSlot();
|
|
1796
|
-
|
|
1797
|
-
// Set the new value.
|
|
1798
|
-
try {
|
|
1799
|
-
// Attempting to call this with JS function will cause of table.set() to fail
|
|
1800
|
-
setWasmTableEntry(ret, func);
|
|
1801
|
-
} catch (err) {
|
|
1802
|
-
if (!(err instanceof TypeError)) {
|
|
1803
|
-
throw err;
|
|
1804
|
-
}
|
|
1805
|
-
assert(typeof sig != 'undefined', 'Missing signature argument to addFunction: ' + func);
|
|
1806
|
-
var wrapped = convertJsFunctionToWasm(func, sig);
|
|
1807
|
-
setWasmTableEntry(ret, wrapped);
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
functionsInTableMap.set(func, ret);
|
|
1811
|
-
|
|
1812
|
-
return ret;
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
function removeFunction(index) {
|
|
1816
|
-
functionsInTableMap.delete(getWasmTableEntry(index));
|
|
1817
|
-
freeTableIndexes.push(index);
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
// end include: runtime_functions.js
|
|
1821
1797
|
// include: runtime_debug.js
|
|
1822
1798
|
|
|
1823
1799
|
|
|
@@ -1838,36 +1814,53 @@ function ignoredModuleProp(prop) {
|
|
|
1838
1814
|
}
|
|
1839
1815
|
}
|
|
1840
1816
|
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1817
|
+
// forcing the filesystem exports a few things by default
|
|
1818
|
+
function isExportedByForceFilesystem(name) {
|
|
1819
|
+
return name === 'FS_createPath' ||
|
|
1820
|
+
name === 'FS_createDataFile' ||
|
|
1821
|
+
name === 'FS_createPreloadedFile' ||
|
|
1822
|
+
name === 'FS_unlink' ||
|
|
1823
|
+
name === 'addRunDependency' ||
|
|
1824
|
+
// The old FS has some functionality that WasmFS lacks.
|
|
1825
|
+
name === 'FS_createLazyFile' ||
|
|
1826
|
+
name === 'FS_createDevice' ||
|
|
1827
|
+
name === 'removeRunDependency';
|
|
1847
1828
|
}
|
|
1848
1829
|
|
|
1849
|
-
function
|
|
1850
|
-
if (!Object.getOwnPropertyDescriptor(
|
|
1851
|
-
Object.defineProperty(
|
|
1830
|
+
function missingLibrarySymbol(sym) {
|
|
1831
|
+
if (typeof globalThis !== 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
|
|
1832
|
+
Object.defineProperty(globalThis, sym, {
|
|
1852
1833
|
configurable: true,
|
|
1853
1834
|
get: function() {
|
|
1854
|
-
abort(
|
|
1835
|
+
// Can't `abort()` here because it would break code that does runtime
|
|
1836
|
+
// checks. e.g. `if (typeof SDL === 'undefined')`.
|
|
1837
|
+
var msg = '`' + sym + '` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line';
|
|
1838
|
+
if (isExportedByForceFilesystem(sym)) {
|
|
1839
|
+
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
1840
|
+
}
|
|
1841
|
+
warnOnce(msg);
|
|
1842
|
+
return undefined;
|
|
1855
1843
|
}
|
|
1856
1844
|
});
|
|
1857
1845
|
}
|
|
1858
1846
|
}
|
|
1859
1847
|
|
|
1860
|
-
function
|
|
1848
|
+
function unexportedRuntimeSymbol(sym) {
|
|
1861
1849
|
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
|
|
1862
|
-
Module
|
|
1850
|
+
Object.defineProperty(Module, sym, {
|
|
1851
|
+
configurable: true,
|
|
1852
|
+
get: function() {
|
|
1853
|
+
var msg = "'" + sym + "' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";
|
|
1854
|
+
if (isExportedByForceFilesystem(sym)) {
|
|
1855
|
+
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
1856
|
+
}
|
|
1857
|
+
abort(msg);
|
|
1858
|
+
}
|
|
1859
|
+
});
|
|
1863
1860
|
}
|
|
1864
1861
|
}
|
|
1865
1862
|
|
|
1866
1863
|
// end include: runtime_debug.js
|
|
1867
|
-
var tempRet0 = 0;
|
|
1868
|
-
var setTempRet0 = (value) => { tempRet0 = value; };
|
|
1869
|
-
var getTempRet0 = () => tempRet0;
|
|
1870
|
-
|
|
1871
1864
|
|
|
1872
1865
|
|
|
1873
1866
|
// === Preamble library stuff ===
|
|
@@ -1888,49 +1881,6 @@ if (typeof WebAssembly != 'object') {
|
|
|
1888
1881
|
abort('no native wasm support detected');
|
|
1889
1882
|
}
|
|
1890
1883
|
|
|
1891
|
-
// include: runtime_safe_heap.js
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
// In MINIMAL_RUNTIME, setValue() and getValue() are only available when building with safe heap enabled, for heap safety checking.
|
|
1895
|
-
// In traditional runtime, setValue() and getValue() are always available (although their use is highly discouraged due to perf penalties)
|
|
1896
|
-
|
|
1897
|
-
/** @param {number} ptr
|
|
1898
|
-
@param {number} value
|
|
1899
|
-
@param {string} type
|
|
1900
|
-
@param {number|boolean=} noSafe */
|
|
1901
|
-
function setValue(ptr, value, type = 'i8', noSafe) {
|
|
1902
|
-
if (type.charAt(type.length-1) === '*') type = 'i32';
|
|
1903
|
-
switch (type) {
|
|
1904
|
-
case 'i1': HEAP8[((ptr)>>0)] = value; break;
|
|
1905
|
-
case 'i8': HEAP8[((ptr)>>0)] = value; break;
|
|
1906
|
-
case 'i16': HEAP16[((ptr)>>1)] = value; break;
|
|
1907
|
-
case 'i32': HEAP32[((ptr)>>2)] = value; break;
|
|
1908
|
-
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;
|
|
1909
|
-
case 'float': HEAPF32[((ptr)>>2)] = value; break;
|
|
1910
|
-
case 'double': HEAPF64[((ptr)>>3)] = value; break;
|
|
1911
|
-
default: abort('invalid type for setValue: ' + type);
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
|
-
/** @param {number} ptr
|
|
1916
|
-
@param {string} type
|
|
1917
|
-
@param {number|boolean=} noSafe */
|
|
1918
|
-
function getValue(ptr, type = 'i8', noSafe) {
|
|
1919
|
-
if (type.charAt(type.length-1) === '*') type = 'i32';
|
|
1920
|
-
switch (type) {
|
|
1921
|
-
case 'i1': return HEAP8[((ptr)>>0)];
|
|
1922
|
-
case 'i8': return HEAP8[((ptr)>>0)];
|
|
1923
|
-
case 'i16': return HEAP16[((ptr)>>1)];
|
|
1924
|
-
case 'i32': return HEAP32[((ptr)>>2)];
|
|
1925
|
-
case 'i64': return HEAP32[((ptr)>>2)];
|
|
1926
|
-
case 'float': return HEAPF32[((ptr)>>2)];
|
|
1927
|
-
case 'double': return Number(HEAPF64[((ptr)>>3)]);
|
|
1928
|
-
default: abort('invalid type for getValue: ' + type);
|
|
1929
|
-
}
|
|
1930
|
-
return null;
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
|
-
// end include: runtime_safe_heap.js
|
|
1934
1884
|
// Wasm globals
|
|
1935
1885
|
|
|
1936
1886
|
var wasmMemory;
|
|
@@ -1955,115 +1905,9 @@ function assert(condition, text) {
|
|
|
1955
1905
|
}
|
|
1956
1906
|
}
|
|
1957
1907
|
|
|
1958
|
-
// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
|
|
1959
|
-
function getCFunc(ident) {
|
|
1960
|
-
var func = Module['_' + ident]; // closure exported function
|
|
1961
|
-
assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
|
|
1962
|
-
return func;
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
// C calling interface.
|
|
1966
|
-
/** @param {string|null=} returnType
|
|
1967
|
-
@param {Array=} argTypes
|
|
1968
|
-
@param {Arguments|Array=} args
|
|
1969
|
-
@param {Object=} opts */
|
|
1970
|
-
function ccall(ident, returnType, argTypes, args, opts) {
|
|
1971
|
-
// For fast lookup of conversion functions
|
|
1972
|
-
var toC = {
|
|
1973
|
-
'string': function(str) {
|
|
1974
|
-
var ret = 0;
|
|
1975
|
-
if (str !== null && str !== undefined && str !== 0) { // null string
|
|
1976
|
-
// at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
|
|
1977
|
-
var len = (str.length << 2) + 1;
|
|
1978
|
-
ret = stackAlloc(len);
|
|
1979
|
-
stringToUTF8(str, ret, len);
|
|
1980
|
-
}
|
|
1981
|
-
return ret;
|
|
1982
|
-
},
|
|
1983
|
-
'array': function(arr) {
|
|
1984
|
-
var ret = stackAlloc(arr.length);
|
|
1985
|
-
writeArrayToMemory(arr, ret);
|
|
1986
|
-
return ret;
|
|
1987
|
-
}
|
|
1988
|
-
};
|
|
1989
|
-
|
|
1990
|
-
function convertReturnValue(ret) {
|
|
1991
|
-
if (returnType === 'string') return UTF8ToString(ret);
|
|
1992
|
-
if (returnType === 'boolean') return Boolean(ret);
|
|
1993
|
-
return ret;
|
|
1994
|
-
}
|
|
1995
|
-
|
|
1996
|
-
var func = getCFunc(ident);
|
|
1997
|
-
var cArgs = [];
|
|
1998
|
-
var stack = 0;
|
|
1999
|
-
assert(returnType !== 'array', 'Return type should not be "array".');
|
|
2000
|
-
if (args) {
|
|
2001
|
-
for (var i = 0; i < args.length; i++) {
|
|
2002
|
-
var converter = toC[argTypes[i]];
|
|
2003
|
-
if (converter) {
|
|
2004
|
-
if (stack === 0) stack = stackSave();
|
|
2005
|
-
cArgs[i] = converter(args[i]);
|
|
2006
|
-
} else {
|
|
2007
|
-
cArgs[i] = args[i];
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
var ret = func.apply(null, cArgs);
|
|
2012
|
-
function onDone(ret) {
|
|
2013
|
-
if (stack !== 0) stackRestore(stack);
|
|
2014
|
-
return convertReturnValue(ret);
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
ret = onDone(ret);
|
|
2018
|
-
return ret;
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
/** @param {string=} returnType
|
|
2022
|
-
@param {Array=} argTypes
|
|
2023
|
-
@param {Object=} opts */
|
|
2024
|
-
function cwrap(ident, returnType, argTypes, opts) {
|
|
2025
|
-
return function() {
|
|
2026
|
-
return ccall(ident, returnType, argTypes, arguments, opts);
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
1908
|
// We used to include malloc/free by default in the past. Show a helpful error in
|
|
2031
1909
|
// builds with assertions.
|
|
2032
1910
|
|
|
2033
|
-
// include: runtime_legacy.js
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
var ALLOC_NORMAL = 0; // Tries to use _malloc()
|
|
2037
|
-
var ALLOC_STACK = 1; // Lives for the duration of the current function call
|
|
2038
|
-
|
|
2039
|
-
/**
|
|
2040
|
-
* allocate(): This function is no longer used by emscripten but is kept around to avoid
|
|
2041
|
-
* breaking external users.
|
|
2042
|
-
* You should normally not use allocate(), and instead allocate
|
|
2043
|
-
* memory using _malloc()/stackAlloc(), initialize it with
|
|
2044
|
-
* setValue(), and so forth.
|
|
2045
|
-
* @param {(Uint8Array|Array<number>)} slab: An array of data.
|
|
2046
|
-
* @param {number=} allocator : How to allocate memory, see ALLOC_*
|
|
2047
|
-
*/
|
|
2048
|
-
function allocate(slab, allocator) {
|
|
2049
|
-
var ret;
|
|
2050
|
-
assert(typeof allocator == 'number', 'allocate no longer takes a type argument')
|
|
2051
|
-
assert(typeof slab != 'number', 'allocate no longer takes a number as arg0')
|
|
2052
|
-
|
|
2053
|
-
if (allocator == ALLOC_STACK) {
|
|
2054
|
-
ret = stackAlloc(slab.length);
|
|
2055
|
-
} else {
|
|
2056
|
-
ret = _malloc(slab.length);
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
if (!slab.subarray && !slab.slice) {
|
|
2060
|
-
slab = new Uint8Array(slab);
|
|
2061
|
-
}
|
|
2062
|
-
HEAPU8.set(slab, ret);
|
|
2063
|
-
return ret;
|
|
2064
|
-
}
|
|
2065
|
-
|
|
2066
|
-
// end include: runtime_legacy.js
|
|
2067
1911
|
// include: runtime_strings.js
|
|
2068
1912
|
|
|
2069
1913
|
|
|
@@ -2089,32 +1933,31 @@ function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
|
|
|
2089
1933
|
|
|
2090
1934
|
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
2091
1935
|
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
1936
|
+
}
|
|
1937
|
+
var str = '';
|
|
1938
|
+
// If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
|
|
1939
|
+
while (idx < endPtr) {
|
|
1940
|
+
// For UTF8 byte structure, see:
|
|
1941
|
+
// http://en.wikipedia.org/wiki/UTF-8#Description
|
|
1942
|
+
// https://www.ietf.org/rfc/rfc2279.txt
|
|
1943
|
+
// https://tools.ietf.org/html/rfc3629
|
|
1944
|
+
var u0 = heapOrArray[idx++];
|
|
1945
|
+
if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
|
|
1946
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
1947
|
+
if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
|
|
1948
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
1949
|
+
if ((u0 & 0xF0) == 0xE0) {
|
|
1950
|
+
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
|
1951
|
+
} else {
|
|
1952
|
+
if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte 0x' + u0.toString(16) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!');
|
|
1953
|
+
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
|
|
1954
|
+
}
|
|
2111
1955
|
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
}
|
|
1956
|
+
if (u0 < 0x10000) {
|
|
1957
|
+
str += String.fromCharCode(u0);
|
|
1958
|
+
} else {
|
|
1959
|
+
var ch = u0 - 0x10000;
|
|
1960
|
+
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
|
2118
1961
|
}
|
|
2119
1962
|
}
|
|
2120
1963
|
return str;
|
|
@@ -2136,7 +1979,6 @@ function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
|
|
|
2136
1979
|
* @return {string}
|
|
2137
1980
|
*/
|
|
2138
1981
|
function UTF8ToString(ptr, maxBytesToRead) {
|
|
2139
|
-
;
|
|
2140
1982
|
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
|
|
2141
1983
|
}
|
|
2142
1984
|
|
|
@@ -2210,245 +2052,21 @@ function lengthBytesUTF8(str) {
|
|
|
2210
2052
|
for (var i = 0; i < str.length; ++i) {
|
|
2211
2053
|
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
|
|
2212
2054
|
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
2213
|
-
var
|
|
2214
|
-
if (
|
|
2215
|
-
|
|
2216
|
-
else if (
|
|
2217
|
-
|
|
2218
|
-
else
|
|
2219
|
-
|
|
2220
|
-
return len;
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
|
-
// end include: runtime_strings.js
|
|
2224
|
-
// include: runtime_strings_extra.js
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
// runtime_strings_extra.js: Strings related runtime functions that are available only in regular runtime.
|
|
2228
|
-
|
|
2229
|
-
// Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns
|
|
2230
|
-
// a copy of that string as a Javascript String object.
|
|
2231
|
-
|
|
2232
|
-
function AsciiToString(ptr) {
|
|
2233
|
-
var str = '';
|
|
2234
|
-
while (1) {
|
|
2235
|
-
var ch = HEAPU8[((ptr++)>>0)];
|
|
2236
|
-
if (!ch) return str;
|
|
2237
|
-
str += String.fromCharCode(ch);
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
|
|
2242
|
-
// null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP.
|
|
2243
|
-
|
|
2244
|
-
function stringToAscii(str, outPtr) {
|
|
2245
|
-
return writeAsciiToMemory(str, outPtr, false);
|
|
2246
|
-
}
|
|
2247
|
-
|
|
2248
|
-
// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
|
|
2249
|
-
// a copy of that string as a Javascript String object.
|
|
2250
|
-
|
|
2251
|
-
var UTF16Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf-16le') : undefined;
|
|
2252
|
-
|
|
2253
|
-
function UTF16ToString(ptr, maxBytesToRead) {
|
|
2254
|
-
assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
|
|
2255
|
-
var endPtr = ptr;
|
|
2256
|
-
// TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
|
|
2257
|
-
// Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
|
|
2258
|
-
var idx = endPtr >> 1;
|
|
2259
|
-
var maxIdx = idx + maxBytesToRead / 2;
|
|
2260
|
-
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
|
|
2261
|
-
// will always evaluate to true. This saves on code size.
|
|
2262
|
-
while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
|
|
2263
|
-
endPtr = idx << 1;
|
|
2264
|
-
|
|
2265
|
-
if (endPtr - ptr > 32 && UTF16Decoder) {
|
|
2266
|
-
return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
|
|
2267
|
-
} else {
|
|
2268
|
-
var str = '';
|
|
2269
|
-
|
|
2270
|
-
// If maxBytesToRead is not passed explicitly, it will be undefined, and the for-loop's condition
|
|
2271
|
-
// will always evaluate to true. The loop is then terminated on the first null char.
|
|
2272
|
-
for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
|
|
2273
|
-
var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
|
|
2274
|
-
if (codeUnit == 0) break;
|
|
2275
|
-
// fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
|
|
2276
|
-
str += String.fromCharCode(codeUnit);
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
return str;
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
|
|
2284
|
-
// null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP.
|
|
2285
|
-
// Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write.
|
|
2286
|
-
// Parameters:
|
|
2287
|
-
// str: the Javascript string to copy.
|
|
2288
|
-
// outPtr: Byte address in Emscripten HEAP where to write the string to.
|
|
2289
|
-
// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
|
|
2290
|
-
// terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else.
|
|
2291
|
-
// maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator.
|
|
2292
|
-
// Returns the number of bytes written, EXCLUDING the null terminator.
|
|
2293
|
-
|
|
2294
|
-
function stringToUTF16(str, outPtr, maxBytesToWrite) {
|
|
2295
|
-
assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
|
|
2296
|
-
assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
2297
|
-
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
2298
|
-
if (maxBytesToWrite === undefined) {
|
|
2299
|
-
maxBytesToWrite = 0x7FFFFFFF;
|
|
2300
|
-
}
|
|
2301
|
-
if (maxBytesToWrite < 2) return 0;
|
|
2302
|
-
maxBytesToWrite -= 2; // Null terminator.
|
|
2303
|
-
var startPtr = outPtr;
|
|
2304
|
-
var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
|
|
2305
|
-
for (var i = 0; i < numCharsToWrite; ++i) {
|
|
2306
|
-
// charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
|
|
2307
|
-
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
|
|
2308
|
-
HEAP16[((outPtr)>>1)] = codeUnit;
|
|
2309
|
-
outPtr += 2;
|
|
2310
|
-
}
|
|
2311
|
-
// Null-terminate the pointer to the HEAP.
|
|
2312
|
-
HEAP16[((outPtr)>>1)] = 0;
|
|
2313
|
-
return outPtr - startPtr;
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
|
|
2317
|
-
|
|
2318
|
-
function lengthBytesUTF16(str) {
|
|
2319
|
-
return str.length*2;
|
|
2320
|
-
}
|
|
2321
|
-
|
|
2322
|
-
function UTF32ToString(ptr, maxBytesToRead) {
|
|
2323
|
-
assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
|
|
2324
|
-
var i = 0;
|
|
2325
|
-
|
|
2326
|
-
var str = '';
|
|
2327
|
-
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
|
|
2328
|
-
// will always evaluate to true. This saves on code size.
|
|
2329
|
-
while (!(i >= maxBytesToRead / 4)) {
|
|
2330
|
-
var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
|
|
2331
|
-
if (utf32 == 0) break;
|
|
2332
|
-
++i;
|
|
2333
|
-
// Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
|
|
2334
|
-
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
2335
|
-
if (utf32 >= 0x10000) {
|
|
2336
|
-
var ch = utf32 - 0x10000;
|
|
2337
|
-
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
|
2055
|
+
var c = str.charCodeAt(i); // possibly a lead surrogate
|
|
2056
|
+
if (c <= 0x7F) {
|
|
2057
|
+
len++;
|
|
2058
|
+
} else if (c <= 0x7FF) {
|
|
2059
|
+
len += 2;
|
|
2060
|
+
} else if (c >= 0xD800 && c <= 0xDFFF) {
|
|
2061
|
+
len += 4; ++i;
|
|
2338
2062
|
} else {
|
|
2339
|
-
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
return str;
|
|
2343
|
-
}
|
|
2344
|
-
|
|
2345
|
-
// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
|
|
2346
|
-
// null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP.
|
|
2347
|
-
// Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write.
|
|
2348
|
-
// Parameters:
|
|
2349
|
-
// str: the Javascript string to copy.
|
|
2350
|
-
// outPtr: Byte address in Emscripten HEAP where to write the string to.
|
|
2351
|
-
// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
|
|
2352
|
-
// terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else.
|
|
2353
|
-
// maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator.
|
|
2354
|
-
// Returns the number of bytes written, EXCLUDING the null terminator.
|
|
2355
|
-
|
|
2356
|
-
function stringToUTF32(str, outPtr, maxBytesToWrite) {
|
|
2357
|
-
assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
|
|
2358
|
-
assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
2359
|
-
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
2360
|
-
if (maxBytesToWrite === undefined) {
|
|
2361
|
-
maxBytesToWrite = 0x7FFFFFFF;
|
|
2362
|
-
}
|
|
2363
|
-
if (maxBytesToWrite < 4) return 0;
|
|
2364
|
-
var startPtr = outPtr;
|
|
2365
|
-
var endPtr = startPtr + maxBytesToWrite - 4;
|
|
2366
|
-
for (var i = 0; i < str.length; ++i) {
|
|
2367
|
-
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
|
|
2368
|
-
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
2369
|
-
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
|
|
2370
|
-
if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
|
|
2371
|
-
var trailSurrogate = str.charCodeAt(++i);
|
|
2372
|
-
codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
|
|
2063
|
+
len += 3;
|
|
2373
2064
|
}
|
|
2374
|
-
HEAP32[((outPtr)>>2)] = codeUnit;
|
|
2375
|
-
outPtr += 4;
|
|
2376
|
-
if (outPtr + 4 > endPtr) break;
|
|
2377
|
-
}
|
|
2378
|
-
// Null-terminate the pointer to the HEAP.
|
|
2379
|
-
HEAP32[((outPtr)>>2)] = 0;
|
|
2380
|
-
return outPtr - startPtr;
|
|
2381
|
-
}
|
|
2382
|
-
|
|
2383
|
-
// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
|
|
2384
|
-
|
|
2385
|
-
function lengthBytesUTF32(str) {
|
|
2386
|
-
var len = 0;
|
|
2387
|
-
for (var i = 0; i < str.length; ++i) {
|
|
2388
|
-
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
|
|
2389
|
-
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
2390
|
-
var codeUnit = str.charCodeAt(i);
|
|
2391
|
-
if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
|
|
2392
|
-
len += 4;
|
|
2393
2065
|
}
|
|
2394
|
-
|
|
2395
2066
|
return len;
|
|
2396
2067
|
}
|
|
2397
2068
|
|
|
2398
|
-
//
|
|
2399
|
-
// It is the responsibility of the caller to free() that memory.
|
|
2400
|
-
function allocateUTF8(str) {
|
|
2401
|
-
var size = lengthBytesUTF8(str) + 1;
|
|
2402
|
-
var ret = _malloc(size);
|
|
2403
|
-
if (ret) stringToUTF8Array(str, HEAP8, ret, size);
|
|
2404
|
-
return ret;
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
// Allocate stack space for a JS string, and write it there.
|
|
2408
|
-
function allocateUTF8OnStack(str) {
|
|
2409
|
-
var size = lengthBytesUTF8(str) + 1;
|
|
2410
|
-
var ret = stackAlloc(size);
|
|
2411
|
-
stringToUTF8Array(str, HEAP8, ret, size);
|
|
2412
|
-
return ret;
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2415
|
-
// Deprecated: This function should not be called because it is unsafe and does not provide
|
|
2416
|
-
// a maximum length limit of how many bytes it is allowed to write. Prefer calling the
|
|
2417
|
-
// function stringToUTF8Array() instead, which takes in a maximum length that can be used
|
|
2418
|
-
// to be secure from out of bounds writes.
|
|
2419
|
-
/** @deprecated
|
|
2420
|
-
@param {boolean=} dontAddNull */
|
|
2421
|
-
function writeStringToMemory(string, buffer, dontAddNull) {
|
|
2422
|
-
warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
|
|
2423
|
-
|
|
2424
|
-
var /** @type {number} */ lastChar, /** @type {number} */ end;
|
|
2425
|
-
if (dontAddNull) {
|
|
2426
|
-
// stringToUTF8Array always appends null. If we don't want to do that, remember the
|
|
2427
|
-
// character that existed at the location where the null will be placed, and restore
|
|
2428
|
-
// that after the write (below).
|
|
2429
|
-
end = buffer + lengthBytesUTF8(string);
|
|
2430
|
-
lastChar = HEAP8[end];
|
|
2431
|
-
}
|
|
2432
|
-
stringToUTF8(string, buffer, Infinity);
|
|
2433
|
-
if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character.
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
function writeArrayToMemory(array, buffer) {
|
|
2437
|
-
assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
|
|
2438
|
-
HEAP8.set(array, buffer);
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
|
-
/** @param {boolean=} dontAddNull */
|
|
2442
|
-
function writeAsciiToMemory(str, buffer, dontAddNull) {
|
|
2443
|
-
for (var i = 0; i < str.length; ++i) {
|
|
2444
|
-
assert(str.charCodeAt(i) === (str.charCodeAt(i) & 0xff));
|
|
2445
|
-
HEAP8[((buffer++)>>0)] = str.charCodeAt(i);
|
|
2446
|
-
}
|
|
2447
|
-
// Null-terminate the pointer to the HEAP.
|
|
2448
|
-
if (!dontAddNull) HEAP8[((buffer)>>0)] = 0;
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
|
-
// end include: runtime_strings_extra.js
|
|
2069
|
+
// end include: runtime_strings.js
|
|
2452
2070
|
// Memory management
|
|
2453
2071
|
|
|
2454
2072
|
var HEAP,
|
|
@@ -2495,8 +2113,8 @@ assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' &
|
|
|
2495
2113
|
'JS engine does not provide full typed array support');
|
|
2496
2114
|
|
|
2497
2115
|
// If memory is defined in wasm, the user can't provide it.
|
|
2498
|
-
assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected. Use -
|
|
2499
|
-
assert(INITIAL_MEMORY == 16777216, 'Detected runtime INITIAL_MEMORY setting. Use -
|
|
2116
|
+
assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
|
|
2117
|
+
assert(INITIAL_MEMORY == 16777216, 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
|
|
2500
2118
|
|
|
2501
2119
|
// include: runtime_init_table.js
|
|
2502
2120
|
// In regular non-RELOCATABLE mode the table is exported
|
|
@@ -2515,10 +2133,10 @@ function writeStackCookie() {
|
|
|
2515
2133
|
// The stack grow downwards towards _emscripten_stack_get_end.
|
|
2516
2134
|
// We write cookies to the final two words in the stack and detect if they are
|
|
2517
2135
|
// ever overwritten.
|
|
2518
|
-
|
|
2519
|
-
|
|
2136
|
+
HEAPU32[((max)>>2)] = 0x2135467;
|
|
2137
|
+
HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
|
|
2520
2138
|
// Also test the global address 0 for integrity.
|
|
2521
|
-
|
|
2139
|
+
HEAPU32[0] = 0x63736d65; /* 'emsc' */
|
|
2522
2140
|
}
|
|
2523
2141
|
|
|
2524
2142
|
function checkStackCookie() {
|
|
@@ -2527,10 +2145,10 @@ function checkStackCookie() {
|
|
|
2527
2145
|
var cookie1 = HEAPU32[((max)>>2)];
|
|
2528
2146
|
var cookie2 = HEAPU32[(((max)+(4))>>2)];
|
|
2529
2147
|
if (cookie1 != 0x2135467 || cookie2 != 0x89BACDFE) {
|
|
2530
|
-
abort('Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x' + cookie2.toString(16) + ' 0x' + cookie1.toString(16));
|
|
2148
|
+
abort('Stack overflow! Stack cookie has been overwritten at 0x' + max.toString(16) + ', expected hex dwords 0x89BACDFE and 0x2135467, but received 0x' + cookie2.toString(16) + ' 0x' + cookie1.toString(16));
|
|
2531
2149
|
}
|
|
2532
2150
|
// Also test the global address 0 for integrity.
|
|
2533
|
-
if (
|
|
2151
|
+
if (HEAPU32[0] !== 0x63736d65 /* 'emsc' */) abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
|
|
2534
2152
|
}
|
|
2535
2153
|
|
|
2536
2154
|
// end include: runtime_stack_check.js
|
|
@@ -2542,7 +2160,7 @@ function checkStackCookie() {
|
|
|
2542
2160
|
var h16 = new Int16Array(1);
|
|
2543
2161
|
var h8 = new Int8Array(h16.buffer);
|
|
2544
2162
|
h16[0] = 0x6373;
|
|
2545
|
-
if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -
|
|
2163
|
+
if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
|
|
2546
2164
|
})();
|
|
2547
2165
|
|
|
2548
2166
|
// end include: runtime_assertions.js
|
|
@@ -2570,10 +2188,11 @@ function preRun() {
|
|
|
2570
2188
|
}
|
|
2571
2189
|
|
|
2572
2190
|
function initRuntime() {
|
|
2573
|
-
checkStackCookie();
|
|
2574
2191
|
assert(!runtimeInitialized);
|
|
2575
2192
|
runtimeInitialized = true;
|
|
2576
2193
|
|
|
2194
|
+
checkStackCookie();
|
|
2195
|
+
|
|
2577
2196
|
|
|
2578
2197
|
if (!Module["noFSInit"] && !FS.init.initialized)
|
|
2579
2198
|
FS.init();
|
|
@@ -2710,9 +2329,6 @@ function removeRunDependency(id) {
|
|
|
2710
2329
|
}
|
|
2711
2330
|
}
|
|
2712
2331
|
|
|
2713
|
-
Module["preloadedImages"] = {}; // maps url to image data
|
|
2714
|
-
Module["preloadedAudios"] = {}; // maps url to audio data
|
|
2715
|
-
|
|
2716
2332
|
/** @param {string|number=} what */
|
|
2717
2333
|
function abort(what) {
|
|
2718
2334
|
{
|
|
@@ -2732,12 +2348,16 @@ function abort(what) {
|
|
|
2732
2348
|
// Use a wasm runtime error, because a JS error might be seen as a foreign
|
|
2733
2349
|
// exception, which means we'd run destructors on it. We need the error to
|
|
2734
2350
|
// simply make the program stop.
|
|
2351
|
+
// FIXME This approach does not work in Wasm EH because it currently does not assume
|
|
2352
|
+
// all RuntimeErrors are from traps; it decides whether a RuntimeError is from
|
|
2353
|
+
// a trap or not based on a hidden field within the object. So at the moment
|
|
2354
|
+
// we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
|
|
2355
|
+
// allows this in the wasm spec.
|
|
2735
2356
|
|
|
2736
2357
|
// Suppress closure compiler warning here. Closure compiler's builtin extern
|
|
2737
2358
|
// defintion for WebAssembly.RuntimeError claims it takes no arguments even
|
|
2738
2359
|
// though it can.
|
|
2739
2360
|
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
|
|
2740
|
-
|
|
2741
2361
|
/** @suppress {checkTypes} */
|
|
2742
2362
|
var e = new WebAssembly.RuntimeError(what);
|
|
2743
2363
|
|
|
@@ -2800,9 +2420,8 @@ function getBinary(file) {
|
|
|
2800
2420
|
}
|
|
2801
2421
|
if (readBinary) {
|
|
2802
2422
|
return readBinary(file);
|
|
2803
|
-
} else {
|
|
2804
|
-
throw "both async and sync fetching of the wasm failed";
|
|
2805
2423
|
}
|
|
2424
|
+
throw "both async and sync fetching of the wasm failed";
|
|
2806
2425
|
}
|
|
2807
2426
|
catch (err) {
|
|
2808
2427
|
abort(err);
|
|
@@ -2915,6 +2534,13 @@ function createWasm() {
|
|
|
2915
2534
|
!isDataURI(wasmBinaryFile) &&
|
|
2916
2535
|
// Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
|
|
2917
2536
|
!isFileURI(wasmBinaryFile) &&
|
|
2537
|
+
// Avoid instantiateStreaming() on Node.js environment for now, as while
|
|
2538
|
+
// Node.js v18.1.0 implements it, it does not have a full fetch()
|
|
2539
|
+
// implementation yet.
|
|
2540
|
+
//
|
|
2541
|
+
// Reference:
|
|
2542
|
+
// https://github.com/emscripten-core/emscripten/pull/16917
|
|
2543
|
+
!ENVIRONMENT_IS_NODE &&
|
|
2918
2544
|
typeof fetch == 'function') {
|
|
2919
2545
|
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
|
|
2920
2546
|
// Suppress closure warning here since the upstream definition for
|
|
@@ -2972,28 +2598,17 @@ var ASM_CONSTS = {
|
|
|
2972
2598
|
|
|
2973
2599
|
|
|
2974
2600
|
|
|
2601
|
+
/** @constructor */
|
|
2602
|
+
function ExitStatus(status) {
|
|
2603
|
+
this.name = 'ExitStatus';
|
|
2604
|
+
this.message = 'Program terminated with exit(' + status + ')';
|
|
2605
|
+
this.status = status;
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2975
2608
|
function callRuntimeCallbacks(callbacks) {
|
|
2976
2609
|
while (callbacks.length > 0) {
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
callback(Module); // Pass the module as the first argument.
|
|
2980
|
-
continue;
|
|
2981
|
-
}
|
|
2982
|
-
var func = callback.func;
|
|
2983
|
-
if (typeof func == 'number') {
|
|
2984
|
-
if (callback.arg === undefined) {
|
|
2985
|
-
// Run the wasm function ptr with signature 'v'. If no function
|
|
2986
|
-
// with such signature was exported, this call does not need
|
|
2987
|
-
// to be emitted (and would confuse Closure)
|
|
2988
|
-
getWasmTableEntry(func)();
|
|
2989
|
-
} else {
|
|
2990
|
-
// If any function with signature 'vi' was exported, run
|
|
2991
|
-
// the callback with that signature.
|
|
2992
|
-
getWasmTableEntry(func)(callback.arg);
|
|
2993
|
-
}
|
|
2994
|
-
} else {
|
|
2995
|
-
func(callback.arg === undefined ? null : callback.arg);
|
|
2996
|
-
}
|
|
2610
|
+
// Pass the module as the first argument.
|
|
2611
|
+
callbacks.shift()(Module);
|
|
2997
2612
|
}
|
|
2998
2613
|
}
|
|
2999
2614
|
|
|
@@ -3004,7 +2619,7 @@ var ASM_CONSTS = {
|
|
|
3004
2619
|
return ret;
|
|
3005
2620
|
}
|
|
3006
2621
|
function demangle(func) {
|
|
3007
|
-
warnOnce('warning: build with
|
|
2622
|
+
warnOnce('warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling');
|
|
3008
2623
|
return func;
|
|
3009
2624
|
}
|
|
3010
2625
|
|
|
@@ -3018,15 +2633,25 @@ var ASM_CONSTS = {
|
|
|
3018
2633
|
});
|
|
3019
2634
|
}
|
|
3020
2635
|
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
2636
|
+
|
|
2637
|
+
/**
|
|
2638
|
+
* @param {number} ptr
|
|
2639
|
+
* @param {string} type
|
|
2640
|
+
*/
|
|
2641
|
+
function getValue(ptr, type = 'i8') {
|
|
2642
|
+
if (type.endsWith('*')) type = '*';
|
|
2643
|
+
switch (type) {
|
|
2644
|
+
case 'i1': return HEAP8[((ptr)>>0)];
|
|
2645
|
+
case 'i8': return HEAP8[((ptr)>>0)];
|
|
2646
|
+
case 'i16': return HEAP16[((ptr)>>1)];
|
|
2647
|
+
case 'i32': return HEAP32[((ptr)>>2)];
|
|
2648
|
+
case 'i64': return HEAP32[((ptr)>>2)];
|
|
2649
|
+
case 'float': return HEAPF32[((ptr)>>2)];
|
|
2650
|
+
case 'double': return HEAPF64[((ptr)>>3)];
|
|
2651
|
+
case '*': return HEAPU32[((ptr)>>2)];
|
|
2652
|
+
default: abort('invalid type for getValue: ' + type);
|
|
3027
2653
|
}
|
|
3028
|
-
|
|
3029
|
-
return func;
|
|
2654
|
+
return null;
|
|
3030
2655
|
}
|
|
3031
2656
|
|
|
3032
2657
|
function handleException(e) {
|
|
@@ -3044,8 +2669,8 @@ var ASM_CONSTS = {
|
|
|
3044
2669
|
function jsStackTrace() {
|
|
3045
2670
|
var error = new Error();
|
|
3046
2671
|
if (!error.stack) {
|
|
3047
|
-
// IE10+ special cases: It does have callstack info, but it is only
|
|
3048
|
-
// so try that as a special-case.
|
|
2672
|
+
// IE10+ special cases: It does have callstack info, but it is only
|
|
2673
|
+
// populated if an Error object is thrown, so try that as a special-case.
|
|
3049
2674
|
try {
|
|
3050
2675
|
throw new Error();
|
|
3051
2676
|
} catch(e) {
|
|
@@ -3058,9 +2683,25 @@ var ASM_CONSTS = {
|
|
|
3058
2683
|
return error.stack.toString();
|
|
3059
2684
|
}
|
|
3060
2685
|
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
2686
|
+
|
|
2687
|
+
/**
|
|
2688
|
+
* @param {number} ptr
|
|
2689
|
+
* @param {number} value
|
|
2690
|
+
* @param {string} type
|
|
2691
|
+
*/
|
|
2692
|
+
function setValue(ptr, value, type = 'i8') {
|
|
2693
|
+
if (type.endsWith('*')) type = '*';
|
|
2694
|
+
switch (type) {
|
|
2695
|
+
case 'i1': HEAP8[((ptr)>>0)] = value; break;
|
|
2696
|
+
case 'i8': HEAP8[((ptr)>>0)] = value; break;
|
|
2697
|
+
case 'i16': HEAP16[((ptr)>>1)] = value; break;
|
|
2698
|
+
case 'i32': HEAP32[((ptr)>>2)] = value; break;
|
|
2699
|
+
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;
|
|
2700
|
+
case 'float': HEAPF32[((ptr)>>2)] = value; break;
|
|
2701
|
+
case 'double': HEAPF64[((ptr)>>3)] = value; break;
|
|
2702
|
+
case '*': HEAPU32[((ptr)>>2)] = value; break;
|
|
2703
|
+
default: abort('invalid type for setValue: ' + type);
|
|
2704
|
+
}
|
|
3064
2705
|
}
|
|
3065
2706
|
|
|
3066
2707
|
function stackTrace() {
|
|
@@ -3069,14 +2710,28 @@ var ASM_CONSTS = {
|
|
|
3069
2710
|
return demangleAll(js);
|
|
3070
2711
|
}
|
|
3071
2712
|
|
|
2713
|
+
function warnOnce(text) {
|
|
2714
|
+
if (!warnOnce.shown) warnOnce.shown = {};
|
|
2715
|
+
if (!warnOnce.shown[text]) {
|
|
2716
|
+
warnOnce.shown[text] = 1;
|
|
2717
|
+
if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
|
|
2718
|
+
err(text);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
function writeArrayToMemory(array, buffer) {
|
|
2723
|
+
assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
|
|
2724
|
+
HEAP8.set(array, buffer);
|
|
2725
|
+
}
|
|
2726
|
+
|
|
3072
2727
|
function ___assert_fail(condition, filename, line, func) {
|
|
3073
2728
|
abort('Assertion failed: ' + UTF8ToString(condition) + ', at: ' + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
|
3074
2729
|
}
|
|
3075
2730
|
|
|
3076
|
-
var PATH = {splitPath:
|
|
2731
|
+
var PATH = {isAbs:(path) => path.charAt(0) === '/',splitPath:(filename) => {
|
|
3077
2732
|
var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
|
3078
2733
|
return splitPathRe.exec(filename).slice(1);
|
|
3079
|
-
},normalizeArray:
|
|
2734
|
+
},normalizeArray:(parts, allowAboveRoot) => {
|
|
3080
2735
|
// if the path tries to go above the root, `up` ends up > 0
|
|
3081
2736
|
var up = 0;
|
|
3082
2737
|
for (var i = parts.length - 1; i >= 0; i--) {
|
|
@@ -3098,13 +2753,11 @@ var ASM_CONSTS = {
|
|
|
3098
2753
|
}
|
|
3099
2754
|
}
|
|
3100
2755
|
return parts;
|
|
3101
|
-
},normalize:
|
|
3102
|
-
var isAbsolute =
|
|
2756
|
+
},normalize:(path) => {
|
|
2757
|
+
var isAbsolute = PATH.isAbs(path),
|
|
3103
2758
|
trailingSlash = path.substr(-1) === '/';
|
|
3104
2759
|
// Normalize the path
|
|
3105
|
-
path = PATH.normalizeArray(path.split('/').filter(
|
|
3106
|
-
return !!p;
|
|
3107
|
-
}), !isAbsolute).join('/');
|
|
2760
|
+
path = PATH.normalizeArray(path.split('/').filter((p) => !!p), !isAbsolute).join('/');
|
|
3108
2761
|
if (!path && !isAbsolute) {
|
|
3109
2762
|
path = '.';
|
|
3110
2763
|
}
|
|
@@ -3112,7 +2765,7 @@ var ASM_CONSTS = {
|
|
|
3112
2765
|
path += '/';
|
|
3113
2766
|
}
|
|
3114
2767
|
return (isAbsolute ? '/' : '') + path;
|
|
3115
|
-
},dirname:
|
|
2768
|
+
},dirname:(path) => {
|
|
3116
2769
|
var result = PATH.splitPath(path),
|
|
3117
2770
|
root = result[0],
|
|
3118
2771
|
dir = result[1];
|
|
@@ -3125,7 +2778,7 @@ var ASM_CONSTS = {
|
|
|
3125
2778
|
dir = dir.substr(0, dir.length - 1);
|
|
3126
2779
|
}
|
|
3127
2780
|
return root + dir;
|
|
3128
|
-
},basename:
|
|
2781
|
+
},basename:(path) => {
|
|
3129
2782
|
// EMSCRIPTEN return '/'' for '/', not an empty string
|
|
3130
2783
|
if (path === '/') return '/';
|
|
3131
2784
|
path = PATH.normalize(path);
|
|
@@ -3133,12 +2786,10 @@ var ASM_CONSTS = {
|
|
|
3133
2786
|
var lastSlash = path.lastIndexOf('/');
|
|
3134
2787
|
if (lastSlash === -1) return path;
|
|
3135
2788
|
return path.substr(lastSlash+1);
|
|
3136
|
-
},extname:function(path) {
|
|
3137
|
-
return PATH.splitPath(path)[3];
|
|
3138
2789
|
},join:function() {
|
|
3139
|
-
var paths = Array.prototype.slice.call(arguments
|
|
2790
|
+
var paths = Array.prototype.slice.call(arguments);
|
|
3140
2791
|
return PATH.normalize(paths.join('/'));
|
|
3141
|
-
},join2:
|
|
2792
|
+
},join2:(l, r) => {
|
|
3142
2793
|
return PATH.normalize(l + '/' + r);
|
|
3143
2794
|
}};
|
|
3144
2795
|
|
|
@@ -3146,20 +2797,20 @@ var ASM_CONSTS = {
|
|
|
3146
2797
|
if (typeof crypto == 'object' && typeof crypto['getRandomValues'] == 'function') {
|
|
3147
2798
|
// for modern web browsers
|
|
3148
2799
|
var randomBuffer = new Uint8Array(1);
|
|
3149
|
-
return
|
|
2800
|
+
return () => { crypto.getRandomValues(randomBuffer); return randomBuffer[0]; };
|
|
3150
2801
|
} else
|
|
3151
2802
|
if (ENVIRONMENT_IS_NODE) {
|
|
3152
2803
|
// for nodejs with or without crypto support included
|
|
3153
2804
|
try {
|
|
3154
2805
|
var crypto_module = require('crypto');
|
|
3155
2806
|
// nodejs has crypto support
|
|
3156
|
-
return
|
|
2807
|
+
return () => crypto_module['randomBytes'](1)[0];
|
|
3157
2808
|
} catch (e) {
|
|
3158
2809
|
// nodejs doesn't have crypto support
|
|
3159
2810
|
}
|
|
3160
2811
|
}
|
|
3161
2812
|
// we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096
|
|
3162
|
-
return
|
|
2813
|
+
return () => abort("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: function(array) { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };");
|
|
3163
2814
|
}
|
|
3164
2815
|
|
|
3165
2816
|
var PATH_FS = {resolve:function() {
|
|
@@ -3174,15 +2825,13 @@ var ASM_CONSTS = {
|
|
|
3174
2825
|
return ''; // an invalid portion invalidates the whole thing
|
|
3175
2826
|
}
|
|
3176
2827
|
resolvedPath = path + '/' + resolvedPath;
|
|
3177
|
-
resolvedAbsolute =
|
|
2828
|
+
resolvedAbsolute = PATH.isAbs(path);
|
|
3178
2829
|
}
|
|
3179
2830
|
// At this point the path should be resolved to a full absolute path, but
|
|
3180
2831
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
3181
|
-
resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(
|
|
3182
|
-
return !!p;
|
|
3183
|
-
}), !resolvedAbsolute).join('/');
|
|
2832
|
+
resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter((p) => !!p), !resolvedAbsolute).join('/');
|
|
3184
2833
|
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
|
3185
|
-
},relative:
|
|
2834
|
+
},relative:(from, to) => {
|
|
3186
2835
|
from = PATH_FS.resolve(from).substr(1);
|
|
3187
2836
|
to = PATH_FS.resolve(to).substr(1);
|
|
3188
2837
|
function trim(arr) {
|
|
@@ -3215,6 +2864,14 @@ var ASM_CONSTS = {
|
|
|
3215
2864
|
return outputParts.join('/');
|
|
3216
2865
|
}};
|
|
3217
2866
|
|
|
2867
|
+
/** @type {function(string, boolean=, number=)} */
|
|
2868
|
+
function intArrayFromString(stringy, dontAddNull, length) {
|
|
2869
|
+
var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
|
|
2870
|
+
var u8array = new Array(len);
|
|
2871
|
+
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
|
2872
|
+
if (dontAddNull) u8array.length = numBytesWritten;
|
|
2873
|
+
return u8array;
|
|
2874
|
+
}
|
|
3218
2875
|
var TTY = {ttys:[],init:function () {
|
|
3219
2876
|
// https://github.com/emscripten-core/emscripten/pull/1555
|
|
3220
2877
|
// if (ENVIRONMENT_IS_NODE) {
|
|
@@ -3246,9 +2903,9 @@ var ASM_CONSTS = {
|
|
|
3246
2903
|
stream.seekable = false;
|
|
3247
2904
|
},close:function(stream) {
|
|
3248
2905
|
// flush any pending line data
|
|
3249
|
-
stream.tty.ops.
|
|
3250
|
-
},
|
|
3251
|
-
stream.tty.ops.
|
|
2906
|
+
stream.tty.ops.fsync(stream.tty);
|
|
2907
|
+
},fsync:function(stream) {
|
|
2908
|
+
stream.tty.ops.fsync(stream.tty);
|
|
3252
2909
|
},read:function(stream, buffer, offset, length, pos /* ignored */) {
|
|
3253
2910
|
if (!stream.tty || !stream.tty.ops.get_char) {
|
|
3254
2911
|
throw new FS.ErrnoError(60);
|
|
@@ -3338,7 +2995,7 @@ var ASM_CONSTS = {
|
|
|
3338
2995
|
} else {
|
|
3339
2996
|
if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle.
|
|
3340
2997
|
}
|
|
3341
|
-
},
|
|
2998
|
+
},fsync:function(tty) {
|
|
3342
2999
|
if (tty.output && tty.output.length > 0) {
|
|
3343
3000
|
out(UTF8ArrayToString(tty.output, 0));
|
|
3344
3001
|
tty.output = [];
|
|
@@ -3350,7 +3007,7 @@ var ASM_CONSTS = {
|
|
|
3350
3007
|
} else {
|
|
3351
3008
|
if (val != 0) tty.output.push(val);
|
|
3352
3009
|
}
|
|
3353
|
-
},
|
|
3010
|
+
},fsync:function(tty) {
|
|
3354
3011
|
if (tty.output && tty.output.length > 0) {
|
|
3355
3012
|
err(UTF8ArrayToString(tty.output, 0));
|
|
3356
3013
|
tty.output = [];
|
|
@@ -3359,6 +3016,7 @@ var ASM_CONSTS = {
|
|
|
3359
3016
|
|
|
3360
3017
|
function zeroMemory(address, size) {
|
|
3361
3018
|
HEAPU8.fill(0, address, address + size);
|
|
3019
|
+
return address;
|
|
3362
3020
|
}
|
|
3363
3021
|
|
|
3364
3022
|
function alignMemory(size, alignment) {
|
|
@@ -3369,8 +3027,7 @@ var ASM_CONSTS = {
|
|
|
3369
3027
|
size = alignMemory(size, 65536);
|
|
3370
3028
|
var ptr = _emscripten_builtin_memalign(65536, size);
|
|
3371
3029
|
if (!ptr) return 0;
|
|
3372
|
-
zeroMemory(ptr, size);
|
|
3373
|
-
return ptr;
|
|
3030
|
+
return zeroMemory(ptr, size);
|
|
3374
3031
|
}
|
|
3375
3032
|
var MEMFS = {ops_table:null,mount:function(mount) {
|
|
3376
3033
|
return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
|
|
@@ -3644,11 +3301,7 @@ var ASM_CONSTS = {
|
|
|
3644
3301
|
},allocate:function(stream, offset, length) {
|
|
3645
3302
|
MEMFS.expandFileStorage(stream.node, offset + length);
|
|
3646
3303
|
stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
|
|
3647
|
-
},mmap:function(stream,
|
|
3648
|
-
if (address !== 0) {
|
|
3649
|
-
// We don't currently support location hints for the address of the mapping
|
|
3650
|
-
throw new FS.ErrnoError(28);
|
|
3651
|
-
}
|
|
3304
|
+
},mmap:function(stream, length, position, prot, flags) {
|
|
3652
3305
|
if (!FS.isFile(stream.node.mode)) {
|
|
3653
3306
|
throw new FS.ErrnoError(43);
|
|
3654
3307
|
}
|
|
@@ -3695,11 +3348,11 @@ var ASM_CONSTS = {
|
|
|
3695
3348
|
/** @param {boolean=} noRunDep */
|
|
3696
3349
|
function asyncLoad(url, onload, onerror, noRunDep) {
|
|
3697
3350
|
var dep = !noRunDep ? getUniqueRunDependency('al ' + url) : '';
|
|
3698
|
-
readAsync(url,
|
|
3351
|
+
readAsync(url, (arrayBuffer) => {
|
|
3699
3352
|
assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
|
|
3700
3353
|
onload(new Uint8Array(arrayBuffer));
|
|
3701
3354
|
if (dep) removeRunDependency(dep);
|
|
3702
|
-
},
|
|
3355
|
+
}, (event) => {
|
|
3703
3356
|
if (onerror) {
|
|
3704
3357
|
onerror();
|
|
3705
3358
|
} else {
|
|
@@ -3930,22 +3583,42 @@ var ASM_CONSTS = {
|
|
|
3930
3583
|
throw new FS.ErrnoError(33);
|
|
3931
3584
|
},getStream:(fd) => FS.streams[fd],createStream:(stream, fd_start, fd_end) => {
|
|
3932
3585
|
if (!FS.FSStream) {
|
|
3933
|
-
FS.FSStream = /** @constructor */ function(){
|
|
3934
|
-
|
|
3586
|
+
FS.FSStream = /** @constructor */ function() {
|
|
3587
|
+
this.shared = { };
|
|
3588
|
+
};
|
|
3589
|
+
FS.FSStream.prototype = {};
|
|
3590
|
+
Object.defineProperties(FS.FSStream.prototype, {
|
|
3935
3591
|
object: {
|
|
3592
|
+
/** @this {FS.FSStream} */
|
|
3936
3593
|
get: function() { return this.node; },
|
|
3594
|
+
/** @this {FS.FSStream} */
|
|
3937
3595
|
set: function(val) { this.node = val; }
|
|
3938
3596
|
},
|
|
3939
3597
|
isRead: {
|
|
3598
|
+
/** @this {FS.FSStream} */
|
|
3940
3599
|
get: function() { return (this.flags & 2097155) !== 1; }
|
|
3941
3600
|
},
|
|
3942
3601
|
isWrite: {
|
|
3602
|
+
/** @this {FS.FSStream} */
|
|
3943
3603
|
get: function() { return (this.flags & 2097155) !== 0; }
|
|
3944
3604
|
},
|
|
3945
3605
|
isAppend: {
|
|
3606
|
+
/** @this {FS.FSStream} */
|
|
3946
3607
|
get: function() { return (this.flags & 1024); }
|
|
3947
|
-
}
|
|
3948
|
-
|
|
3608
|
+
},
|
|
3609
|
+
flags: {
|
|
3610
|
+
/** @this {FS.FSStream} */
|
|
3611
|
+
get: function() { return this.shared.flags; },
|
|
3612
|
+
/** @this {FS.FSStream} */
|
|
3613
|
+
set: function(val) { this.shared.flags = val; },
|
|
3614
|
+
},
|
|
3615
|
+
position : {
|
|
3616
|
+
/** @this {FS.FSStream} */
|
|
3617
|
+
get: function() { return this.shared.position; },
|
|
3618
|
+
/** @this {FS.FSStream} */
|
|
3619
|
+
set: function(val) { this.shared.position = val; },
|
|
3620
|
+
},
|
|
3621
|
+
});
|
|
3949
3622
|
}
|
|
3950
3623
|
// clone it, so we can return an instance of FSStream
|
|
3951
3624
|
stream = Object.assign(new FS.FSStream(), stream);
|
|
@@ -4409,7 +4082,7 @@ var ASM_CONSTS = {
|
|
|
4409
4082
|
node.node_ops.setattr(node, {
|
|
4410
4083
|
timestamp: Math.max(atime, mtime)
|
|
4411
4084
|
});
|
|
4412
|
-
},open:(path, flags, mode
|
|
4085
|
+
},open:(path, flags, mode) => {
|
|
4413
4086
|
if (path === "") {
|
|
4414
4087
|
throw new FS.ErrnoError(44);
|
|
4415
4088
|
}
|
|
@@ -4469,7 +4142,7 @@ var ASM_CONSTS = {
|
|
|
4469
4142
|
}
|
|
4470
4143
|
}
|
|
4471
4144
|
// do truncation if necessary
|
|
4472
|
-
if ((flags & 512)) {
|
|
4145
|
+
if ((flags & 512) && !created) {
|
|
4473
4146
|
FS.truncate(node, 0);
|
|
4474
4147
|
}
|
|
4475
4148
|
// we've already handled these, don't pass down to the underlying vfs
|
|
@@ -4486,7 +4159,7 @@ var ASM_CONSTS = {
|
|
|
4486
4159
|
// used by the file family libc calls (fopen, fwrite, ferror, etc.)
|
|
4487
4160
|
ungotten: [],
|
|
4488
4161
|
error: false
|
|
4489
|
-
}
|
|
4162
|
+
});
|
|
4490
4163
|
// call the new stream's open function
|
|
4491
4164
|
if (stream.stream_ops.open) {
|
|
4492
4165
|
stream.stream_ops.open(stream);
|
|
@@ -4599,7 +4272,7 @@ var ASM_CONSTS = {
|
|
|
4599
4272
|
throw new FS.ErrnoError(138);
|
|
4600
4273
|
}
|
|
4601
4274
|
stream.stream_ops.allocate(stream, offset, length);
|
|
4602
|
-
},mmap:(stream,
|
|
4275
|
+
},mmap:(stream, length, position, prot, flags) => {
|
|
4603
4276
|
// User requests writing to file (prot & PROT_WRITE != 0).
|
|
4604
4277
|
// Checking if we have permissions to write to the file unless
|
|
4605
4278
|
// MAP_PRIVATE flag is set. According to POSIX spec it is possible
|
|
@@ -4617,7 +4290,7 @@ var ASM_CONSTS = {
|
|
|
4617
4290
|
if (!stream.stream_ops.mmap) {
|
|
4618
4291
|
throw new FS.ErrnoError(43);
|
|
4619
4292
|
}
|
|
4620
|
-
return stream.stream_ops.mmap(stream,
|
|
4293
|
+
return stream.stream_ops.mmap(stream, length, position, prot, flags);
|
|
4621
4294
|
},msync:(stream, buffer, offset, length, mmapFlags) => {
|
|
4622
4295
|
if (!stream || !stream.stream_ops.msync) {
|
|
4623
4296
|
return 0;
|
|
@@ -4818,9 +4491,8 @@ var ASM_CONSTS = {
|
|
|
4818
4491
|
FS.createStandardStreams();
|
|
4819
4492
|
},quit:() => {
|
|
4820
4493
|
FS.init.initialized = false;
|
|
4821
|
-
//
|
|
4822
|
-
|
|
4823
|
-
___stdio_exit();
|
|
4494
|
+
// force-flush all streams, so we get musl std streams printed out
|
|
4495
|
+
_fflush(0);
|
|
4824
4496
|
// close all of our streams
|
|
4825
4497
|
for (var i = 0; i < FS.streams.length; i++) {
|
|
4826
4498
|
var stream = FS.streams[i];
|
|
@@ -4836,11 +4508,10 @@ var ASM_CONSTS = {
|
|
|
4836
4508
|
return mode;
|
|
4837
4509
|
},findObject:(path, dontResolveLastLink) => {
|
|
4838
4510
|
var ret = FS.analyzePath(path, dontResolveLastLink);
|
|
4839
|
-
if (ret.exists) {
|
|
4840
|
-
return ret.object;
|
|
4841
|
-
} else {
|
|
4511
|
+
if (!ret.exists) {
|
|
4842
4512
|
return null;
|
|
4843
4513
|
}
|
|
4514
|
+
return ret.object;
|
|
4844
4515
|
},analyzePath:(path, dontResolveLastLink) => {
|
|
4845
4516
|
// operate from within the context of the symlink's target
|
|
4846
4517
|
try {
|
|
@@ -5032,9 +4703,8 @@ var ASM_CONSTS = {
|
|
|
5032
4703
|
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
|
|
5033
4704
|
if (xhr.response !== undefined) {
|
|
5034
4705
|
return new Uint8Array(/** @type{Array<number>} */(xhr.response || []));
|
|
5035
|
-
} else {
|
|
5036
|
-
return intArrayFromString(xhr.responseText || '', true);
|
|
5037
4706
|
}
|
|
4707
|
+
return intArrayFromString(xhr.responseText || '', true);
|
|
5038
4708
|
};
|
|
5039
4709
|
var lazyArray = this;
|
|
5040
4710
|
lazyArray.setDataGetter((chunkNum) => {
|
|
@@ -5113,9 +4783,7 @@ var ASM_CONSTS = {
|
|
|
5113
4783
|
return fn.apply(null, arguments);
|
|
5114
4784
|
};
|
|
5115
4785
|
});
|
|
5116
|
-
|
|
5117
|
-
stream_ops.read = (stream, buffer, offset, length, position) => {
|
|
5118
|
-
FS.forceLoadFile(node);
|
|
4786
|
+
function writeChunks(stream, buffer, offset, length, position) {
|
|
5119
4787
|
var contents = stream.node.contents;
|
|
5120
4788
|
if (position >= contents.length)
|
|
5121
4789
|
return 0;
|
|
@@ -5131,6 +4799,21 @@ var ASM_CONSTS = {
|
|
|
5131
4799
|
}
|
|
5132
4800
|
}
|
|
5133
4801
|
return size;
|
|
4802
|
+
}
|
|
4803
|
+
// use a custom read function
|
|
4804
|
+
stream_ops.read = (stream, buffer, offset, length, position) => {
|
|
4805
|
+
FS.forceLoadFile(node);
|
|
4806
|
+
return writeChunks(stream, buffer, offset, length, position)
|
|
4807
|
+
};
|
|
4808
|
+
// use a custom mmap function
|
|
4809
|
+
stream_ops.mmap = (stream, length, position, prot, flags) => {
|
|
4810
|
+
FS.forceLoadFile(node);
|
|
4811
|
+
var ptr = mmapAlloc(length);
|
|
4812
|
+
if (!ptr) {
|
|
4813
|
+
throw new FS.ErrnoError(48);
|
|
4814
|
+
}
|
|
4815
|
+
writeChunks(stream, HEAP8, ptr, length, position);
|
|
4816
|
+
return { ptr: ptr, allocated: true };
|
|
5134
4817
|
};
|
|
5135
4818
|
node.stream_ops = stream_ops;
|
|
5136
4819
|
return node;
|
|
@@ -5248,7 +4931,7 @@ var ASM_CONSTS = {
|
|
|
5248
4931
|
abort('FS.standardizePath has been removed; use PATH.normalize instead');
|
|
5249
4932
|
}};
|
|
5250
4933
|
var SYSCALLS = {DEFAULT_POLLMASK:5,calculateAt:function(dirfd, path, allowEmpty) {
|
|
5251
|
-
if (path
|
|
4934
|
+
if (PATH.isAbs(path)) {
|
|
5252
4935
|
return path;
|
|
5253
4936
|
}
|
|
5254
4937
|
// relative path
|
|
@@ -5256,8 +4939,7 @@ var ASM_CONSTS = {
|
|
|
5256
4939
|
if (dirfd === -100) {
|
|
5257
4940
|
dir = FS.cwd();
|
|
5258
4941
|
} else {
|
|
5259
|
-
var dirstream =
|
|
5260
|
-
if (!dirstream) throw new FS.ErrnoError(8);
|
|
4942
|
+
var dirstream = SYSCALLS.getStreamFromFD(dirfd);
|
|
5261
4943
|
dir = dirstream.path;
|
|
5262
4944
|
}
|
|
5263
4945
|
if (path.length == 0) {
|
|
@@ -5278,99 +4960,26 @@ var ASM_CONSTS = {
|
|
|
5278
4960
|
throw e;
|
|
5279
4961
|
}
|
|
5280
4962
|
HEAP32[((buf)>>2)] = stat.dev;
|
|
5281
|
-
HEAP32[(((buf)+(4))>>2)] = 0;
|
|
5282
4963
|
HEAP32[(((buf)+(8))>>2)] = stat.ino;
|
|
5283
4964
|
HEAP32[(((buf)+(12))>>2)] = stat.mode;
|
|
5284
|
-
|
|
4965
|
+
HEAPU32[(((buf)+(16))>>2)] = stat.nlink;
|
|
5285
4966
|
HEAP32[(((buf)+(20))>>2)] = stat.uid;
|
|
5286
4967
|
HEAP32[(((buf)+(24))>>2)] = stat.gid;
|
|
5287
4968
|
HEAP32[(((buf)+(28))>>2)] = stat.rdev;
|
|
5288
|
-
HEAP32[(((buf)+(32))>>2)] = 0;
|
|
5289
4969
|
(tempI64 = [stat.size>>>0,(tempDouble=stat.size,(+(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[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);
|
|
5290
4970
|
HEAP32[(((buf)+(48))>>2)] = 4096;
|
|
5291
4971
|
HEAP32[(((buf)+(52))>>2)] = stat.blocks;
|
|
5292
|
-
HEAP32[(((buf)+(56))>>2)] = (
|
|
5293
|
-
|
|
5294
|
-
HEAP32[(((buf)+(
|
|
5295
|
-
|
|
5296
|
-
HEAP32[(((buf)+(
|
|
5297
|
-
|
|
5298
|
-
(tempI64 = [stat.ino>>>0,(tempDouble=stat.ino,(+(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[(((buf)+(
|
|
4972
|
+
(tempI64 = [Math.floor(stat.atime.getTime() / 1000)>>>0,(tempDouble=Math.floor(stat.atime.getTime() / 1000),(+(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[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);
|
|
4973
|
+
HEAPU32[(((buf)+(64))>>2)] = 0;
|
|
4974
|
+
(tempI64 = [Math.floor(stat.mtime.getTime() / 1000)>>>0,(tempDouble=Math.floor(stat.mtime.getTime() / 1000),(+(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[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);
|
|
4975
|
+
HEAPU32[(((buf)+(80))>>2)] = 0;
|
|
4976
|
+
(tempI64 = [Math.floor(stat.ctime.getTime() / 1000)>>>0,(tempDouble=Math.floor(stat.ctime.getTime() / 1000),(+(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[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);
|
|
4977
|
+
HEAPU32[(((buf)+(96))>>2)] = 0;
|
|
4978
|
+
(tempI64 = [stat.ino>>>0,(tempDouble=stat.ino,(+(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[(((buf)+(104))>>2)] = tempI64[0],HEAP32[(((buf)+(108))>>2)] = tempI64[1]);
|
|
5299
4979
|
return 0;
|
|
5300
4980
|
},doMsync:function(addr, stream, len, flags, offset) {
|
|
5301
4981
|
var buffer = HEAPU8.slice(addr, addr + len);
|
|
5302
4982
|
FS.msync(stream, buffer, offset, len, flags);
|
|
5303
|
-
},doMkdir:function(path, mode) {
|
|
5304
|
-
// remove a trailing slash, if one - /a/b/ has basename of '', but
|
|
5305
|
-
// we want to create b in the context of this function
|
|
5306
|
-
path = PATH.normalize(path);
|
|
5307
|
-
if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
|
|
5308
|
-
FS.mkdir(path, mode, 0);
|
|
5309
|
-
return 0;
|
|
5310
|
-
},doMknod:function(path, mode, dev) {
|
|
5311
|
-
// we don't want this in the JS API as it uses mknod to create all nodes.
|
|
5312
|
-
switch (mode & 61440) {
|
|
5313
|
-
case 32768:
|
|
5314
|
-
case 8192:
|
|
5315
|
-
case 24576:
|
|
5316
|
-
case 4096:
|
|
5317
|
-
case 49152:
|
|
5318
|
-
break;
|
|
5319
|
-
default: return -28;
|
|
5320
|
-
}
|
|
5321
|
-
FS.mknod(path, mode, dev);
|
|
5322
|
-
return 0;
|
|
5323
|
-
},doReadlink:function(path, buf, bufsize) {
|
|
5324
|
-
if (bufsize <= 0) return -28;
|
|
5325
|
-
var ret = FS.readlink(path);
|
|
5326
|
-
|
|
5327
|
-
var len = Math.min(bufsize, lengthBytesUTF8(ret));
|
|
5328
|
-
var endChar = HEAP8[buf+len];
|
|
5329
|
-
stringToUTF8(ret, buf, bufsize+1);
|
|
5330
|
-
// readlink is one of the rare functions that write out a C string, but does never append a null to the output buffer(!)
|
|
5331
|
-
// stringToUTF8() always appends a null byte, so restore the character under the null byte after the write.
|
|
5332
|
-
HEAP8[buf+len] = endChar;
|
|
5333
|
-
|
|
5334
|
-
return len;
|
|
5335
|
-
},doAccess:function(path, amode) {
|
|
5336
|
-
if (amode & ~7) {
|
|
5337
|
-
// need a valid mode
|
|
5338
|
-
return -28;
|
|
5339
|
-
}
|
|
5340
|
-
var lookup = FS.lookupPath(path, { follow: true });
|
|
5341
|
-
var node = lookup.node;
|
|
5342
|
-
if (!node) {
|
|
5343
|
-
return -44;
|
|
5344
|
-
}
|
|
5345
|
-
var perms = '';
|
|
5346
|
-
if (amode & 4) perms += 'r';
|
|
5347
|
-
if (amode & 2) perms += 'w';
|
|
5348
|
-
if (amode & 1) perms += 'x';
|
|
5349
|
-
if (perms /* otherwise, they've just passed F_OK */ && FS.nodePermissions(node, perms)) {
|
|
5350
|
-
return -2;
|
|
5351
|
-
}
|
|
5352
|
-
return 0;
|
|
5353
|
-
},doReadv:function(stream, iov, iovcnt, offset) {
|
|
5354
|
-
var ret = 0;
|
|
5355
|
-
for (var i = 0; i < iovcnt; i++) {
|
|
5356
|
-
var ptr = HEAP32[(((iov)+(i*8))>>2)];
|
|
5357
|
-
var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
|
|
5358
|
-
var curr = FS.read(stream, HEAP8,ptr, len, offset);
|
|
5359
|
-
if (curr < 0) return -1;
|
|
5360
|
-
ret += curr;
|
|
5361
|
-
if (curr < len) break; // nothing more to read
|
|
5362
|
-
}
|
|
5363
|
-
return ret;
|
|
5364
|
-
},doWritev:function(stream, iov, iovcnt, offset) {
|
|
5365
|
-
var ret = 0;
|
|
5366
|
-
for (var i = 0; i < iovcnt; i++) {
|
|
5367
|
-
var ptr = HEAP32[(((iov)+(i*8))>>2)];
|
|
5368
|
-
var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
|
|
5369
|
-
var curr = FS.write(stream, HEAP8,ptr, len, offset);
|
|
5370
|
-
if (curr < 0) return -1;
|
|
5371
|
-
ret += curr;
|
|
5372
|
-
}
|
|
5373
|
-
return ret;
|
|
5374
4983
|
},varargs:undefined,get:function() {
|
|
5375
4984
|
assert(SYSCALLS.varargs != undefined);
|
|
5376
4985
|
SYSCALLS.varargs += 4;
|
|
@@ -5383,10 +4992,6 @@ var ASM_CONSTS = {
|
|
|
5383
4992
|
var stream = FS.getStream(fd);
|
|
5384
4993
|
if (!stream) throw new FS.ErrnoError(8);
|
|
5385
4994
|
return stream;
|
|
5386
|
-
},get64:function(low, high) {
|
|
5387
|
-
if (low >= 0) assert(high === 0);
|
|
5388
|
-
else assert(high === -1);
|
|
5389
|
-
return low;
|
|
5390
4995
|
}};
|
|
5391
4996
|
function ___syscall_chmod(path, mode) {
|
|
5392
4997
|
try {
|
|
@@ -5406,7 +5011,23 @@ var ASM_CONSTS = {
|
|
|
5406
5011
|
path = SYSCALLS.getStr(path);
|
|
5407
5012
|
assert(flags === 0);
|
|
5408
5013
|
path = SYSCALLS.calculateAt(dirfd, path);
|
|
5409
|
-
|
|
5014
|
+
if (amode & ~7) {
|
|
5015
|
+
// need a valid mode
|
|
5016
|
+
return -28;
|
|
5017
|
+
}
|
|
5018
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
5019
|
+
var node = lookup.node;
|
|
5020
|
+
if (!node) {
|
|
5021
|
+
return -44;
|
|
5022
|
+
}
|
|
5023
|
+
var perms = '';
|
|
5024
|
+
if (amode & 4) perms += 'r';
|
|
5025
|
+
if (amode & 2) perms += 'w';
|
|
5026
|
+
if (amode & 1) perms += 'x';
|
|
5027
|
+
if (perms /* otherwise, they've just passed F_OK */ && FS.nodePermissions(node, perms)) {
|
|
5028
|
+
return -2;
|
|
5029
|
+
}
|
|
5030
|
+
return 0;
|
|
5410
5031
|
} catch (e) {
|
|
5411
5032
|
if (typeof FS == 'undefined' || !(e instanceof FS.ErrnoError)) throw e;
|
|
5412
5033
|
return -e.errno;
|
|
@@ -5451,7 +5072,7 @@ var ASM_CONSTS = {
|
|
|
5451
5072
|
return -28;
|
|
5452
5073
|
}
|
|
5453
5074
|
var newStream;
|
|
5454
|
-
newStream = FS.
|
|
5075
|
+
newStream = FS.createStream(stream, arg);
|
|
5455
5076
|
return newStream.fd;
|
|
5456
5077
|
}
|
|
5457
5078
|
case 1:
|
|
@@ -5484,7 +5105,7 @@ var ASM_CONSTS = {
|
|
|
5484
5105
|
case 8:
|
|
5485
5106
|
return -28; // These are for sockets. We don't have them fully implemented yet.
|
|
5486
5107
|
case 9:
|
|
5487
|
-
// musl trusts getown return values, due to a bug where they must be, as they overlap with errors. just return -1 here, so
|
|
5108
|
+
// musl trusts getown return values, due to a bug where they must be, as they overlap with errors. just return -1 here, so fcntl() returns that, and we set errno ourselves.
|
|
5488
5109
|
setErrNo(28);
|
|
5489
5110
|
return -1;
|
|
5490
5111
|
default: {
|
|
@@ -5508,10 +5129,15 @@ var ASM_CONSTS = {
|
|
|
5508
5129
|
}
|
|
5509
5130
|
}
|
|
5510
5131
|
|
|
5511
|
-
function
|
|
5132
|
+
function convertI32PairToI53Checked(lo, hi) {
|
|
5133
|
+
assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
|
|
5134
|
+
assert(hi === (hi|0)); // hi should be a i32
|
|
5135
|
+
return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
|
|
5136
|
+
}
|
|
5137
|
+
function ___syscall_ftruncate64(fd, length_low, length_high) {
|
|
5512
5138
|
try {
|
|
5513
5139
|
|
|
5514
|
-
var length =
|
|
5140
|
+
var length = convertI32PairToI53Checked(length_low, length_high); if (isNaN(length)) return -61;
|
|
5515
5141
|
FS.ftruncate(fd, length);
|
|
5516
5142
|
return 0;
|
|
5517
5143
|
} catch (e) {
|
|
@@ -5525,10 +5151,10 @@ var ASM_CONSTS = {
|
|
|
5525
5151
|
|
|
5526
5152
|
if (size === 0) return -28;
|
|
5527
5153
|
var cwd = FS.cwd();
|
|
5528
|
-
var cwdLengthInBytes = lengthBytesUTF8(cwd);
|
|
5529
|
-
if (size < cwdLengthInBytes
|
|
5154
|
+
var cwdLengthInBytes = lengthBytesUTF8(cwd) + 1;
|
|
5155
|
+
if (size < cwdLengthInBytes) return -68;
|
|
5530
5156
|
stringToUTF8(cwd, buf, size);
|
|
5531
|
-
return
|
|
5157
|
+
return cwdLengthInBytes;
|
|
5532
5158
|
} catch (e) {
|
|
5533
5159
|
if (typeof FS == 'undefined' || !(e instanceof FS.ErrnoError)) throw e;
|
|
5534
5160
|
return -e.errno;
|
|
@@ -5546,11 +5172,17 @@ var ASM_CONSTS = {
|
|
|
5546
5172
|
}
|
|
5547
5173
|
}
|
|
5548
5174
|
|
|
5549
|
-
function
|
|
5175
|
+
function ___syscall_mkdirat(dirfd, path, mode) {
|
|
5550
5176
|
try {
|
|
5551
5177
|
|
|
5552
5178
|
path = SYSCALLS.getStr(path);
|
|
5553
|
-
|
|
5179
|
+
path = SYSCALLS.calculateAt(dirfd, path);
|
|
5180
|
+
// remove a trailing slash, if one - /a/b/ has basename of '', but
|
|
5181
|
+
// we want to create b in the context of this function
|
|
5182
|
+
path = PATH.normalize(path);
|
|
5183
|
+
if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
|
|
5184
|
+
FS.mkdir(path, mode, 0);
|
|
5185
|
+
return 0;
|
|
5554
5186
|
} catch (e) {
|
|
5555
5187
|
if (typeof FS == 'undefined' || !(e instanceof FS.ErrnoError)) throw e;
|
|
5556
5188
|
return -e.errno;
|
|
@@ -5592,7 +5224,16 @@ var ASM_CONSTS = {
|
|
|
5592
5224
|
|
|
5593
5225
|
path = SYSCALLS.getStr(path);
|
|
5594
5226
|
path = SYSCALLS.calculateAt(dirfd, path);
|
|
5595
|
-
|
|
5227
|
+
if (bufsize <= 0) return -28;
|
|
5228
|
+
var ret = FS.readlink(path);
|
|
5229
|
+
|
|
5230
|
+
var len = Math.min(bufsize, lengthBytesUTF8(ret));
|
|
5231
|
+
var endChar = HEAP8[buf+len];
|
|
5232
|
+
stringToUTF8(ret, buf, bufsize+1);
|
|
5233
|
+
// readlink is one of the rare functions that write out a C string, but does never append a null to the output buffer(!)
|
|
5234
|
+
// stringToUTF8() always appends a null byte, so restore the character under the null byte after the write.
|
|
5235
|
+
HEAP8[buf+len] = endChar;
|
|
5236
|
+
return len;
|
|
5596
5237
|
} catch (e) {
|
|
5597
5238
|
if (typeof FS == 'undefined' || !(e instanceof FS.ErrnoError)) throw e;
|
|
5598
5239
|
return -e.errno;
|
|
@@ -5641,6 +5282,9 @@ var ASM_CONSTS = {
|
|
|
5641
5282
|
}
|
|
5642
5283
|
}
|
|
5643
5284
|
|
|
5285
|
+
function readI53FromI64(ptr) {
|
|
5286
|
+
return HEAPU32[ptr>>2] + HEAP32[ptr+4>>2] * 4294967296;
|
|
5287
|
+
}
|
|
5644
5288
|
function ___syscall_utimensat(dirfd, path, times, flags) {
|
|
5645
5289
|
try {
|
|
5646
5290
|
|
|
@@ -5651,12 +5295,12 @@ var ASM_CONSTS = {
|
|
|
5651
5295
|
var atime = Date.now();
|
|
5652
5296
|
var mtime = atime;
|
|
5653
5297
|
} else {
|
|
5654
|
-
var seconds =
|
|
5655
|
-
var nanoseconds = HEAP32[(((times)+(
|
|
5298
|
+
var seconds = readI53FromI64(times);
|
|
5299
|
+
var nanoseconds = HEAP32[(((times)+(8))>>2)];
|
|
5656
5300
|
atime = (seconds*1000) + (nanoseconds/(1000*1000));
|
|
5657
|
-
times +=
|
|
5658
|
-
seconds =
|
|
5659
|
-
nanoseconds = HEAP32[(((times)+(
|
|
5301
|
+
times += 16;
|
|
5302
|
+
seconds = readI53FromI64(times);
|
|
5303
|
+
nanoseconds = HEAP32[(((times)+(8))>>2)];
|
|
5660
5304
|
mtime = (seconds*1000) + (nanoseconds/(1000*1000));
|
|
5661
5305
|
}
|
|
5662
5306
|
FS.utime(path, atime, mtime);
|
|
@@ -5677,7 +5321,7 @@ var ASM_CONSTS = {
|
|
|
5677
5321
|
}
|
|
5678
5322
|
|
|
5679
5323
|
function __localtime_js(time, tmPtr) {
|
|
5680
|
-
var date = new Date(
|
|
5324
|
+
var date = new Date(readI53FromI64(time)*1000);
|
|
5681
5325
|
HEAP32[((tmPtr)>>2)] = date.getSeconds();
|
|
5682
5326
|
HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();
|
|
5683
5327
|
HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();
|
|
@@ -5698,12 +5342,11 @@ var ASM_CONSTS = {
|
|
|
5698
5342
|
HEAP32[(((tmPtr)+(32))>>2)] = dst;
|
|
5699
5343
|
}
|
|
5700
5344
|
|
|
5701
|
-
function __mmap_js(
|
|
5345
|
+
function __mmap_js(len, prot, flags, fd, off, allocated) {
|
|
5702
5346
|
try {
|
|
5703
5347
|
|
|
5704
|
-
var
|
|
5705
|
-
|
|
5706
|
-
var res = FS.mmap(info, addr, len, off, prot, flags);
|
|
5348
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
5349
|
+
var res = FS.mmap(stream, len, off, prot, flags);
|
|
5707
5350
|
var ptr = res.ptr;
|
|
5708
5351
|
HEAP32[((allocated)>>2)] = res.allocated;
|
|
5709
5352
|
return ptr;
|
|
@@ -5716,19 +5359,23 @@ var ASM_CONSTS = {
|
|
|
5716
5359
|
function __munmap_js(addr, len, prot, flags, fd, offset) {
|
|
5717
5360
|
try {
|
|
5718
5361
|
|
|
5719
|
-
var stream =
|
|
5720
|
-
if (
|
|
5721
|
-
|
|
5722
|
-
SYSCALLS.doMsync(addr, stream, len, flags, offset);
|
|
5723
|
-
}
|
|
5724
|
-
FS.munmap(stream);
|
|
5362
|
+
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
5363
|
+
if (prot & 2) {
|
|
5364
|
+
SYSCALLS.doMsync(addr, stream, len, flags, offset);
|
|
5725
5365
|
}
|
|
5366
|
+
FS.munmap(stream);
|
|
5726
5367
|
} catch (e) {
|
|
5727
5368
|
if (typeof FS == 'undefined' || !(e instanceof FS.ErrnoError)) throw e;
|
|
5728
5369
|
return -e.errno;
|
|
5729
5370
|
}
|
|
5730
5371
|
}
|
|
5731
5372
|
|
|
5373
|
+
function allocateUTF8(str) {
|
|
5374
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
5375
|
+
var ret = _malloc(size);
|
|
5376
|
+
if (ret) stringToUTF8Array(str, HEAP8, ret, size);
|
|
5377
|
+
return ret;
|
|
5378
|
+
}
|
|
5732
5379
|
function _tzset_impl(timezone, daylight, tzname) {
|
|
5733
5380
|
var currentYear = new Date().getFullYear();
|
|
5734
5381
|
var winter = new Date(currentYear, 0, 1);
|
|
@@ -5760,11 +5407,11 @@ var ASM_CONSTS = {
|
|
|
5760
5407
|
var summerNamePtr = allocateUTF8(summerName);
|
|
5761
5408
|
if (summerOffset < winterOffset) {
|
|
5762
5409
|
// Northern hemisphere
|
|
5763
|
-
|
|
5764
|
-
|
|
5410
|
+
HEAPU32[((tzname)>>2)] = winterNamePtr;
|
|
5411
|
+
HEAPU32[(((tzname)+(4))>>2)] = summerNamePtr;
|
|
5765
5412
|
} else {
|
|
5766
|
-
|
|
5767
|
-
|
|
5413
|
+
HEAPU32[((tzname)>>2)] = summerNamePtr;
|
|
5414
|
+
HEAPU32[(((tzname)+(4))>>2)] = winterNamePtr;
|
|
5768
5415
|
}
|
|
5769
5416
|
}
|
|
5770
5417
|
function __tzset_js(timezone, daylight, tzname) {
|
|
@@ -5774,13 +5421,16 @@ var ASM_CONSTS = {
|
|
|
5774
5421
|
_tzset_impl(timezone, daylight, tzname);
|
|
5775
5422
|
}
|
|
5776
5423
|
|
|
5777
|
-
function
|
|
5424
|
+
function getHeapMax() {
|
|
5778
5425
|
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
5779
5426
|
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
|
|
5780
5427
|
// for any code that deals with heap sizes, which would require special
|
|
5781
5428
|
// casing all heap size related code to treat 0 specially.
|
|
5782
5429
|
return 2147483648;
|
|
5783
5430
|
}
|
|
5431
|
+
function _emscripten_get_heap_max() {
|
|
5432
|
+
return getHeapMax();
|
|
5433
|
+
}
|
|
5784
5434
|
|
|
5785
5435
|
var _emscripten_get_now;if (ENVIRONMENT_IS_NODE) {
|
|
5786
5436
|
_emscripten_get_now = () => {
|
|
@@ -5832,7 +5482,7 @@ var ASM_CONSTS = {
|
|
|
5832
5482
|
|
|
5833
5483
|
// A limit is set for how much we can grow. We should not exceed that
|
|
5834
5484
|
// (the wasm binary specifies it, so if we tried, we'd fail anyhow).
|
|
5835
|
-
var maxHeapSize =
|
|
5485
|
+
var maxHeapSize = getHeapMax();
|
|
5836
5486
|
if (requestedSize > maxHeapSize) {
|
|
5837
5487
|
err('Cannot enlarge memory, asked to go up to ' + requestedSize + ' bytes, but the limit is ' + maxHeapSize + ' bytes!');
|
|
5838
5488
|
return false;
|
|
@@ -5895,11 +5545,21 @@ var ASM_CONSTS = {
|
|
|
5895
5545
|
}
|
|
5896
5546
|
return getEnvStrings.strings;
|
|
5897
5547
|
}
|
|
5548
|
+
|
|
5549
|
+
/** @param {boolean=} dontAddNull */
|
|
5550
|
+
function writeAsciiToMemory(str, buffer, dontAddNull) {
|
|
5551
|
+
for (var i = 0; i < str.length; ++i) {
|
|
5552
|
+
assert(str.charCodeAt(i) === (str.charCodeAt(i) & 0xff));
|
|
5553
|
+
HEAP8[((buffer++)>>0)] = str.charCodeAt(i);
|
|
5554
|
+
}
|
|
5555
|
+
// Null-terminate the pointer to the HEAP.
|
|
5556
|
+
if (!dontAddNull) HEAP8[((buffer)>>0)] = 0;
|
|
5557
|
+
}
|
|
5898
5558
|
function _environ_get(__environ, environ_buf) {
|
|
5899
5559
|
var bufSize = 0;
|
|
5900
5560
|
getEnvStrings().forEach(function(string, i) {
|
|
5901
5561
|
var ptr = environ_buf + bufSize;
|
|
5902
|
-
|
|
5562
|
+
HEAPU32[(((__environ)+(i*4))>>2)] = ptr;
|
|
5903
5563
|
writeAsciiToMemory(string, ptr);
|
|
5904
5564
|
bufSize += string.length + 1;
|
|
5905
5565
|
});
|
|
@@ -5908,12 +5568,12 @@ var ASM_CONSTS = {
|
|
|
5908
5568
|
|
|
5909
5569
|
function _environ_sizes_get(penviron_count, penviron_buf_size) {
|
|
5910
5570
|
var strings = getEnvStrings();
|
|
5911
|
-
|
|
5571
|
+
HEAPU32[((penviron_count)>>2)] = strings.length;
|
|
5912
5572
|
var bufSize = 0;
|
|
5913
5573
|
strings.forEach(function(string) {
|
|
5914
5574
|
bufSize += string.length + 1;
|
|
5915
5575
|
});
|
|
5916
|
-
|
|
5576
|
+
HEAPU32[((penviron_buf_size)>>2)] = bufSize;
|
|
5917
5577
|
return 0;
|
|
5918
5578
|
}
|
|
5919
5579
|
|
|
@@ -5950,12 +5610,26 @@ var ASM_CONSTS = {
|
|
|
5950
5610
|
}
|
|
5951
5611
|
}
|
|
5952
5612
|
|
|
5613
|
+
/** @param {number=} offset */
|
|
5614
|
+
function doReadv(stream, iov, iovcnt, offset) {
|
|
5615
|
+
var ret = 0;
|
|
5616
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
5617
|
+
var ptr = HEAPU32[((iov)>>2)];
|
|
5618
|
+
var len = HEAPU32[(((iov)+(4))>>2)];
|
|
5619
|
+
iov += 8;
|
|
5620
|
+
var curr = FS.read(stream, HEAP8,ptr, len, offset);
|
|
5621
|
+
if (curr < 0) return -1;
|
|
5622
|
+
ret += curr;
|
|
5623
|
+
if (curr < len) break; // nothing more to read
|
|
5624
|
+
}
|
|
5625
|
+
return ret;
|
|
5626
|
+
}
|
|
5953
5627
|
function _fd_read(fd, iov, iovcnt, pnum) {
|
|
5954
5628
|
try {
|
|
5955
5629
|
|
|
5956
5630
|
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
5957
|
-
var num =
|
|
5958
|
-
|
|
5631
|
+
var num = doReadv(stream, iov, iovcnt);
|
|
5632
|
+
HEAPU32[((pnum)>>2)] = num;
|
|
5959
5633
|
return 0;
|
|
5960
5634
|
} catch (e) {
|
|
5961
5635
|
if (typeof FS == 'undefined' || !(e instanceof FS.ErrnoError)) throw e;
|
|
@@ -5966,18 +5640,8 @@ var ASM_CONSTS = {
|
|
|
5966
5640
|
function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
|
|
5967
5641
|
try {
|
|
5968
5642
|
|
|
5969
|
-
|
|
5643
|
+
var offset = convertI32PairToI53Checked(offset_low, offset_high); if (isNaN(offset)) return 61;
|
|
5970
5644
|
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
5971
|
-
var HIGH_OFFSET = 0x100000000; // 2^32
|
|
5972
|
-
// use an unsigned operator on low and shift high by 32-bits
|
|
5973
|
-
var offset = offset_high * HIGH_OFFSET + (offset_low >>> 0);
|
|
5974
|
-
|
|
5975
|
-
var DOUBLE_LIMIT = 0x20000000000000; // 2^53
|
|
5976
|
-
// we also check for equality since DOUBLE_LIMIT + 1 == DOUBLE_LIMIT
|
|
5977
|
-
if (offset <= -DOUBLE_LIMIT || offset >= DOUBLE_LIMIT) {
|
|
5978
|
-
return -61;
|
|
5979
|
-
}
|
|
5980
|
-
|
|
5981
5645
|
FS.llseek(stream, offset, whence);
|
|
5982
5646
|
(tempI64 = [stream.position>>>0,(tempDouble=stream.position,(+(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[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);
|
|
5983
5647
|
if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
|
|
@@ -5993,7 +5657,7 @@ var ASM_CONSTS = {
|
|
|
5993
5657
|
|
|
5994
5658
|
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
5995
5659
|
if (stream.stream_ops && stream.stream_ops.fsync) {
|
|
5996
|
-
return
|
|
5660
|
+
return stream.stream_ops.fsync(stream);
|
|
5997
5661
|
}
|
|
5998
5662
|
return 0; // we can't do anything synchronously; the in-memory FS is already synced to
|
|
5999
5663
|
} catch (e) {
|
|
@@ -6002,13 +5666,25 @@ var ASM_CONSTS = {
|
|
|
6002
5666
|
}
|
|
6003
5667
|
}
|
|
6004
5668
|
|
|
5669
|
+
/** @param {number=} offset */
|
|
5670
|
+
function doWritev(stream, iov, iovcnt, offset) {
|
|
5671
|
+
var ret = 0;
|
|
5672
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
5673
|
+
var ptr = HEAPU32[((iov)>>2)];
|
|
5674
|
+
var len = HEAPU32[(((iov)+(4))>>2)];
|
|
5675
|
+
iov += 8;
|
|
5676
|
+
var curr = FS.write(stream, HEAP8,ptr, len, offset);
|
|
5677
|
+
if (curr < 0) return -1;
|
|
5678
|
+
ret += curr;
|
|
5679
|
+
}
|
|
5680
|
+
return ret;
|
|
5681
|
+
}
|
|
6005
5682
|
function _fd_write(fd, iov, iovcnt, pnum) {
|
|
6006
5683
|
try {
|
|
6007
5684
|
|
|
6008
|
-
;
|
|
6009
5685
|
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
6010
|
-
var num =
|
|
6011
|
-
|
|
5686
|
+
var num = doWritev(stream, iov, iovcnt);
|
|
5687
|
+
HEAPU32[((pnum)>>2)] = num;
|
|
6012
5688
|
return 0;
|
|
6013
5689
|
} catch (e) {
|
|
6014
5690
|
if (typeof FS == 'undefined' || !(e instanceof FS.ErrnoError)) throw e;
|
|
@@ -6016,10 +5692,471 @@ var ASM_CONSTS = {
|
|
|
6016
5692
|
}
|
|
6017
5693
|
}
|
|
6018
5694
|
|
|
6019
|
-
function
|
|
6020
|
-
|
|
5695
|
+
function uleb128Encode(n, target) {
|
|
5696
|
+
assert(n < 16384);
|
|
5697
|
+
if (n < 128) {
|
|
5698
|
+
target.push(n);
|
|
5699
|
+
} else {
|
|
5700
|
+
target.push((n % 128) | 128, n >> 7);
|
|
5701
|
+
}
|
|
5702
|
+
}
|
|
5703
|
+
|
|
5704
|
+
function sigToWasmTypes(sig) {
|
|
5705
|
+
var typeNames = {
|
|
5706
|
+
'i': 'i32',
|
|
5707
|
+
'j': 'i64',
|
|
5708
|
+
'f': 'f32',
|
|
5709
|
+
'd': 'f64',
|
|
5710
|
+
'p': 'i32',
|
|
5711
|
+
};
|
|
5712
|
+
var type = {
|
|
5713
|
+
parameters: [],
|
|
5714
|
+
results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
|
|
5715
|
+
};
|
|
5716
|
+
for (var i = 1; i < sig.length; ++i) {
|
|
5717
|
+
assert(sig[i] in typeNames, 'invalid signature char: ' + sig[i]);
|
|
5718
|
+
type.parameters.push(typeNames[sig[i]]);
|
|
5719
|
+
}
|
|
5720
|
+
return type;
|
|
5721
|
+
}
|
|
5722
|
+
function convertJsFunctionToWasm(func, sig) {
|
|
5723
|
+
|
|
5724
|
+
// If the type reflection proposal is available, use the new
|
|
5725
|
+
// "WebAssembly.Function" constructor.
|
|
5726
|
+
// Otherwise, construct a minimal wasm module importing the JS function and
|
|
5727
|
+
// re-exporting it.
|
|
5728
|
+
if (typeof WebAssembly.Function == "function") {
|
|
5729
|
+
return new WebAssembly.Function(sigToWasmTypes(sig), func);
|
|
5730
|
+
}
|
|
5731
|
+
|
|
5732
|
+
// The module is static, with the exception of the type section, which is
|
|
5733
|
+
// generated based on the signature passed in.
|
|
5734
|
+
var typeSectionBody = [
|
|
5735
|
+
0x01, // count: 1
|
|
5736
|
+
0x60, // form: func
|
|
5737
|
+
];
|
|
5738
|
+
var sigRet = sig.slice(0, 1);
|
|
5739
|
+
var sigParam = sig.slice(1);
|
|
5740
|
+
var typeCodes = {
|
|
5741
|
+
'i': 0x7f, // i32
|
|
5742
|
+
'p': 0x7f, // i32
|
|
5743
|
+
'j': 0x7e, // i64
|
|
5744
|
+
'f': 0x7d, // f32
|
|
5745
|
+
'd': 0x7c, // f64
|
|
5746
|
+
};
|
|
5747
|
+
|
|
5748
|
+
// Parameters, length + signatures
|
|
5749
|
+
uleb128Encode(sigParam.length, typeSectionBody);
|
|
5750
|
+
for (var i = 0; i < sigParam.length; ++i) {
|
|
5751
|
+
assert(sigParam[i] in typeCodes, 'invalid signature char: ' + sigParam[i]);
|
|
5752
|
+
typeSectionBody.push(typeCodes[sigParam[i]]);
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5755
|
+
// Return values, length + signatures
|
|
5756
|
+
// With no multi-return in MVP, either 0 (void) or 1 (anything else)
|
|
5757
|
+
if (sigRet == 'v') {
|
|
5758
|
+
typeSectionBody.push(0x00);
|
|
5759
|
+
} else {
|
|
5760
|
+
typeSectionBody.push(0x01, typeCodes[sigRet]);
|
|
5761
|
+
}
|
|
5762
|
+
|
|
5763
|
+
// Rest of the module is static
|
|
5764
|
+
var bytes = [
|
|
5765
|
+
0x00, 0x61, 0x73, 0x6d, // magic ("\0asm")
|
|
5766
|
+
0x01, 0x00, 0x00, 0x00, // version: 1
|
|
5767
|
+
0x01, // Type section code
|
|
5768
|
+
];
|
|
5769
|
+
// Write the overall length of the type section followed by the body
|
|
5770
|
+
uleb128Encode(typeSectionBody.length, bytes);
|
|
5771
|
+
bytes.push.apply(bytes, typeSectionBody);
|
|
5772
|
+
|
|
5773
|
+
// The rest of the module is static
|
|
5774
|
+
bytes.push(
|
|
5775
|
+
0x02, 0x07, // import section
|
|
5776
|
+
// (import "e" "f" (func 0 (type 0)))
|
|
5777
|
+
0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00,
|
|
5778
|
+
0x07, 0x05, // export section
|
|
5779
|
+
// (export "f" (func 0 (type 0)))
|
|
5780
|
+
0x01, 0x01, 0x66, 0x00, 0x00,
|
|
5781
|
+
);
|
|
5782
|
+
|
|
5783
|
+
// We can compile this wasm module synchronously because it is very small.
|
|
5784
|
+
// This accepts an import (at "e.f"), that it reroutes to an export (at "f")
|
|
5785
|
+
var module = new WebAssembly.Module(new Uint8Array(bytes));
|
|
5786
|
+
var instance = new WebAssembly.Instance(module, { 'e': { 'f': func } });
|
|
5787
|
+
var wrappedFunc = instance.exports['f'];
|
|
5788
|
+
return wrappedFunc;
|
|
5789
|
+
}
|
|
5790
|
+
|
|
5791
|
+
var wasmTableMirror = [];
|
|
5792
|
+
function getWasmTableEntry(funcPtr) {
|
|
5793
|
+
var func = wasmTableMirror[funcPtr];
|
|
5794
|
+
if (!func) {
|
|
5795
|
+
if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
|
|
5796
|
+
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
5797
|
+
}
|
|
5798
|
+
assert(wasmTable.get(funcPtr) == func, "JavaScript-side Wasm function table mirror is out of date!");
|
|
5799
|
+
return func;
|
|
5800
|
+
}
|
|
5801
|
+
function updateTableMap(offset, count) {
|
|
5802
|
+
if (functionsInTableMap) {
|
|
5803
|
+
for (var i = offset; i < offset + count; i++) {
|
|
5804
|
+
var item = getWasmTableEntry(i);
|
|
5805
|
+
// Ignore null values.
|
|
5806
|
+
if (item) {
|
|
5807
|
+
functionsInTableMap.set(item, i);
|
|
5808
|
+
}
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
|
|
5813
|
+
var functionsInTableMap = undefined;
|
|
5814
|
+
|
|
5815
|
+
var freeTableIndexes = [];
|
|
5816
|
+
function getEmptyTableSlot() {
|
|
5817
|
+
// Reuse a free index if there is one, otherwise grow.
|
|
5818
|
+
if (freeTableIndexes.length) {
|
|
5819
|
+
return freeTableIndexes.pop();
|
|
5820
|
+
}
|
|
5821
|
+
// Grow the table
|
|
5822
|
+
try {
|
|
5823
|
+
wasmTable.grow(1);
|
|
5824
|
+
} catch (err) {
|
|
5825
|
+
if (!(err instanceof RangeError)) {
|
|
5826
|
+
throw err;
|
|
5827
|
+
}
|
|
5828
|
+
throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
|
|
5829
|
+
}
|
|
5830
|
+
return wasmTable.length - 1;
|
|
5831
|
+
}
|
|
5832
|
+
|
|
5833
|
+
function setWasmTableEntry(idx, func) {
|
|
5834
|
+
wasmTable.set(idx, func);
|
|
5835
|
+
// With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overriden to return wrapped
|
|
5836
|
+
// functions so we need to call it here to retrieve the potential wrapper correctly
|
|
5837
|
+
// instead of just storing 'func' directly into wasmTableMirror
|
|
5838
|
+
wasmTableMirror[idx] = wasmTable.get(idx);
|
|
5839
|
+
}
|
|
5840
|
+
/** @param {string=} sig */
|
|
5841
|
+
function addFunction(func, sig) {
|
|
5842
|
+
assert(typeof func != 'undefined');
|
|
5843
|
+
|
|
5844
|
+
// Check if the function is already in the table, to ensure each function
|
|
5845
|
+
// gets a unique index. First, create the map if this is the first use.
|
|
5846
|
+
if (!functionsInTableMap) {
|
|
5847
|
+
functionsInTableMap = new WeakMap();
|
|
5848
|
+
updateTableMap(0, wasmTable.length);
|
|
5849
|
+
}
|
|
5850
|
+
if (functionsInTableMap.has(func)) {
|
|
5851
|
+
return functionsInTableMap.get(func);
|
|
5852
|
+
}
|
|
5853
|
+
|
|
5854
|
+
// It's not in the table, add it now.
|
|
5855
|
+
|
|
5856
|
+
var ret = getEmptyTableSlot();
|
|
5857
|
+
|
|
5858
|
+
// Set the new value.
|
|
5859
|
+
try {
|
|
5860
|
+
// Attempting to call this with JS function will cause of table.set() to fail
|
|
5861
|
+
setWasmTableEntry(ret, func);
|
|
5862
|
+
} catch (err) {
|
|
5863
|
+
if (!(err instanceof TypeError)) {
|
|
5864
|
+
throw err;
|
|
5865
|
+
}
|
|
5866
|
+
assert(typeof sig != 'undefined', 'Missing signature argument to addFunction: ' + func);
|
|
5867
|
+
var wrapped = convertJsFunctionToWasm(func, sig);
|
|
5868
|
+
setWasmTableEntry(ret, wrapped);
|
|
5869
|
+
}
|
|
5870
|
+
|
|
5871
|
+
functionsInTableMap.set(func, ret);
|
|
5872
|
+
|
|
5873
|
+
return ret;
|
|
5874
|
+
}
|
|
5875
|
+
|
|
5876
|
+
function removeFunction(index) {
|
|
5877
|
+
functionsInTableMap.delete(getWasmTableEntry(index));
|
|
5878
|
+
freeTableIndexes.push(index);
|
|
5879
|
+
}
|
|
5880
|
+
|
|
5881
|
+
var ALLOC_NORMAL = 0;
|
|
5882
|
+
|
|
5883
|
+
var ALLOC_STACK = 1;
|
|
5884
|
+
function allocate(slab, allocator) {
|
|
5885
|
+
var ret;
|
|
5886
|
+
assert(typeof allocator == 'number', 'allocate no longer takes a type argument')
|
|
5887
|
+
assert(typeof slab != 'number', 'allocate no longer takes a number as arg0')
|
|
5888
|
+
|
|
5889
|
+
if (allocator == ALLOC_STACK) {
|
|
5890
|
+
ret = stackAlloc(slab.length);
|
|
5891
|
+
} else {
|
|
5892
|
+
ret = _malloc(slab.length);
|
|
5893
|
+
}
|
|
5894
|
+
|
|
5895
|
+
if (!slab.subarray && !slab.slice) {
|
|
5896
|
+
slab = new Uint8Array(slab);
|
|
5897
|
+
}
|
|
5898
|
+
HEAPU8.set(slab, ret);
|
|
5899
|
+
return ret;
|
|
5900
|
+
}
|
|
5901
|
+
|
|
5902
|
+
|
|
5903
|
+
|
|
5904
|
+
function AsciiToString(ptr) {
|
|
5905
|
+
var str = '';
|
|
5906
|
+
while (1) {
|
|
5907
|
+
var ch = HEAPU8[((ptr++)>>0)];
|
|
5908
|
+
if (!ch) return str;
|
|
5909
|
+
str += String.fromCharCode(ch);
|
|
5910
|
+
}
|
|
5911
|
+
}
|
|
5912
|
+
|
|
5913
|
+
function stringToAscii(str, outPtr) {
|
|
5914
|
+
return writeAsciiToMemory(str, outPtr, false);
|
|
5915
|
+
}
|
|
5916
|
+
|
|
5917
|
+
var UTF16Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf-16le') : undefined;;
|
|
5918
|
+
function UTF16ToString(ptr, maxBytesToRead) {
|
|
5919
|
+
assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
|
|
5920
|
+
var endPtr = ptr;
|
|
5921
|
+
// TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
|
|
5922
|
+
// Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
|
|
5923
|
+
var idx = endPtr >> 1;
|
|
5924
|
+
var maxIdx = idx + maxBytesToRead / 2;
|
|
5925
|
+
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
|
|
5926
|
+
// will always evaluate to true. This saves on code size.
|
|
5927
|
+
while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
|
|
5928
|
+
endPtr = idx << 1;
|
|
5929
|
+
|
|
5930
|
+
if (endPtr - ptr > 32 && UTF16Decoder) {
|
|
5931
|
+
return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
|
|
5932
|
+
} else {
|
|
5933
|
+
var str = '';
|
|
5934
|
+
|
|
5935
|
+
// If maxBytesToRead is not passed explicitly, it will be undefined, and the for-loop's condition
|
|
5936
|
+
// will always evaluate to true. The loop is then terminated on the first null char.
|
|
5937
|
+
for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
|
|
5938
|
+
var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
|
|
5939
|
+
if (codeUnit == 0) break;
|
|
5940
|
+
// fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
|
|
5941
|
+
str += String.fromCharCode(codeUnit);
|
|
5942
|
+
}
|
|
5943
|
+
|
|
5944
|
+
return str;
|
|
5945
|
+
}
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5948
|
+
function stringToUTF16(str, outPtr, maxBytesToWrite) {
|
|
5949
|
+
assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
|
|
5950
|
+
assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
5951
|
+
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
5952
|
+
if (maxBytesToWrite === undefined) {
|
|
5953
|
+
maxBytesToWrite = 0x7FFFFFFF;
|
|
5954
|
+
}
|
|
5955
|
+
if (maxBytesToWrite < 2) return 0;
|
|
5956
|
+
maxBytesToWrite -= 2; // Null terminator.
|
|
5957
|
+
var startPtr = outPtr;
|
|
5958
|
+
var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
|
|
5959
|
+
for (var i = 0; i < numCharsToWrite; ++i) {
|
|
5960
|
+
// charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
|
|
5961
|
+
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
|
|
5962
|
+
HEAP16[((outPtr)>>1)] = codeUnit;
|
|
5963
|
+
outPtr += 2;
|
|
5964
|
+
}
|
|
5965
|
+
// Null-terminate the pointer to the HEAP.
|
|
5966
|
+
HEAP16[((outPtr)>>1)] = 0;
|
|
5967
|
+
return outPtr - startPtr;
|
|
5968
|
+
}
|
|
5969
|
+
|
|
5970
|
+
function lengthBytesUTF16(str) {
|
|
5971
|
+
return str.length*2;
|
|
5972
|
+
}
|
|
5973
|
+
|
|
5974
|
+
function UTF32ToString(ptr, maxBytesToRead) {
|
|
5975
|
+
assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
|
|
5976
|
+
var i = 0;
|
|
5977
|
+
|
|
5978
|
+
var str = '';
|
|
5979
|
+
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
|
|
5980
|
+
// will always evaluate to true. This saves on code size.
|
|
5981
|
+
while (!(i >= maxBytesToRead / 4)) {
|
|
5982
|
+
var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
|
|
5983
|
+
if (utf32 == 0) break;
|
|
5984
|
+
++i;
|
|
5985
|
+
// Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
|
|
5986
|
+
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
5987
|
+
if (utf32 >= 0x10000) {
|
|
5988
|
+
var ch = utf32 - 0x10000;
|
|
5989
|
+
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
|
5990
|
+
} else {
|
|
5991
|
+
str += String.fromCharCode(utf32);
|
|
5992
|
+
}
|
|
5993
|
+
}
|
|
5994
|
+
return str;
|
|
5995
|
+
}
|
|
5996
|
+
|
|
5997
|
+
function stringToUTF32(str, outPtr, maxBytesToWrite) {
|
|
5998
|
+
assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
|
|
5999
|
+
assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
6000
|
+
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
6001
|
+
if (maxBytesToWrite === undefined) {
|
|
6002
|
+
maxBytesToWrite = 0x7FFFFFFF;
|
|
6003
|
+
}
|
|
6004
|
+
if (maxBytesToWrite < 4) return 0;
|
|
6005
|
+
var startPtr = outPtr;
|
|
6006
|
+
var endPtr = startPtr + maxBytesToWrite - 4;
|
|
6007
|
+
for (var i = 0; i < str.length; ++i) {
|
|
6008
|
+
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
|
|
6009
|
+
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
6010
|
+
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
|
|
6011
|
+
if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
|
|
6012
|
+
var trailSurrogate = str.charCodeAt(++i);
|
|
6013
|
+
codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
|
|
6014
|
+
}
|
|
6015
|
+
HEAP32[((outPtr)>>2)] = codeUnit;
|
|
6016
|
+
outPtr += 4;
|
|
6017
|
+
if (outPtr + 4 > endPtr) break;
|
|
6018
|
+
}
|
|
6019
|
+
// Null-terminate the pointer to the HEAP.
|
|
6020
|
+
HEAP32[((outPtr)>>2)] = 0;
|
|
6021
|
+
return outPtr - startPtr;
|
|
6022
|
+
}
|
|
6023
|
+
|
|
6024
|
+
function lengthBytesUTF32(str) {
|
|
6025
|
+
var len = 0;
|
|
6026
|
+
for (var i = 0; i < str.length; ++i) {
|
|
6027
|
+
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
|
|
6028
|
+
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
6029
|
+
var codeUnit = str.charCodeAt(i);
|
|
6030
|
+
if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
|
|
6031
|
+
len += 4;
|
|
6032
|
+
}
|
|
6033
|
+
|
|
6034
|
+
return len;
|
|
6035
|
+
}
|
|
6036
|
+
|
|
6037
|
+
|
|
6038
|
+
function allocateUTF8OnStack(str) {
|
|
6039
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
6040
|
+
var ret = stackAlloc(size);
|
|
6041
|
+
stringToUTF8Array(str, HEAP8, ret, size);
|
|
6042
|
+
return ret;
|
|
6043
|
+
}
|
|
6044
|
+
|
|
6045
|
+
/** @deprecated @param {boolean=} dontAddNull */
|
|
6046
|
+
function writeStringToMemory(string, buffer, dontAddNull) {
|
|
6047
|
+
warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
|
|
6048
|
+
|
|
6049
|
+
var /** @type {number} */ lastChar, /** @type {number} */ end;
|
|
6050
|
+
if (dontAddNull) {
|
|
6051
|
+
// stringToUTF8Array always appends null. If we don't want to do that, remember the
|
|
6052
|
+
// character that existed at the location where the null will be placed, and restore
|
|
6053
|
+
// that after the write (below).
|
|
6054
|
+
end = buffer + lengthBytesUTF8(string);
|
|
6055
|
+
lastChar = HEAP8[end];
|
|
6056
|
+
}
|
|
6057
|
+
stringToUTF8(string, buffer, Infinity);
|
|
6058
|
+
if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character.
|
|
6059
|
+
}
|
|
6060
|
+
|
|
6061
|
+
|
|
6062
|
+
|
|
6063
|
+
|
|
6064
|
+
function intArrayToString(array) {
|
|
6065
|
+
var ret = [];
|
|
6066
|
+
for (var i = 0; i < array.length; i++) {
|
|
6067
|
+
var chr = array[i];
|
|
6068
|
+
if (chr > 0xFF) {
|
|
6069
|
+
if (ASSERTIONS) {
|
|
6070
|
+
assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
|
|
6071
|
+
}
|
|
6072
|
+
chr &= 0xFF;
|
|
6073
|
+
}
|
|
6074
|
+
ret.push(String.fromCharCode(chr));
|
|
6075
|
+
}
|
|
6076
|
+
return ret.join('');
|
|
6077
|
+
}
|
|
6078
|
+
|
|
6079
|
+
|
|
6080
|
+
function getCFunc(ident) {
|
|
6081
|
+
var func = Module['_' + ident]; // closure exported function
|
|
6082
|
+
assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
|
|
6083
|
+
return func;
|
|
6084
|
+
}
|
|
6085
|
+
|
|
6086
|
+
/**
|
|
6087
|
+
* @param {string|null=} returnType
|
|
6088
|
+
* @param {Array=} argTypes
|
|
6089
|
+
* @param {Arguments|Array=} args
|
|
6090
|
+
* @param {Object=} opts
|
|
6091
|
+
*/
|
|
6092
|
+
function ccall(ident, returnType, argTypes, args, opts) {
|
|
6093
|
+
// For fast lookup of conversion functions
|
|
6094
|
+
var toC = {
|
|
6095
|
+
'string': (str) => {
|
|
6096
|
+
var ret = 0;
|
|
6097
|
+
if (str !== null && str !== undefined && str !== 0) { // null string
|
|
6098
|
+
// at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
|
|
6099
|
+
var len = (str.length << 2) + 1;
|
|
6100
|
+
ret = stackAlloc(len);
|
|
6101
|
+
stringToUTF8(str, ret, len);
|
|
6102
|
+
}
|
|
6103
|
+
return ret;
|
|
6104
|
+
},
|
|
6105
|
+
'array': (arr) => {
|
|
6106
|
+
var ret = stackAlloc(arr.length);
|
|
6107
|
+
writeArrayToMemory(arr, ret);
|
|
6108
|
+
return ret;
|
|
6109
|
+
}
|
|
6110
|
+
};
|
|
6111
|
+
|
|
6112
|
+
function convertReturnValue(ret) {
|
|
6113
|
+
if (returnType === 'string') {
|
|
6114
|
+
|
|
6115
|
+
return UTF8ToString(ret);
|
|
6116
|
+
}
|
|
6117
|
+
if (returnType === 'boolean') return Boolean(ret);
|
|
6118
|
+
return ret;
|
|
6119
|
+
}
|
|
6120
|
+
|
|
6121
|
+
var func = getCFunc(ident);
|
|
6122
|
+
var cArgs = [];
|
|
6123
|
+
var stack = 0;
|
|
6124
|
+
assert(returnType !== 'array', 'Return type should not be "array".');
|
|
6125
|
+
if (args) {
|
|
6126
|
+
for (var i = 0; i < args.length; i++) {
|
|
6127
|
+
var converter = toC[argTypes[i]];
|
|
6128
|
+
if (converter) {
|
|
6129
|
+
if (stack === 0) stack = stackSave();
|
|
6130
|
+
cArgs[i] = converter(args[i]);
|
|
6131
|
+
} else {
|
|
6132
|
+
cArgs[i] = args[i];
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
}
|
|
6136
|
+
var ret = func.apply(null, cArgs);
|
|
6137
|
+
function onDone(ret) {
|
|
6138
|
+
if (stack !== 0) stackRestore(stack);
|
|
6139
|
+
return convertReturnValue(ret);
|
|
6140
|
+
}
|
|
6141
|
+
|
|
6142
|
+
ret = onDone(ret);
|
|
6143
|
+
return ret;
|
|
6144
|
+
}
|
|
6145
|
+
|
|
6146
|
+
|
|
6147
|
+
/**
|
|
6148
|
+
* @param {string=} returnType
|
|
6149
|
+
* @param {Array=} argTypes
|
|
6150
|
+
* @param {Object=} opts
|
|
6151
|
+
*/
|
|
6152
|
+
function cwrap(ident, returnType, argTypes, opts) {
|
|
6153
|
+
return function() {
|
|
6154
|
+
return ccall(ident, returnType, argTypes, arguments, opts);
|
|
6155
|
+
}
|
|
6021
6156
|
}
|
|
6022
6157
|
|
|
6158
|
+
|
|
6159
|
+
|
|
6023
6160
|
var FSNode = /** @constructor */ function(parent, name, mode, rdev) {
|
|
6024
6161
|
if (!parent) {
|
|
6025
6162
|
parent = this; // root node sets parent to itself
|
|
@@ -6191,33 +6328,6 @@ ERRNO_CODES = {
|
|
|
6191
6328
|
};;
|
|
6192
6329
|
var ASSERTIONS = true;
|
|
6193
6330
|
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
/** @type {function(string, boolean=, number=)} */
|
|
6197
|
-
function intArrayFromString(stringy, dontAddNull, length) {
|
|
6198
|
-
var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
|
|
6199
|
-
var u8array = new Array(len);
|
|
6200
|
-
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
|
6201
|
-
if (dontAddNull) u8array.length = numBytesWritten;
|
|
6202
|
-
return u8array;
|
|
6203
|
-
}
|
|
6204
|
-
|
|
6205
|
-
function intArrayToString(array) {
|
|
6206
|
-
var ret = [];
|
|
6207
|
-
for (var i = 0; i < array.length; i++) {
|
|
6208
|
-
var chr = array[i];
|
|
6209
|
-
if (chr > 0xFF) {
|
|
6210
|
-
if (ASSERTIONS) {
|
|
6211
|
-
assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
|
|
6212
|
-
}
|
|
6213
|
-
chr &= 0xFF;
|
|
6214
|
-
}
|
|
6215
|
-
ret.push(String.fromCharCode(chr));
|
|
6216
|
-
}
|
|
6217
|
-
return ret.join('');
|
|
6218
|
-
}
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
6331
|
function checkIncomingModuleAPI() {
|
|
6222
6332
|
ignoredModuleProp('fetchSettings');
|
|
6223
6333
|
}
|
|
@@ -6232,7 +6342,7 @@ var asmLibraryArg = {
|
|
|
6232
6342
|
"__syscall_ftruncate64": ___syscall_ftruncate64,
|
|
6233
6343
|
"__syscall_getcwd": ___syscall_getcwd,
|
|
6234
6344
|
"__syscall_lstat64": ___syscall_lstat64,
|
|
6235
|
-
"
|
|
6345
|
+
"__syscall_mkdirat": ___syscall_mkdirat,
|
|
6236
6346
|
"__syscall_newfstatat": ___syscall_newfstatat,
|
|
6237
6347
|
"__syscall_openat": ___syscall_openat,
|
|
6238
6348
|
"__syscall_readlinkat": ___syscall_readlinkat,
|
|
@@ -6257,8 +6367,7 @@ var asmLibraryArg = {
|
|
|
6257
6367
|
"fd_read": _fd_read,
|
|
6258
6368
|
"fd_seek": _fd_seek,
|
|
6259
6369
|
"fd_sync": _fd_sync,
|
|
6260
|
-
"fd_write": _fd_write
|
|
6261
|
-
"setTempRet0": _setTempRet0
|
|
6370
|
+
"fd_write": _fd_write
|
|
6262
6371
|
};
|
|
6263
6372
|
var asm = createWasm();
|
|
6264
6373
|
/** @type {function(...*):?} */
|
|
@@ -6327,6 +6436,9 @@ var _sqlite3_result_text = Module["_sqlite3_result_text"] = createExportWrapper(
|
|
|
6327
6436
|
/** @type {function(...*):?} */
|
|
6328
6437
|
var _sqlite3_sql = Module["_sqlite3_sql"] = createExportWrapper("sqlite3_sql");
|
|
6329
6438
|
|
|
6439
|
+
/** @type {function(...*):?} */
|
|
6440
|
+
var _sqlite3_aggregate_context = Module["_sqlite3_aggregate_context"] = createExportWrapper("sqlite3_aggregate_context");
|
|
6441
|
+
|
|
6330
6442
|
/** @type {function(...*):?} */
|
|
6331
6443
|
var _sqlite3_column_count = Module["_sqlite3_column_count"] = createExportWrapper("sqlite3_column_count");
|
|
6332
6444
|
|
|
@@ -6397,7 +6509,7 @@ var _free = Module["_free"] = createExportWrapper("free");
|
|
|
6397
6509
|
var _RegisterExtensionFunctions = Module["_RegisterExtensionFunctions"] = createExportWrapper("RegisterExtensionFunctions");
|
|
6398
6510
|
|
|
6399
6511
|
/** @type {function(...*):?} */
|
|
6400
|
-
var
|
|
6512
|
+
var _fflush = Module["_fflush"] = createExportWrapper("fflush");
|
|
6401
6513
|
|
|
6402
6514
|
/** @type {function(...*):?} */
|
|
6403
6515
|
var _emscripten_builtin_memalign = Module["_emscripten_builtin_memalign"] = createExportWrapper("emscripten_builtin_memalign");
|
|
@@ -6458,244 +6570,364 @@ var dynCall_jiji = Module["dynCall_jiji"] = createExportWrapper("dynCall_jiji");
|
|
|
6458
6570
|
|
|
6459
6571
|
// === Auto-generated postamble setup entry stuff ===
|
|
6460
6572
|
|
|
6461
|
-
unexportedRuntimeFunction('intArrayFromString', false);
|
|
6462
|
-
unexportedRuntimeFunction('intArrayToString', false);
|
|
6463
|
-
unexportedRuntimeFunction('ccall', false);
|
|
6464
|
-
Module["cwrap"] = cwrap;
|
|
6465
|
-
unexportedRuntimeFunction('setValue', false);
|
|
6466
|
-
unexportedRuntimeFunction('getValue', false);
|
|
6467
|
-
unexportedRuntimeFunction('allocate', false);
|
|
6468
|
-
unexportedRuntimeFunction('UTF8ArrayToString', false);
|
|
6469
6573
|
Module["UTF8ToString"] = UTF8ToString;
|
|
6470
|
-
|
|
6471
|
-
unexportedRuntimeFunction('stringToUTF8', false);
|
|
6472
|
-
unexportedRuntimeFunction('lengthBytesUTF8', false);
|
|
6473
|
-
unexportedRuntimeFunction('stackTrace', false);
|
|
6474
|
-
unexportedRuntimeFunction('addOnPreRun', false);
|
|
6475
|
-
unexportedRuntimeFunction('addOnInit', false);
|
|
6476
|
-
unexportedRuntimeFunction('addOnPreMain', false);
|
|
6477
|
-
unexportedRuntimeFunction('addOnExit', false);
|
|
6478
|
-
unexportedRuntimeFunction('addOnPostRun', false);
|
|
6479
|
-
unexportedRuntimeFunction('writeStringToMemory', false);
|
|
6480
|
-
unexportedRuntimeFunction('writeArrayToMemory', false);
|
|
6481
|
-
unexportedRuntimeFunction('writeAsciiToMemory', false);
|
|
6482
|
-
unexportedRuntimeFunction('addRunDependency', true);
|
|
6483
|
-
unexportedRuntimeFunction('removeRunDependency', true);
|
|
6484
|
-
unexportedRuntimeFunction('FS_createFolder', false);
|
|
6485
|
-
unexportedRuntimeFunction('FS_createPath', true);
|
|
6486
|
-
unexportedRuntimeFunction('FS_createDataFile', true);
|
|
6487
|
-
unexportedRuntimeFunction('FS_createPreloadedFile', true);
|
|
6488
|
-
unexportedRuntimeFunction('FS_createLazyFile', true);
|
|
6489
|
-
unexportedRuntimeFunction('FS_createLink', false);
|
|
6490
|
-
unexportedRuntimeFunction('FS_createDevice', true);
|
|
6491
|
-
unexportedRuntimeFunction('FS_unlink', true);
|
|
6492
|
-
unexportedRuntimeFunction('getLEB', false);
|
|
6493
|
-
unexportedRuntimeFunction('getFunctionTables', false);
|
|
6494
|
-
unexportedRuntimeFunction('alignFunctionTables', false);
|
|
6495
|
-
unexportedRuntimeFunction('registerFunctions', false);
|
|
6496
|
-
unexportedRuntimeFunction('addFunction', false);
|
|
6497
|
-
unexportedRuntimeFunction('removeFunction', false);
|
|
6498
|
-
unexportedRuntimeFunction('getFuncWrapper', false);
|
|
6499
|
-
unexportedRuntimeFunction('prettyPrint', false);
|
|
6500
|
-
unexportedRuntimeFunction('dynCall', false);
|
|
6501
|
-
unexportedRuntimeFunction('getCompilerSetting', false);
|
|
6502
|
-
unexportedRuntimeFunction('print', false);
|
|
6503
|
-
unexportedRuntimeFunction('printErr', false);
|
|
6504
|
-
unexportedRuntimeFunction('getTempRet0', false);
|
|
6505
|
-
unexportedRuntimeFunction('setTempRet0', false);
|
|
6506
|
-
unexportedRuntimeFunction('callMain', false);
|
|
6507
|
-
unexportedRuntimeFunction('abort', false);
|
|
6508
|
-
unexportedRuntimeFunction('keepRuntimeAlive', false);
|
|
6509
|
-
unexportedRuntimeFunction('zeroMemory', false);
|
|
6510
|
-
unexportedRuntimeFunction('stringToNewUTF8', false);
|
|
6511
|
-
unexportedRuntimeFunction('emscripten_realloc_buffer', false);
|
|
6512
|
-
unexportedRuntimeFunction('ENV', false);
|
|
6513
|
-
unexportedRuntimeFunction('ERRNO_CODES', false);
|
|
6514
|
-
unexportedRuntimeFunction('ERRNO_MESSAGES', false);
|
|
6515
|
-
unexportedRuntimeFunction('setErrNo', false);
|
|
6516
|
-
unexportedRuntimeFunction('inetPton4', false);
|
|
6517
|
-
unexportedRuntimeFunction('inetNtop4', false);
|
|
6518
|
-
unexportedRuntimeFunction('inetPton6', false);
|
|
6519
|
-
unexportedRuntimeFunction('inetNtop6', false);
|
|
6520
|
-
unexportedRuntimeFunction('readSockaddr', false);
|
|
6521
|
-
unexportedRuntimeFunction('writeSockaddr', false);
|
|
6522
|
-
unexportedRuntimeFunction('DNS', false);
|
|
6523
|
-
unexportedRuntimeFunction('getHostByName', false);
|
|
6524
|
-
unexportedRuntimeFunction('Protocols', false);
|
|
6525
|
-
unexportedRuntimeFunction('Sockets', false);
|
|
6526
|
-
unexportedRuntimeFunction('getRandomDevice', false);
|
|
6527
|
-
unexportedRuntimeFunction('traverseStack', false);
|
|
6528
|
-
unexportedRuntimeFunction('UNWIND_CACHE', false);
|
|
6529
|
-
unexportedRuntimeFunction('convertPCtoSourceLocation', false);
|
|
6530
|
-
unexportedRuntimeFunction('readAsmConstArgsArray', false);
|
|
6531
|
-
unexportedRuntimeFunction('readAsmConstArgs', false);
|
|
6532
|
-
unexportedRuntimeFunction('mainThreadEM_ASM', false);
|
|
6533
|
-
unexportedRuntimeFunction('jstoi_q', false);
|
|
6534
|
-
unexportedRuntimeFunction('jstoi_s', false);
|
|
6535
|
-
unexportedRuntimeFunction('getExecutableName', false);
|
|
6536
|
-
unexportedRuntimeFunction('listenOnce', false);
|
|
6537
|
-
unexportedRuntimeFunction('autoResumeAudioContext', false);
|
|
6538
|
-
unexportedRuntimeFunction('dynCallLegacy', false);
|
|
6539
|
-
unexportedRuntimeFunction('getDynCaller', false);
|
|
6540
|
-
unexportedRuntimeFunction('dynCall', false);
|
|
6541
|
-
unexportedRuntimeFunction('handleException', false);
|
|
6542
|
-
unexportedRuntimeFunction('runtimeKeepalivePush', false);
|
|
6543
|
-
unexportedRuntimeFunction('runtimeKeepalivePop', false);
|
|
6544
|
-
unexportedRuntimeFunction('callUserCallback', false);
|
|
6545
|
-
unexportedRuntimeFunction('maybeExit', false);
|
|
6546
|
-
unexportedRuntimeFunction('safeSetTimeout', false);
|
|
6547
|
-
unexportedRuntimeFunction('asmjsMangle', false);
|
|
6548
|
-
unexportedRuntimeFunction('asyncLoad', false);
|
|
6549
|
-
unexportedRuntimeFunction('alignMemory', false);
|
|
6550
|
-
unexportedRuntimeFunction('mmapAlloc', false);
|
|
6551
|
-
unexportedRuntimeFunction('reallyNegative', false);
|
|
6552
|
-
unexportedRuntimeFunction('unSign', false);
|
|
6553
|
-
unexportedRuntimeFunction('reSign', false);
|
|
6554
|
-
unexportedRuntimeFunction('formatString', false);
|
|
6555
|
-
unexportedRuntimeFunction('PATH', false);
|
|
6556
|
-
unexportedRuntimeFunction('PATH_FS', false);
|
|
6557
|
-
unexportedRuntimeFunction('SYSCALLS', false);
|
|
6558
|
-
unexportedRuntimeFunction('getSocketFromFD', false);
|
|
6559
|
-
unexportedRuntimeFunction('getSocketAddress', false);
|
|
6560
|
-
unexportedRuntimeFunction('JSEvents', false);
|
|
6561
|
-
unexportedRuntimeFunction('registerKeyEventCallback', false);
|
|
6562
|
-
unexportedRuntimeFunction('specialHTMLTargets', false);
|
|
6563
|
-
unexportedRuntimeFunction('maybeCStringToJsString', false);
|
|
6564
|
-
unexportedRuntimeFunction('findEventTarget', false);
|
|
6565
|
-
unexportedRuntimeFunction('findCanvasEventTarget', false);
|
|
6566
|
-
unexportedRuntimeFunction('getBoundingClientRect', false);
|
|
6567
|
-
unexportedRuntimeFunction('fillMouseEventData', false);
|
|
6568
|
-
unexportedRuntimeFunction('registerMouseEventCallback', false);
|
|
6569
|
-
unexportedRuntimeFunction('registerWheelEventCallback', false);
|
|
6570
|
-
unexportedRuntimeFunction('registerUiEventCallback', false);
|
|
6571
|
-
unexportedRuntimeFunction('registerFocusEventCallback', false);
|
|
6572
|
-
unexportedRuntimeFunction('fillDeviceOrientationEventData', false);
|
|
6573
|
-
unexportedRuntimeFunction('registerDeviceOrientationEventCallback', false);
|
|
6574
|
-
unexportedRuntimeFunction('fillDeviceMotionEventData', false);
|
|
6575
|
-
unexportedRuntimeFunction('registerDeviceMotionEventCallback', false);
|
|
6576
|
-
unexportedRuntimeFunction('screenOrientation', false);
|
|
6577
|
-
unexportedRuntimeFunction('fillOrientationChangeEventData', false);
|
|
6578
|
-
unexportedRuntimeFunction('registerOrientationChangeEventCallback', false);
|
|
6579
|
-
unexportedRuntimeFunction('fillFullscreenChangeEventData', false);
|
|
6580
|
-
unexportedRuntimeFunction('registerFullscreenChangeEventCallback', false);
|
|
6581
|
-
unexportedRuntimeFunction('registerRestoreOldStyle', false);
|
|
6582
|
-
unexportedRuntimeFunction('hideEverythingExceptGivenElement', false);
|
|
6583
|
-
unexportedRuntimeFunction('restoreHiddenElements', false);
|
|
6584
|
-
unexportedRuntimeFunction('setLetterbox', false);
|
|
6585
|
-
unexportedRuntimeFunction('currentFullscreenStrategy', false);
|
|
6586
|
-
unexportedRuntimeFunction('restoreOldWindowedStyle', false);
|
|
6587
|
-
unexportedRuntimeFunction('softFullscreenResizeWebGLRenderTarget', false);
|
|
6588
|
-
unexportedRuntimeFunction('doRequestFullscreen', false);
|
|
6589
|
-
unexportedRuntimeFunction('fillPointerlockChangeEventData', false);
|
|
6590
|
-
unexportedRuntimeFunction('registerPointerlockChangeEventCallback', false);
|
|
6591
|
-
unexportedRuntimeFunction('registerPointerlockErrorEventCallback', false);
|
|
6592
|
-
unexportedRuntimeFunction('requestPointerLock', false);
|
|
6593
|
-
unexportedRuntimeFunction('fillVisibilityChangeEventData', false);
|
|
6594
|
-
unexportedRuntimeFunction('registerVisibilityChangeEventCallback', false);
|
|
6595
|
-
unexportedRuntimeFunction('registerTouchEventCallback', false);
|
|
6596
|
-
unexportedRuntimeFunction('fillGamepadEventData', false);
|
|
6597
|
-
unexportedRuntimeFunction('registerGamepadEventCallback', false);
|
|
6598
|
-
unexportedRuntimeFunction('registerBeforeUnloadEventCallback', false);
|
|
6599
|
-
unexportedRuntimeFunction('fillBatteryEventData', false);
|
|
6600
|
-
unexportedRuntimeFunction('battery', false);
|
|
6601
|
-
unexportedRuntimeFunction('registerBatteryEventCallback', false);
|
|
6602
|
-
unexportedRuntimeFunction('setCanvasElementSize', false);
|
|
6603
|
-
unexportedRuntimeFunction('getCanvasElementSize', false);
|
|
6604
|
-
unexportedRuntimeFunction('demangle', false);
|
|
6605
|
-
unexportedRuntimeFunction('demangleAll', false);
|
|
6606
|
-
unexportedRuntimeFunction('jsStackTrace', false);
|
|
6607
|
-
unexportedRuntimeFunction('stackTrace', false);
|
|
6608
|
-
unexportedRuntimeFunction('getEnvStrings', false);
|
|
6609
|
-
unexportedRuntimeFunction('checkWasiClock', false);
|
|
6610
|
-
unexportedRuntimeFunction('writeI53ToI64', false);
|
|
6611
|
-
unexportedRuntimeFunction('writeI53ToI64Clamped', false);
|
|
6612
|
-
unexportedRuntimeFunction('writeI53ToI64Signaling', false);
|
|
6613
|
-
unexportedRuntimeFunction('writeI53ToU64Clamped', false);
|
|
6614
|
-
unexportedRuntimeFunction('writeI53ToU64Signaling', false);
|
|
6615
|
-
unexportedRuntimeFunction('readI53FromI64', false);
|
|
6616
|
-
unexportedRuntimeFunction('readI53FromU64', false);
|
|
6617
|
-
unexportedRuntimeFunction('convertI32PairToI53', false);
|
|
6618
|
-
unexportedRuntimeFunction('convertU32PairToI53', false);
|
|
6619
|
-
unexportedRuntimeFunction('setImmediateWrapped', false);
|
|
6620
|
-
unexportedRuntimeFunction('clearImmediateWrapped', false);
|
|
6621
|
-
unexportedRuntimeFunction('polyfillSetImmediate', false);
|
|
6622
|
-
unexportedRuntimeFunction('uncaughtExceptionCount', false);
|
|
6623
|
-
unexportedRuntimeFunction('exceptionLast', false);
|
|
6624
|
-
unexportedRuntimeFunction('exceptionCaught', false);
|
|
6625
|
-
unexportedRuntimeFunction('ExceptionInfo', false);
|
|
6626
|
-
unexportedRuntimeFunction('CatchInfo', false);
|
|
6627
|
-
unexportedRuntimeFunction('exception_addRef', false);
|
|
6628
|
-
unexportedRuntimeFunction('exception_decRef', false);
|
|
6629
|
-
unexportedRuntimeFunction('Browser', false);
|
|
6630
|
-
unexportedRuntimeFunction('funcWrappers', false);
|
|
6631
|
-
unexportedRuntimeFunction('getFuncWrapper', false);
|
|
6632
|
-
unexportedRuntimeFunction('setMainLoop', false);
|
|
6633
|
-
unexportedRuntimeFunction('wget', false);
|
|
6634
|
-
unexportedRuntimeFunction('FS', false);
|
|
6635
|
-
unexportedRuntimeFunction('MEMFS', false);
|
|
6636
|
-
unexportedRuntimeFunction('TTY', false);
|
|
6637
|
-
unexportedRuntimeFunction('PIPEFS', false);
|
|
6638
|
-
unexportedRuntimeFunction('SOCKFS', false);
|
|
6639
|
-
unexportedRuntimeFunction('_setNetworkCallback', false);
|
|
6640
|
-
unexportedRuntimeFunction('tempFixedLengthArray', false);
|
|
6641
|
-
unexportedRuntimeFunction('miniTempWebGLFloatBuffers', false);
|
|
6642
|
-
unexportedRuntimeFunction('heapObjectForWebGLType', false);
|
|
6643
|
-
unexportedRuntimeFunction('heapAccessShiftForWebGLHeap', false);
|
|
6644
|
-
unexportedRuntimeFunction('GL', false);
|
|
6645
|
-
unexportedRuntimeFunction('emscriptenWebGLGet', false);
|
|
6646
|
-
unexportedRuntimeFunction('computeUnpackAlignedImageSize', false);
|
|
6647
|
-
unexportedRuntimeFunction('emscriptenWebGLGetTexPixelData', false);
|
|
6648
|
-
unexportedRuntimeFunction('emscriptenWebGLGetUniform', false);
|
|
6649
|
-
unexportedRuntimeFunction('webglGetUniformLocation', false);
|
|
6650
|
-
unexportedRuntimeFunction('webglPrepareUniformLocationsBeforeFirstUse', false);
|
|
6651
|
-
unexportedRuntimeFunction('webglGetLeftBracePos', false);
|
|
6652
|
-
unexportedRuntimeFunction('emscriptenWebGLGetVertexAttrib', false);
|
|
6653
|
-
unexportedRuntimeFunction('writeGLArray', false);
|
|
6654
|
-
unexportedRuntimeFunction('AL', false);
|
|
6655
|
-
unexportedRuntimeFunction('SDL_unicode', false);
|
|
6656
|
-
unexportedRuntimeFunction('SDL_ttfContext', false);
|
|
6657
|
-
unexportedRuntimeFunction('SDL_audio', false);
|
|
6658
|
-
unexportedRuntimeFunction('SDL', false);
|
|
6659
|
-
unexportedRuntimeFunction('SDL_gfx', false);
|
|
6660
|
-
unexportedRuntimeFunction('GLUT', false);
|
|
6661
|
-
unexportedRuntimeFunction('EGL', false);
|
|
6662
|
-
unexportedRuntimeFunction('GLFW_Window', false);
|
|
6663
|
-
unexportedRuntimeFunction('GLFW', false);
|
|
6664
|
-
unexportedRuntimeFunction('GLEW', false);
|
|
6665
|
-
unexportedRuntimeFunction('IDBStore', false);
|
|
6666
|
-
unexportedRuntimeFunction('runAndAbortIfError', false);
|
|
6667
|
-
unexportedRuntimeFunction('warnOnce', false);
|
|
6574
|
+
Module["stackAlloc"] = stackAlloc;
|
|
6668
6575
|
Module["stackSave"] = stackSave;
|
|
6669
6576
|
Module["stackRestore"] = stackRestore;
|
|
6670
|
-
Module["
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6577
|
+
Module["cwrap"] = cwrap;
|
|
6578
|
+
var unexportedRuntimeSymbols = [
|
|
6579
|
+
'run',
|
|
6580
|
+
'UTF8ArrayToString',
|
|
6581
|
+
'stringToUTF8Array',
|
|
6582
|
+
'stringToUTF8',
|
|
6583
|
+
'lengthBytesUTF8',
|
|
6584
|
+
'addOnPreRun',
|
|
6585
|
+
'addOnInit',
|
|
6586
|
+
'addOnPreMain',
|
|
6587
|
+
'addOnExit',
|
|
6588
|
+
'addOnPostRun',
|
|
6589
|
+
'addRunDependency',
|
|
6590
|
+
'removeRunDependency',
|
|
6591
|
+
'FS_createFolder',
|
|
6592
|
+
'FS_createPath',
|
|
6593
|
+
'FS_createDataFile',
|
|
6594
|
+
'FS_createPreloadedFile',
|
|
6595
|
+
'FS_createLazyFile',
|
|
6596
|
+
'FS_createLink',
|
|
6597
|
+
'FS_createDevice',
|
|
6598
|
+
'FS_unlink',
|
|
6599
|
+
'getLEB',
|
|
6600
|
+
'getFunctionTables',
|
|
6601
|
+
'alignFunctionTables',
|
|
6602
|
+
'registerFunctions',
|
|
6603
|
+
'prettyPrint',
|
|
6604
|
+
'getCompilerSetting',
|
|
6605
|
+
'print',
|
|
6606
|
+
'printErr',
|
|
6607
|
+
'callMain',
|
|
6608
|
+
'abort',
|
|
6609
|
+
'keepRuntimeAlive',
|
|
6610
|
+
'wasmMemory',
|
|
6611
|
+
'getTempRet0',
|
|
6612
|
+
'setTempRet0',
|
|
6613
|
+
'writeStackCookie',
|
|
6614
|
+
'checkStackCookie',
|
|
6615
|
+
'ptrToString',
|
|
6616
|
+
'zeroMemory',
|
|
6617
|
+
'stringToNewUTF8',
|
|
6618
|
+
'exitJS',
|
|
6619
|
+
'getHeapMax',
|
|
6620
|
+
'emscripten_realloc_buffer',
|
|
6621
|
+
'ENV',
|
|
6622
|
+
'ERRNO_CODES',
|
|
6623
|
+
'ERRNO_MESSAGES',
|
|
6624
|
+
'setErrNo',
|
|
6625
|
+
'inetPton4',
|
|
6626
|
+
'inetNtop4',
|
|
6627
|
+
'inetPton6',
|
|
6628
|
+
'inetNtop6',
|
|
6629
|
+
'readSockaddr',
|
|
6630
|
+
'writeSockaddr',
|
|
6631
|
+
'DNS',
|
|
6632
|
+
'getHostByName',
|
|
6633
|
+
'Protocols',
|
|
6634
|
+
'Sockets',
|
|
6635
|
+
'getRandomDevice',
|
|
6636
|
+
'warnOnce',
|
|
6637
|
+
'traverseStack',
|
|
6638
|
+
'UNWIND_CACHE',
|
|
6639
|
+
'convertPCtoSourceLocation',
|
|
6640
|
+
'readAsmConstArgsArray',
|
|
6641
|
+
'readAsmConstArgs',
|
|
6642
|
+
'mainThreadEM_ASM',
|
|
6643
|
+
'jstoi_q',
|
|
6644
|
+
'jstoi_s',
|
|
6645
|
+
'getExecutableName',
|
|
6646
|
+
'listenOnce',
|
|
6647
|
+
'autoResumeAudioContext',
|
|
6648
|
+
'dynCallLegacy',
|
|
6649
|
+
'getDynCaller',
|
|
6650
|
+
'dynCall',
|
|
6651
|
+
'handleException',
|
|
6652
|
+
'runtimeKeepalivePush',
|
|
6653
|
+
'runtimeKeepalivePop',
|
|
6654
|
+
'callUserCallback',
|
|
6655
|
+
'maybeExit',
|
|
6656
|
+
'safeSetTimeout',
|
|
6657
|
+
'asmjsMangle',
|
|
6658
|
+
'asyncLoad',
|
|
6659
|
+
'alignMemory',
|
|
6660
|
+
'mmapAlloc',
|
|
6661
|
+
'writeI53ToI64',
|
|
6662
|
+
'writeI53ToI64Clamped',
|
|
6663
|
+
'writeI53ToI64Signaling',
|
|
6664
|
+
'writeI53ToU64Clamped',
|
|
6665
|
+
'writeI53ToU64Signaling',
|
|
6666
|
+
'readI53FromI64',
|
|
6667
|
+
'readI53FromU64',
|
|
6668
|
+
'convertI32PairToI53',
|
|
6669
|
+
'convertI32PairToI53Checked',
|
|
6670
|
+
'convertU32PairToI53',
|
|
6671
|
+
'getCFunc',
|
|
6672
|
+
'ccall',
|
|
6673
|
+
'uleb128Encode',
|
|
6674
|
+
'sigToWasmTypes',
|
|
6675
|
+
'convertJsFunctionToWasm',
|
|
6676
|
+
'freeTableIndexes',
|
|
6677
|
+
'functionsInTableMap',
|
|
6678
|
+
'getEmptyTableSlot',
|
|
6679
|
+
'updateTableMap',
|
|
6680
|
+
'addFunction',
|
|
6681
|
+
'removeFunction',
|
|
6682
|
+
'reallyNegative',
|
|
6683
|
+
'unSign',
|
|
6684
|
+
'strLen',
|
|
6685
|
+
'reSign',
|
|
6686
|
+
'formatString',
|
|
6687
|
+
'setValue',
|
|
6688
|
+
'getValue',
|
|
6689
|
+
'PATH',
|
|
6690
|
+
'PATH_FS',
|
|
6691
|
+
'intArrayFromString',
|
|
6692
|
+
'intArrayToString',
|
|
6693
|
+
'AsciiToString',
|
|
6694
|
+
'stringToAscii',
|
|
6695
|
+
'UTF16Decoder',
|
|
6696
|
+
'UTF16ToString',
|
|
6697
|
+
'stringToUTF16',
|
|
6698
|
+
'lengthBytesUTF16',
|
|
6699
|
+
'UTF32ToString',
|
|
6700
|
+
'stringToUTF32',
|
|
6701
|
+
'lengthBytesUTF32',
|
|
6702
|
+
'allocateUTF8',
|
|
6703
|
+
'allocateUTF8OnStack',
|
|
6704
|
+
'writeStringToMemory',
|
|
6705
|
+
'writeArrayToMemory',
|
|
6706
|
+
'writeAsciiToMemory',
|
|
6707
|
+
'SYSCALLS',
|
|
6708
|
+
'getSocketFromFD',
|
|
6709
|
+
'getSocketAddress',
|
|
6710
|
+
'JSEvents',
|
|
6711
|
+
'registerKeyEventCallback',
|
|
6712
|
+
'specialHTMLTargets',
|
|
6713
|
+
'maybeCStringToJsString',
|
|
6714
|
+
'findEventTarget',
|
|
6715
|
+
'findCanvasEventTarget',
|
|
6716
|
+
'getBoundingClientRect',
|
|
6717
|
+
'fillMouseEventData',
|
|
6718
|
+
'registerMouseEventCallback',
|
|
6719
|
+
'registerWheelEventCallback',
|
|
6720
|
+
'registerUiEventCallback',
|
|
6721
|
+
'registerFocusEventCallback',
|
|
6722
|
+
'fillDeviceOrientationEventData',
|
|
6723
|
+
'registerDeviceOrientationEventCallback',
|
|
6724
|
+
'fillDeviceMotionEventData',
|
|
6725
|
+
'registerDeviceMotionEventCallback',
|
|
6726
|
+
'screenOrientation',
|
|
6727
|
+
'fillOrientationChangeEventData',
|
|
6728
|
+
'registerOrientationChangeEventCallback',
|
|
6729
|
+
'fillFullscreenChangeEventData',
|
|
6730
|
+
'registerFullscreenChangeEventCallback',
|
|
6731
|
+
'JSEvents_requestFullscreen',
|
|
6732
|
+
'JSEvents_resizeCanvasForFullscreen',
|
|
6733
|
+
'registerRestoreOldStyle',
|
|
6734
|
+
'hideEverythingExceptGivenElement',
|
|
6735
|
+
'restoreHiddenElements',
|
|
6736
|
+
'setLetterbox',
|
|
6737
|
+
'currentFullscreenStrategy',
|
|
6738
|
+
'restoreOldWindowedStyle',
|
|
6739
|
+
'softFullscreenResizeWebGLRenderTarget',
|
|
6740
|
+
'doRequestFullscreen',
|
|
6741
|
+
'fillPointerlockChangeEventData',
|
|
6742
|
+
'registerPointerlockChangeEventCallback',
|
|
6743
|
+
'registerPointerlockErrorEventCallback',
|
|
6744
|
+
'requestPointerLock',
|
|
6745
|
+
'fillVisibilityChangeEventData',
|
|
6746
|
+
'registerVisibilityChangeEventCallback',
|
|
6747
|
+
'registerTouchEventCallback',
|
|
6748
|
+
'fillGamepadEventData',
|
|
6749
|
+
'registerGamepadEventCallback',
|
|
6750
|
+
'registerBeforeUnloadEventCallback',
|
|
6751
|
+
'fillBatteryEventData',
|
|
6752
|
+
'battery',
|
|
6753
|
+
'registerBatteryEventCallback',
|
|
6754
|
+
'setCanvasElementSize',
|
|
6755
|
+
'getCanvasElementSize',
|
|
6756
|
+
'demangle',
|
|
6757
|
+
'demangleAll',
|
|
6758
|
+
'jsStackTrace',
|
|
6759
|
+
'stackTrace',
|
|
6760
|
+
'ExitStatus',
|
|
6761
|
+
'getEnvStrings',
|
|
6762
|
+
'checkWasiClock',
|
|
6763
|
+
'doReadv',
|
|
6764
|
+
'doWritev',
|
|
6765
|
+
'dlopenMissingError',
|
|
6766
|
+
'setImmediateWrapped',
|
|
6767
|
+
'clearImmediateWrapped',
|
|
6768
|
+
'polyfillSetImmediate',
|
|
6769
|
+
'uncaughtExceptionCount',
|
|
6770
|
+
'exceptionLast',
|
|
6771
|
+
'exceptionCaught',
|
|
6772
|
+
'ExceptionInfo',
|
|
6773
|
+
'exception_addRef',
|
|
6774
|
+
'exception_decRef',
|
|
6775
|
+
'Browser',
|
|
6776
|
+
'setMainLoop',
|
|
6777
|
+
'wget',
|
|
6778
|
+
'FS',
|
|
6779
|
+
'MEMFS',
|
|
6780
|
+
'TTY',
|
|
6781
|
+
'PIPEFS',
|
|
6782
|
+
'SOCKFS',
|
|
6783
|
+
'_setNetworkCallback',
|
|
6784
|
+
'tempFixedLengthArray',
|
|
6785
|
+
'miniTempWebGLFloatBuffers',
|
|
6786
|
+
'heapObjectForWebGLType',
|
|
6787
|
+
'heapAccessShiftForWebGLHeap',
|
|
6788
|
+
'GL',
|
|
6789
|
+
'emscriptenWebGLGet',
|
|
6790
|
+
'computeUnpackAlignedImageSize',
|
|
6791
|
+
'emscriptenWebGLGetTexPixelData',
|
|
6792
|
+
'emscriptenWebGLGetUniform',
|
|
6793
|
+
'webglGetUniformLocation',
|
|
6794
|
+
'webglPrepareUniformLocationsBeforeFirstUse',
|
|
6795
|
+
'webglGetLeftBracePos',
|
|
6796
|
+
'emscriptenWebGLGetVertexAttrib',
|
|
6797
|
+
'writeGLArray',
|
|
6798
|
+
'AL',
|
|
6799
|
+
'SDL_unicode',
|
|
6800
|
+
'SDL_ttfContext',
|
|
6801
|
+
'SDL_audio',
|
|
6802
|
+
'SDL',
|
|
6803
|
+
'SDL_gfx',
|
|
6804
|
+
'GLUT',
|
|
6805
|
+
'EGL',
|
|
6806
|
+
'GLFW_Window',
|
|
6807
|
+
'GLFW',
|
|
6808
|
+
'GLEW',
|
|
6809
|
+
'IDBStore',
|
|
6810
|
+
'runAndAbortIfError',
|
|
6811
|
+
'ALLOC_NORMAL',
|
|
6812
|
+
'ALLOC_STACK',
|
|
6813
|
+
'allocate',
|
|
6814
|
+
];
|
|
6815
|
+
unexportedRuntimeSymbols.forEach(unexportedRuntimeSymbol);
|
|
6816
|
+
var missingLibrarySymbols = [
|
|
6817
|
+
'ptrToString',
|
|
6818
|
+
'stringToNewUTF8',
|
|
6819
|
+
'exitJS',
|
|
6820
|
+
'inetPton4',
|
|
6821
|
+
'inetNtop4',
|
|
6822
|
+
'inetPton6',
|
|
6823
|
+
'inetNtop6',
|
|
6824
|
+
'readSockaddr',
|
|
6825
|
+
'writeSockaddr',
|
|
6826
|
+
'getHostByName',
|
|
6827
|
+
'traverseStack',
|
|
6828
|
+
'convertPCtoSourceLocation',
|
|
6829
|
+
'readAsmConstArgs',
|
|
6830
|
+
'mainThreadEM_ASM',
|
|
6831
|
+
'jstoi_q',
|
|
6832
|
+
'jstoi_s',
|
|
6833
|
+
'listenOnce',
|
|
6834
|
+
'autoResumeAudioContext',
|
|
6835
|
+
'dynCallLegacy',
|
|
6836
|
+
'getDynCaller',
|
|
6837
|
+
'dynCall',
|
|
6838
|
+
'runtimeKeepalivePush',
|
|
6839
|
+
'runtimeKeepalivePop',
|
|
6840
|
+
'callUserCallback',
|
|
6841
|
+
'maybeExit',
|
|
6842
|
+
'safeSetTimeout',
|
|
6843
|
+
'asmjsMangle',
|
|
6844
|
+
'writeI53ToI64',
|
|
6845
|
+
'writeI53ToI64Clamped',
|
|
6846
|
+
'writeI53ToI64Signaling',
|
|
6847
|
+
'writeI53ToU64Clamped',
|
|
6848
|
+
'writeI53ToU64Signaling',
|
|
6849
|
+
'readI53FromU64',
|
|
6850
|
+
'convertI32PairToI53',
|
|
6851
|
+
'convertU32PairToI53',
|
|
6852
|
+
'reallyNegative',
|
|
6853
|
+
'unSign',
|
|
6854
|
+
'strLen',
|
|
6855
|
+
'reSign',
|
|
6856
|
+
'formatString',
|
|
6857
|
+
'getSocketFromFD',
|
|
6858
|
+
'getSocketAddress',
|
|
6859
|
+
'registerKeyEventCallback',
|
|
6860
|
+
'maybeCStringToJsString',
|
|
6861
|
+
'findEventTarget',
|
|
6862
|
+
'findCanvasEventTarget',
|
|
6863
|
+
'getBoundingClientRect',
|
|
6864
|
+
'fillMouseEventData',
|
|
6865
|
+
'registerMouseEventCallback',
|
|
6866
|
+
'registerWheelEventCallback',
|
|
6867
|
+
'registerUiEventCallback',
|
|
6868
|
+
'registerFocusEventCallback',
|
|
6869
|
+
'fillDeviceOrientationEventData',
|
|
6870
|
+
'registerDeviceOrientationEventCallback',
|
|
6871
|
+
'fillDeviceMotionEventData',
|
|
6872
|
+
'registerDeviceMotionEventCallback',
|
|
6873
|
+
'screenOrientation',
|
|
6874
|
+
'fillOrientationChangeEventData',
|
|
6875
|
+
'registerOrientationChangeEventCallback',
|
|
6876
|
+
'fillFullscreenChangeEventData',
|
|
6877
|
+
'registerFullscreenChangeEventCallback',
|
|
6878
|
+
'JSEvents_requestFullscreen',
|
|
6879
|
+
'JSEvents_resizeCanvasForFullscreen',
|
|
6880
|
+
'registerRestoreOldStyle',
|
|
6881
|
+
'hideEverythingExceptGivenElement',
|
|
6882
|
+
'restoreHiddenElements',
|
|
6883
|
+
'setLetterbox',
|
|
6884
|
+
'softFullscreenResizeWebGLRenderTarget',
|
|
6885
|
+
'doRequestFullscreen',
|
|
6886
|
+
'fillPointerlockChangeEventData',
|
|
6887
|
+
'registerPointerlockChangeEventCallback',
|
|
6888
|
+
'registerPointerlockErrorEventCallback',
|
|
6889
|
+
'requestPointerLock',
|
|
6890
|
+
'fillVisibilityChangeEventData',
|
|
6891
|
+
'registerVisibilityChangeEventCallback',
|
|
6892
|
+
'registerTouchEventCallback',
|
|
6893
|
+
'fillGamepadEventData',
|
|
6894
|
+
'registerGamepadEventCallback',
|
|
6895
|
+
'registerBeforeUnloadEventCallback',
|
|
6896
|
+
'fillBatteryEventData',
|
|
6897
|
+
'battery',
|
|
6898
|
+
'registerBatteryEventCallback',
|
|
6899
|
+
'setCanvasElementSize',
|
|
6900
|
+
'getCanvasElementSize',
|
|
6901
|
+
'checkWasiClock',
|
|
6902
|
+
'setImmediateWrapped',
|
|
6903
|
+
'clearImmediateWrapped',
|
|
6904
|
+
'polyfillSetImmediate',
|
|
6905
|
+
'ExceptionInfo',
|
|
6906
|
+
'exception_addRef',
|
|
6907
|
+
'exception_decRef',
|
|
6908
|
+
'setMainLoop',
|
|
6909
|
+
'_setNetworkCallback',
|
|
6910
|
+
'heapObjectForWebGLType',
|
|
6911
|
+
'heapAccessShiftForWebGLHeap',
|
|
6912
|
+
'emscriptenWebGLGet',
|
|
6913
|
+
'computeUnpackAlignedImageSize',
|
|
6914
|
+
'emscriptenWebGLGetTexPixelData',
|
|
6915
|
+
'emscriptenWebGLGetUniform',
|
|
6916
|
+
'webglGetUniformLocation',
|
|
6917
|
+
'webglPrepareUniformLocationsBeforeFirstUse',
|
|
6918
|
+
'webglGetLeftBracePos',
|
|
6919
|
+
'emscriptenWebGLGetVertexAttrib',
|
|
6920
|
+
'writeGLArray',
|
|
6921
|
+
'SDL_unicode',
|
|
6922
|
+
'SDL_ttfContext',
|
|
6923
|
+
'SDL_audio',
|
|
6924
|
+
'GLFW_Window',
|
|
6925
|
+
'runAndAbortIfError',
|
|
6926
|
+
];
|
|
6927
|
+
missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
6687
6928
|
|
|
6688
|
-
/**
|
|
6689
|
-
* @constructor
|
|
6690
|
-
* @this {ExitStatus}
|
|
6691
|
-
*/
|
|
6692
|
-
function ExitStatus(status) {
|
|
6693
|
-
this.name = "ExitStatus";
|
|
6694
|
-
this.message = "Program terminated with exit(" + status + ")";
|
|
6695
|
-
this.status = status;
|
|
6696
|
-
}
|
|
6697
6929
|
|
|
6698
|
-
var
|
|
6930
|
+
var calledRun;
|
|
6699
6931
|
|
|
6700
6932
|
dependenciesFulfilled = function runCaller() {
|
|
6701
6933
|
// If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
|
|
@@ -6707,8 +6939,8 @@ function stackCheckInit() {
|
|
|
6707
6939
|
// This is normally called automatically during __wasm_call_ctors but need to
|
|
6708
6940
|
// get these values before even running any of the ctors so we call it redundantly
|
|
6709
6941
|
// here.
|
|
6710
|
-
// TODO(sbc): Move writeStackCookie to native to to avoid this.
|
|
6711
6942
|
_emscripten_stack_init();
|
|
6943
|
+
// TODO(sbc): Move writeStackCookie to native to to avoid this.
|
|
6712
6944
|
writeStackCookie();
|
|
6713
6945
|
}
|
|
6714
6946
|
|
|
@@ -6720,7 +6952,7 @@ function run(args) {
|
|
|
6720
6952
|
return;
|
|
6721
6953
|
}
|
|
6722
6954
|
|
|
6723
|
-
|
|
6955
|
+
stackCheckInit();
|
|
6724
6956
|
|
|
6725
6957
|
preRun();
|
|
6726
6958
|
|
|
@@ -6761,7 +6993,6 @@ function run(args) {
|
|
|
6761
6993
|
}
|
|
6762
6994
|
checkStackCookie();
|
|
6763
6995
|
}
|
|
6764
|
-
Module['run'] = run;
|
|
6765
6996
|
|
|
6766
6997
|
function checkUnflushedContent() {
|
|
6767
6998
|
// Compiler settings do not allow exiting the runtime, so flushing
|
|
@@ -6782,7 +7013,7 @@ function checkUnflushedContent() {
|
|
|
6782
7013
|
has = true;
|
|
6783
7014
|
}
|
|
6784
7015
|
try { // it doesn't matter if it fails
|
|
6785
|
-
|
|
7016
|
+
_fflush(0);
|
|
6786
7017
|
// also flush in the JS FS layer
|
|
6787
7018
|
['stdout', 'stderr'].forEach(function(name) {
|
|
6788
7019
|
var info = FS.analyzePath('/dev/' + name);
|
|
@@ -6802,30 +7033,6 @@ function checkUnflushedContent() {
|
|
|
6802
7033
|
}
|
|
6803
7034
|
}
|
|
6804
7035
|
|
|
6805
|
-
/** @param {boolean|number=} implicit */
|
|
6806
|
-
function exit(status, implicit) {
|
|
6807
|
-
EXITSTATUS = status;
|
|
6808
|
-
|
|
6809
|
-
checkUnflushedContent();
|
|
6810
|
-
|
|
6811
|
-
// if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
|
|
6812
|
-
if (keepRuntimeAlive() && !implicit) {
|
|
6813
|
-
var msg = 'program exited (with status: ' + status + '), 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)';
|
|
6814
|
-
err(msg);
|
|
6815
|
-
}
|
|
6816
|
-
|
|
6817
|
-
procExit(status);
|
|
6818
|
-
}
|
|
6819
|
-
|
|
6820
|
-
function procExit(code) {
|
|
6821
|
-
EXITSTATUS = code;
|
|
6822
|
-
if (!keepRuntimeAlive()) {
|
|
6823
|
-
if (Module['onExit']) Module['onExit'](code);
|
|
6824
|
-
ABORT = true;
|
|
6825
|
-
}
|
|
6826
|
-
quit_(code, new ExitStatus(code));
|
|
6827
|
-
}
|
|
6828
|
-
|
|
6829
7036
|
if (Module['preInit']) {
|
|
6830
7037
|
if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
|
|
6831
7038
|
while (Module['preInit'].length > 0) {
|