Add built-in valueof type

This commit is contained in:
dcode
2019-06-15 22:44:48 +02:00
parent a4e5857f7f
commit 8571df939f
10 changed files with 333 additions and 39 deletions

View File

@ -882,6 +882,8 @@ declare namespace v8x16 {
}
/** Macro type evaluating to the underlying native WebAssembly type. */
declare type native<T> = T;
/** Special type evaluating the value type of a collection. */
declare type valueof<T extends unknown[]> = T[0];
/** Pseudo-class representing the backing class of integer types. */
declare class _Integer {

View File

@ -1068,7 +1068,7 @@ function FOREACH<TArray extends ArrayBufferView, T>(
// @ts-ignore: decorator
@inline
export function REVERSE<TArray extends ArrayBufferView, T>(array: TArray): TArray {
function REVERSE<TArray extends ArrayBufferView, T>(array: TArray): TArray {
var dataStart = array.dataStart;
for (let front = 0, back = array.length - 1; front < back; ++front, --back) {
let frontPtr = dataStart + (<usize>front << alignof<T>());

View File

@ -28,6 +28,9 @@ declare type usize = number;
declare type f32 = number;
declare type f64 = number;
/** Special type evaluating the value type of a collection. */
declare type valueof<T extends unknown[]> = T[0];
// Compiler hints
/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */