(value, type)
| 439 | |
| 440 | // ensures that a float type has either 5.5 (clearly a float) or +5 (float due to asm coercion) |
| 441 | function 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 | |
| 456 | function asmCoercion(value, type) { |
| 457 | assert(arguments.length == 2, 'asmCoercion takes exactly two arguments'); |
no test coverage detected