( remoteTypeId: number, localTypeId: number, value: string, converter: string, )
| 381 | } |
| 382 | |
| 383 | function scalarToIntegerExpr( |
| 384 | remoteTypeId: number, |
| 385 | localTypeId: number, |
| 386 | value: string, |
| 387 | converter: string, |
| 388 | ): string | null { |
| 389 | const checkedMethod = checkedIntegerMethod(localTypeId); |
| 390 | if (checkedMethod === null) { |
| 391 | return null; |
| 392 | } |
| 393 | switch (remoteTypeId) { |
| 394 | case TypeId.BOOL: |
| 395 | if (localTypeId === TypeId.INT64 || localTypeId === TypeId.UINT64) { |
| 396 | return `(${value} ? 1n : 0n)`; |
| 397 | } |
| 398 | return `(${value} ? 1 : 0)`; |
| 399 | case TypeId.STRING: |
| 400 | return `${converter}.${checkedMethod}(${converter}.stringToInteger(${value}))`; |
| 401 | case TypeId.DECIMAL: |
| 402 | return `${converter}.${checkedMethod}(${converter}.decimalToInteger(${value}))`; |
| 403 | case TypeId.FLOAT16: |
| 404 | case TypeId.BFLOAT16: |
| 405 | case TypeId.FLOAT32: |
| 406 | case TypeId.FLOAT64: |
| 407 | return `${converter}.${checkedMethod}(${converter}.floatToInteger(${value}))`; |
| 408 | default: |
| 409 | return integerToIntegerExpr(remoteTypeId, localTypeId, value, converter); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | function integerToIntegerExpr( |
| 414 | remoteTypeId: number, |
no test coverage detected