MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / asmEnsureFloat

Function asmEnsureFloat

src/parseTools.mjs:441–454  ·  view source on GitHub ↗
(value, type)

Source from the content-addressed store, hash-verified

439
440// ensures that a float type has either 5.5 (clearly a float) or +5 (float due to asm coercion)
441function asmEnsureFloat(value, type) {
442 if (!isNumber(value)) return value;
443 if (type === 'float') {
444 // normally ok to just emit Math.fround(0), but if the constant is large we
445 // may need a .0 (if it can't fit in an int)
446 if (value == 0) return 'Math.fround(0)';
447 value = ensureDot(value);
448 return `Math.fround(${value})`;
449 }
450 if (FLOAT_TYPES.has(type)) {
451 return ensureDot(value);
452 }
453 return value;
454}
455
456function asmCoercion(value, type) {
457 assert(arguments.length == 2, 'asmCoercion takes exactly two arguments');

Callers 2

splitI64Function · 0.85
asmCoercionFunction · 0.85

Calls 3

ensureDotFunction · 0.85
hasMethod · 0.80
isNumberFunction · 0.70

Tested by

no test coverage detected