Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/src/parseTools_legacy.mjs
4128 views
1
/**
2
* @license
3
* Copyright 2010 The Emscripten Authors
4
* SPDX-License-Identifier: MIT
5
*/
6
7
import {warn, addToCompileTimeContext} from './utility.mjs';
8
import {POINTER_SIZE, runIfMainThread} from './parseTools.mjs';
9
10
// Replaced (at least internally) with receiveI64ParamAsI53 that does
11
// bounds checking.
12
function receiveI64ParamAsDouble(name) {
13
warn('use of legacy parseTools function: receiveI64ParamAsDouble');
14
if (WASM_BIGINT) {
15
// Just convert the bigint into a double.
16
return `${name} = Number(${name});`;
17
}
18
// Combine the i32 params. Use an unsigned operator on low and shift high by
19
// 32 bits.
20
return `var ${name} = ${name}_high * 0x100000000 + (${name}_low >>> 0);`;
21
}
22
23
function receiveI64ParamAsI32s(name) {
24
warn('use of legacy parseTools function: receiveI64ParamAsI32s');
25
if (WASM_BIGINT) {
26
return `var ${name}_low = Number(${name} & 0xffffffffn) | 0, ${name}_high = Number(${name} >> 32n) | 0;`;
27
}
28
return '';
29
}
30
31
function makeMalloc(source, param) {
32
warn('use of legacy parseTools function: makeMalloc');
33
return `_malloc(${param})`;
34
}
35
36
const Runtime = {
37
POINTER_SIZE,
38
QUANTUM_SIZE: POINTER_SIZE,
39
};
40
41
// Legacy name for runIfMainThread.
42
const runOnMainThread = runIfMainThread;
43
44
addToCompileTimeContext({
45
Runtime,
46
makeMalloc,
47
receiveI64ParamAsDouble,
48
receiveI64ParamAsI32s,
49
runOnMainThread,
50
});
51
52