From 71d00fcbc45ab329ff79b78852e01f5d6ba6e626 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 5 Sep 2021 16:04:24 +0300 Subject: [PATCH 1/8] update docs to align with 0.19.12 --- src/compiler.md | 2 ++ src/loader.md | 12 ++++++++++-- src/stdlib/console.md | 18 +++++++++--------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/compiler.md b/src/compiler.md index 3ea379db3..c0bd49bbe 100644 --- a/src/compiler.md +++ b/src/compiler.md @@ -149,7 +149,9 @@ There are several flags that enable or disable specific WebAssembly or compiler --use, -u Aliases a global object under another name, e.g., to switch the default 'Math' implementation used: --use Math=JSMath Can also be used to introduce an integer constant. + --lowMemoryLimit Enforces very low (<64k) memory constraints. +--zeroFilledMemory Assume that imported memory is zero filled (requires --importMemory). ``` ### Linking diff --git a/src/loader.md b/src/loader.md index 9d99a13d1..8cb84b02c 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. Optional `values` сan reserve capacity or accept an array / typedarray of elements with numbers or pointers. 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`. * ```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 function object from pointer which contain table's index. `ptr` must not be zero. + * ```ts function __getArrayBuffer(ptr: number): ArrayBuffer ``` 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. From 1b3cb3f9a3e7dc6b964021e5aa1b3d7a8c4f396e Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 5 Sep 2021 17:48:40 +0300 Subject: [PATCH 2/8] add info about @final and @unmanaged decorators --- src/peculiarities.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/peculiarities.md b/src/peculiarities.md index c24aa9f34..5ae045dc7 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 non-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 From ea730b614c402eb2781aed49fd096086acc0dba7 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 5 Sep 2021 21:14:39 +0300 Subject: [PATCH 3/8] add MIN_NORMAL_VALUE for f32/f64 --- src/peculiarities.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/peculiarities.md b/src/peculiarities.md index 5ae045dc7..6c05a5306 100644 --- a/src/peculiarities.md +++ b/src/peculiarities.md @@ -170,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 @@ -178,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 From 53e452cc062d7d312a4a6b17f3c9783b41f0045f Mon Sep 17 00:00:00 2001 From: Max Graey Date: Wed, 8 Sep 2021 21:00:50 +0300 Subject: [PATCH 4/8] Update src/compiler.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: d̶c̶o̶d̶e̶ --- src/compiler.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler.md b/src/compiler.md index c0bd49bbe..05534cbef 100644 --- a/src/compiler.md +++ b/src/compiler.md @@ -149,7 +149,6 @@ There are several flags that enable or disable specific WebAssembly or compiler --use, -u Aliases a global object under another name, e.g., to switch the default 'Math' implementation used: --use Math=JSMath Can also be used to introduce an integer constant. - --lowMemoryLimit Enforces very low (<64k) memory constraints. --zeroFilledMemory Assume that imported memory is zero filled (requires --importMemory). ``` From 7be0c45ddd79f8a45db68813ba24e01a12e5aeff Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Wed, 8 Sep 2021 21:02:24 +0300 Subject: [PATCH 5/8] move zeroFilledMemory after sharedMemory --- src/compiler.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler.md b/src/compiler.md index 05534cbef..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. @@ -150,7 +151,6 @@ There are several flags that enable or disable specific WebAssembly or compiler the default 'Math' implementation used: --use Math=JSMath Can also be used to introduce an integer constant. --lowMemoryLimit Enforces very low (<64k) memory constraints. ---zeroFilledMemory Assume that imported memory is zero filled (requires --importMemory). ``` ### Linking From 21c7f6a9284f78684a7caa98564a188147dedf29 Mon Sep 17 00:00:00 2001 From: Max Graey Date: Wed, 8 Sep 2021 21:03:40 +0300 Subject: [PATCH 6/8] Update src/loader.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: d̶c̶o̶d̶e̶ --- src/loader.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader.md b/src/loader.md index 8cb84b02c..88b50c074 100644 --- a/src/loader.md +++ b/src/loader.md @@ -248,7 +248,7 @@ The following utility functions are mixed into the module's exports. 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. Optional `values` сan reserve capacity or accept an array / typedarray of elements with numbers or pointers. 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 From b6f82917c354e1c428bb910a9e02b155a08e7da6 Mon Sep 17 00:00:00 2001 From: Max Graey Date: Wed, 8 Sep 2021 21:05:14 +0300 Subject: [PATCH 7/8] Update src/loader.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: d̶c̶o̶d̶e̶ --- src/loader.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader.md b/src/loader.md index 88b50c074..9c67940f1 100644 --- a/src/loader.md +++ b/src/loader.md @@ -258,7 +258,7 @@ The following utility functions are mixed into the module's exports. * ```ts function __getFunction(ptr: number): ((...args: unknown[]) => unknown) | null ``` - Gets a function object from pointer which contain table's index. `ptr` must not be zero. + 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 From a8ecb8bd9e11446c3ac24367f502c2c82d9f4986 Mon Sep 17 00:00:00 2001 From: Max Graey Date: Wed, 8 Sep 2021 21:05:44 +0300 Subject: [PATCH 8/8] Update src/peculiarities.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: d̶c̶o̶d̶e̶ --- src/peculiarities.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peculiarities.md b/src/peculiarities.md index 6c05a5306..9bbb42ab2 100644 --- a/src/peculiarities.md +++ b/src/peculiarities.md @@ -15,7 +15,7 @@ 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 non-subclassed. +| `@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.