forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseTools_legacy.mjs
50 lines (43 loc) · 1.33 KB
/
parseTools_legacy.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @license
* Copyright 2010 The Emscripten Authors
* SPDX-License-Identifier: MIT
*/
import {warn, addToCompileTimeContext} from './utility.mjs';
import {POINTER_SIZE, runIfMainThread} from './parseTools.mjs';
// Replaced (at least internally) with receiveI64ParamAsI53 that does
// bounds checking.
function receiveI64ParamAsDouble(name) {
warn('use of legacy parseTools function: receiveI64ParamAsDouble');
if (WASM_BIGINT) {
// Just convert the bigint into a double.
return `${name} = Number(${name});`;
}
// Combine the i32 params. Use an unsigned operator on low and shift high by
// 32 bits.
return `var ${name} = ${name}_high * 0x100000000 + (${name}_low >>> 0);`;
}
function receiveI64ParamAsI32s(name) {
warn('use of legacy parseTools function: receiveI64ParamAsI32s');
if (WASM_BIGINT) {
return `var ${name}_low = Number(${name} & 0xffffffffn) | 0, ${name}_high = Number(${name} >> 32n) | 0;`;
}
return '';
}
function makeMalloc(source, param) {
warn('use of legacy parseTools function: makeMalloc');
return `_malloc(${param})`;
}
const Runtime = {
POINTER_SIZE,
QUANTUM_SIZE: POINTER_SIZE,
};
// Legacy name for runIfMainThread.
const runOnMainThread = runIfMainThread;
addToCompileTimeContext({
Runtime,
makeMalloc,
receiveI64ParamAsDouble,
receiveI64ParamAsI32s,
runOnMainThread,
});