Skip to content

Update docs to align with 0.19.12 #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions src/loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int32Array>()`. 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<Int32Array>()`. 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
```
Expand Down
12 changes: 8 additions & 4 deletions src/peculiarities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/stdlib/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,34 @@ import "wasi";
## Static members

* ```ts
function assert<T>(assertion: T, message: string): void
function assert<T>(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.