mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Reference the wiki
This commit is contained in:
parent
6bea116b3e
commit
b69c07af45
43
README.md
43
README.md
@ -9,17 +9,17 @@ By compiling syntactially (not necessarily semantically) valid TypeScript to [Bi
|
|||||||
|
|
||||||
The compiler itself utilizes "portable definitions" so it can be compiled to both JavaScript using `tsc` and, eventually, to WebAssembly using `asc`.
|
The compiler itself utilizes "portable definitions" so it can be compiled to both JavaScript using `tsc` and, eventually, to WebAssembly using `asc`.
|
||||||
|
|
||||||
Development status
|
Note, though, that this version of the compiler (0.5.0, NEXT) is relatively new and does not yet support some features a TypeScript programmer might expect, e.g., strings, arrays and classes.
|
||||||
------------------
|
|
||||||
|
|
||||||
This version of the compiler (0.5.0, NEXT) is relatively new and does not yet support some features a TypeScript programmer might expect, e.g., strings, arrays and classes. For now, you can see the [compiler tests](https://github.com/AssemblyScript/next/tree/master/tests/compiler) for an overview of what's supposed to be working already.
|
See [the AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) for additional information and documentation.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
A few early examples to get an idea:
|
A few early examples to get an idea:
|
||||||
|
|
||||||
* **Conway's Game of Life** as seen on [dcode.io](http://dcode.io)<br />
|
* **[Conway's Game of Life](./examples/game-of-life)** as seen on dcode.io<br />
|
||||||
[source](./examples/game-of-life/assembly/game-of-life.ts) - [wast](./examples/game-of-life/assembly/game-of-life.optimized.wast) - [html](./examples/game-of-life/game-of-life.html)
|
* **[i64 polyfill](./examples/i64-polyfill)** using 32-bit integers<br />
|
||||||
* **i64 polyfill** using 32-bit integers<br />
|
|
||||||
[source](./examples/i64-polyfill/assembly/i64.ts) - [wast](./examples/i64-polyfill/assembly/i64.optimized.wast) - [js](./examples/i64-polyfill/index.js)
|
|
||||||
|
|
||||||
Getting started
|
Getting started
|
||||||
---------------
|
---------------
|
||||||
@ -43,35 +43,6 @@ and run:
|
|||||||
$> node bin/asc yourModule.ts
|
$> node bin/asc yourModule.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
Using the CLI
|
|
||||||
-------------
|
|
||||||
|
|
||||||
```
|
|
||||||
Syntax: asc [options] [entryFile ...]
|
|
||||||
|
|
||||||
Examples: asc hello.ts
|
|
||||||
asc hello.ts -b hello.wasm -t hello.wast -a hello.js
|
|
||||||
asc hello.ts -b > hello.wasm
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-v, --version Prints the compiler's version.
|
|
||||||
-h, --help Prints this message.
|
|
||||||
-O, --optimize Optimizes the module.
|
|
||||||
-c, --validate Validates the module.
|
|
||||||
-o, --outFile Specifies the output file. Format is determined by file extension.
|
|
||||||
-b, --binaryFile Specifies the binary format output file (.wasm).
|
|
||||||
-t, --textFile Specifies the text format output file (.wast).
|
|
||||||
-a, --asmjsFile Specifies the asm.js format output file (.js).
|
|
||||||
--noTreeShaking Disables tree-shaking.
|
|
||||||
--noDebug Disables assertions.
|
|
||||||
--trapMode Sets the trap mode to use.
|
|
||||||
allow Allow trapping operations. This is the default.
|
|
||||||
clamp Replace trapping operations with clamping semantics.
|
|
||||||
js Replace trapping operations with JS semantics.
|
|
||||||
```
|
|
||||||
|
|
||||||
Unless a bundle has been built to `dist/`, `asc` runs the (portable) TypeScript sources on the fly via [ts-node](https://www.npmjs.com/package/ts-node). Useful for development.
|
|
||||||
|
|
||||||
Building
|
Building
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Conway's Game of Life
|
Conway's Game of Life
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
An AssemblyScript example.
|
An [AssemblyScript](http://assemblyscript.org) example. Continuously updates the cellular automaton and visualizes its state on a canvas.
|
||||||
|
|
||||||
Instructions
|
Instructions
|
||||||
------------
|
------------
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
i64 polyfill
|
i64 polyfill
|
||||||
============
|
============
|
||||||
|
|
||||||
An AssemblyScript example.
|
An [AssemblyScript](http://assemblyscript.org) example. Exposes i64 operations to JS using 32-bit integers (low and high bits).
|
||||||
|
|
||||||
Instructions
|
Instructions
|
||||||
------------
|
------------
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:untouched && npm run build:optimized",
|
"build": "npm run build:untouched && npm run build:optimized",
|
||||||
"build:untouched": "asc assembly/i64.ts -t i64.untouched.wast -b i64.untouched.wasm --validate",
|
"build:untouched": "asc assembly/i64.ts -t i64.untouched.wast -b i64.untouched.wasm --validate",
|
||||||
"build:optimized": "asc -O assembly/i64.ts -b i64.optimized.wasm -t i64.optimized.wast --validdate"
|
"build:optimized": "asc -O assembly/i64.ts -b i64.optimized.wasm -t i64.optimized.wast --validate"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
std/assembly.d.ts
vendored
10
std/assembly.d.ts
vendored
@ -63,15 +63,15 @@ declare function select<T>(ifTrue: T, ifFalse: T, condition: bool): T;
|
|||||||
declare function sqrt<T = f32 | f64>(value: T): T;
|
declare function sqrt<T = f32 | f64>(value: T): T;
|
||||||
/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */
|
/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */
|
||||||
declare function trunc<T = f32 | f64>(value: T): T;
|
declare function trunc<T = f32 | f64>(value: T): T;
|
||||||
/** Loads a value of the specified type from memory. */
|
/** Loads a value of the specified type from memory. Equivalent to dereferncing a pointer in other languages. */
|
||||||
declare function load<T>(offset: usize): T;
|
declare function load<T>(offset: usize): T;
|
||||||
/** Stores a value of the specified type to memory. */
|
/** Stores a value of the specified type to memory. Equivalent to dereferencing a pointer in other languages when assigning a value. */
|
||||||
declare function store<T>(offset: usize, value: T): void;
|
declare function store<T>(offset: usize, value: T): void;
|
||||||
/** Returns the current memory size in units of pages. One page is 64kb. */
|
/** Returns the current memory size in units of pages. One page is 64kb. */
|
||||||
declare function current_memory(): i32;
|
declare function current_memory(): i32;
|
||||||
/** Grows linear memory by a given unsigned delta of pages. One page is 64kb. Returns the previous memory size in units of pages or `-1` on failure. */
|
/** Grows linear memory by a given unsigned delta of pages. One page is 64kb. Returns the previous memory size in units of pages or `-1` on failure. */
|
||||||
declare function grow_memory(value: i32): i32;
|
declare function grow_memory(value: i32): i32;
|
||||||
/** Emits an unreachable operation that results in a runtime error when executed. */
|
/** 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
|
declare function unreachable(): any; // sic
|
||||||
|
|
||||||
/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */
|
/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */
|
||||||
@ -84,9 +84,9 @@ declare const HEAP_START: usize;
|
|||||||
declare function sizeof<T>(): usize;
|
declare function sizeof<T>(): usize;
|
||||||
/** Changes the type of a value to another one. Useful for casting class instances to their pointer values and vice-versa. */
|
/** Changes the type of a value to another one. Useful for casting class instances to their pointer values and vice-versa. */
|
||||||
declare function changetype<T1,T2>(value: T1): T2;
|
declare function changetype<T1,T2>(value: T1): T2;
|
||||||
/** Tests if a 32-bit or 64-bit float is NaN. */
|
/** Tests if a 32-bit or 64-bit float is `NaN`. */
|
||||||
declare function isNaN<T = f32 | f64>(value: T): bool;
|
declare function isNaN<T = f32 | f64>(value: T): bool;
|
||||||
/** Tests if a 32-bit or 64-bit float is finite, that is not NaN or +/-Infinity. */
|
/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */
|
||||||
declare function isFinite<T = f32 | f64>(value: T): bool;
|
declare function isFinite<T = f32 | f64>(value: T): bool;
|
||||||
/** Traps if the specified value evaluates to `false`. */
|
/** Traps if the specified value evaluates to `false`. */
|
||||||
declare function assert(isTrue: bool, message?: string): void;
|
declare function assert(isTrue: bool, message?: string): void;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user