Add bswap/bswap16 post MVP polyfills (#34)

This commit is contained in:
Max Graey
2018-02-19 13:35:28 +02:00
committed by Daniel Wirtz
parent 31633899f9
commit de1c4b3da5
8 changed files with 3301 additions and 0 deletions

5
std/assembly.d.ts vendored
View File

@ -175,6 +175,11 @@ declare function free_memory(ptr: usize): void;
/** Emits an unreachable operation that results in a runtime error when executed. Both a statement and an expression of any type. */
declare function unreachable(): any; // sic
/** [Polyfill] Performs the sign-agnostic reverse bytes **/
declare function bswap<T = i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64 | isize | usize>(value: T): T;
/** [Polyfill] Performs the sign-agnostic reverse bytes only for last 16-bit **/
declare function bswap16<T = i8 | u8 | i16 | u16 | i32 | u32>(value: T): T;
/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */
declare const NaN: f32 | f64;
/** Positive infinity as a 32-bit or 64-bit float depending on context. */