diff --git a/src/compiler.md b/src/compiler.md index 3ea379db3..2ab41b6ef 100644 --- a/src/compiler.md +++ b/src/compiler.md @@ -121,6 +121,7 @@ There are several flags that enable or disable specific WebAssembly or compiler --initialMemory Sets the initial memory size in pages. --maximumMemory Sets the maximum memory size in pages. --sharedMemory Declare memory as shared. Requires maximumMemory. +--zeroFilledMemory Assume that imported memory is zero filled (requires --importMemory). --importTable Imports the function table from 'env.table'. --exportTable Exports the function table as 'table'. --runtime Specifies the runtime variant to include in the program. diff --git a/src/loader.md b/src/loader.md index 9d99a13d1..9c67940f1 100644 --- a/src/loader.md +++ b/src/loader.md @@ -243,15 +243,23 @@ The following utility functions are mixed into the module's exports. Allocates a new string in the module's memory and returns a pointer to it. Requires `--exportRuntime` for access to `__new`. * ```ts - function __newArray(id: number, values: number[]): number + function __newArray( + id: number, + values: valuesOrCapacity?: number[] | ArrayBufferView | number + ): number ``` - Allocates a new array in the module's memory and returns a pointer to it. The `id` is the unique runtime id of the respective array class. If you are using `Int32Array` for example, the best way to know the id is an `export const Int32Array_ID = idof()`. Requires `--exportRuntime` for access to `__new`. + Allocates a new array in the module's memory and returns a pointer to it. The `id` is the unique runtime id of the respective array class. If you are using `Int32Array` for example, the best way to know the id is an `export const Int32Array_ID = idof()`. Requires `--exportRuntime` for access to `__new`. The `values` parameter сan also be used to pre-allocate an otherwise empty array of a certain capacity. * ```ts function __getString(ptr: number): string ``` Copies a string's value from the module's memory to a JavaScript string. `ptr` must not be zero. +* ```ts + function __getFunction(ptr: number): ((...args: unknown[]) => unknown) | null + ``` + Gets a callable function object from the module's memory containing its table index. `ptr` must not be zero. + * ```ts function __getArrayBuffer(ptr: number): ArrayBuffer ``` diff --git a/src/peculiarities.md b/src/peculiarities.md index c24aa9f34..9bbb42ab2 100644 --- a/src/peculiarities.md +++ b/src/peculiarities.md @@ -15,6 +15,8 @@ Decorators work more like actual compiler annotations in AssemblyScript. | `@inline` | Requests inlining of a constant or function. | `@lazy` | Requests lazy compilation of a variable. Useful to avoid unnecessary globals. | `@global` | Registers an element to be part of the global scope. +| `@final` | Annotates a class as final, that is it cannot be subclassed. +| `@unmanaged` | Annotates a class as not tracked by GC, essentially C structs. | `@external` | Changes the external name of an imported element. `@external(module, name)` changes both the module and element name, `@external(name)` changes the element name only. | `@operator` | Annotates a method as a binary operator overload. See below. | `@operator.binary` | Alias of `@operator`. @@ -76,10 +78,10 @@ __op(): T { ... } | OP | Description | Notes | :----- | :--------------- | :----- -| `"!"` | Logical NOT | -| `"~"` | Bitwise NOT | -| `"+"` | Unary plus | -| `"-"` | Unary negation | +| `"!"` | Logical NOT | +| `"~"` | Bitwise NOT | +| `"+"` | Unary plus | +| `"-"` | Unary negation | | `"++"` | Prefix increment | Instance overload reassigns | `"--"` | Prefix decrement | Instance overload reassigns @@ -168,6 +170,7 @@ The following range limits are present as global constants for convenience: * ```ts const f32.MIN_VALUE: f32 = -3.40282347e+38 const f32.MAX_VALUE: f32 = 3.40282347e+38 + const f32.MIN_NORMAL_VALUE: f32 = 1.17549435e-38 const f32.MIN_SAFE_INTEGER: f32 = -16777215 const f32.MAX_SAFE_INTEGER: f32 = 16777215 const f32.EPSILON: f32 = 1.19209290e-07 @@ -176,6 +179,7 @@ The following range limits are present as global constants for convenience: * ```ts const f64.MIN_VALUE: f64 = -1.7976931348623157e+308 const f64.MAX_VALUE: f64 = 1.7976931348623157e+308 + const f64.MIN_NORMAL_VALUE: f64 = 2.2250738585072014e-308 const f64.MIN_SAFE_INTEGER: f64 = -9007199254740991 const f64.MAX_SAFE_INTEGER: f64 = 9007199254740991 const f64.EPSILON: f64 = 2.2204460492503131e-16 diff --git a/src/stdlib/console.md b/src/stdlib/console.md index 09ca6b707..987b70b65 100644 --- a/src/stdlib/console.md +++ b/src/stdlib/console.md @@ -13,34 +13,34 @@ import "wasi"; ## Static members * ```ts - function assert(assertion: T, message: string): void + function assert(assertion: T, message?: string): void ``` Logs `message` to console if `assertion` is false-ish. * ```ts - function log(message: string): void + function log(message?: string): void ``` Outputs `message` to the console. * ```ts - function debug(message: string): void - function info(message: string): void - function warn(message: string): void - function error(message: string): void + function debug(message?: string): void + function info(message?: string): void + function warn(message?: string): void + function error(message?: string): void ``` Outputs `message` to the console, prefixed with "Debug:", "Info:", "Warning:" or "Error:" respectively. * ```ts - function time(label: string): void + function time(label?: string): void ``` Starts a new timer using the specified `label`. * ```ts - function timeLog(label: string): void + function timeLog(label?: string): void ``` Logs the current value of a timer previously started with `console.time`. * ```ts - function timeEnd(label: string): void + function timeEnd(label?: string): void ``` Logs the current value of a timer previously started with `console.time` and discards the timer.