You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains compiler components for the next iteration of the AssemblyScript compiler written in AssemblyScript itself.
6
+
**AssemblyScript** is a new compiler targeting WebAssembly while utilizing [TypeScript](http://www.typescriptlang.org)'s syntax and [node](https://nodejs.org)'s vibrant ecosystem. Instead of requiring complex toolchains to set up, you can simply `npm install` it - or run it in a browser.
7
7
8
-
Note that the code uses some features and standard library components that are not yet supported by any version of asc. To account for this, the code has been written in "portable AssemblyScript", a TypeScript-compatible subset of a subset of a superset of JavaScript, that also compiles to JavaScript using TSC.
8
+
By compiling a variant of TypeScript to [Binaryen](https://github.com/WebAssembly/binaryen) IR, the resulting module can be validated, optimized, emitted in WebAssembly text or binary format and converted to [asm.js](http://asmjs.org) as a polyfill.
9
9
10
-
Why is this necessary?
11
-
----------------------
10
+
The compiler itself is written in "portable AssemblyScript" so it can be compiled to both JavaScript using `tsc` and, eventually, to WebAssembly using `asc`.
12
11
13
-
Well, it isn't, but: In order to be able to compile the AssemblyScript compiler itself to WebAssembly eventually, we cannot depend on TypeScript because it is written in vanilla TypeScript and makes use of quite a few non-AOT-compatible dynamic features of JavaScript.
14
-
15
-
Cons:
16
-
- A lot of work
17
-
- Dealing with TypeScript compatibility issues
18
-
19
-
Pros:
20
-
- One day compiling to WebAssembly for performance
21
-
- Necessary features only, reducing binary size
22
-
- Linking against Binaryen compiled to WebAssembly, reducing overhead
23
-
24
-
Side effects:
25
-
- Good fire test for the compiler
26
-
- Good benchmark when comparing both versions
27
-
- Benefits standard library design ideas
28
-
29
-
How does it work?
30
-
-----------------
12
+
Development status
13
+
------------------
31
14
32
-
AssemblyScript NEXT compiles a subset (or variant) of TypeScript to [Binaryen](https://github.com/WebAssembly/binaryen) IR. The resulting module can then be optimized, emitted in text or binary format or converted to [asm.js](http://asmjs.org) as a polyfill.
15
+
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.
33
16
34
17
Getting started
35
18
---------------
36
19
37
-
If you'd like to try out NEXT today or even plan to contribute, this is how you do it:
20
+
If you'd like to try it today or even plan to contribute, this is how you do it:
Building an UMD bundle to `dist/assemblyscript.js` (does not bundle [binaryen.js](https://github.com/AssemblyScript/binaryen.js)):
28
+
Author your module in AssemblyScript ([definitions](./assembly.d.ts)) or portable AssemblyScript ([definitions](./portable-assembly.d.ts)) and run:
47
29
48
30
```
49
-
$> npm run build
50
-
```
51
-
52
-
Running the [tests](./tests):
53
-
54
-
```
55
-
$> npm test
31
+
$> node bin\asc yourModule.ts
56
32
```
57
33
58
-
Development status
59
-
------------------
60
-
61
-
For now, see the [compiler tests](https://github.com/AssemblyScript/next/tree/master/tests/compiler) for an overview of what's supposed to be working already.
62
-
63
34
Using the CLI
64
35
-------------
65
36
@@ -82,9 +53,24 @@ Options:
82
53
--noTreeShaking Disables tree-shaking.
83
54
--noDebug Disables assertions.
84
55
--trapMode Sets the trap mode to use.
85
-
none Do not modify trapping operations. This is the default.
56
+
allow Allow trapping operations. This is the default.
86
57
clamp Replace trapping operations with clamping semantics.
87
58
js Replace trapping operations with JS semantics.
88
59
```
89
60
90
-
Unless a bundle has been built to `dist/`, `asc` runs the TypeScript sources directly via [ts-node](https://www.npmjs.com/package/ts-node). Useful for development.
61
+
Unless a bundle has been built to `dist/`, `asc` runs the TypeScript sources on the fly via [ts-node](https://www.npmjs.com/package/ts-node). Useful for development.
62
+
63
+
Building
64
+
--------
65
+
66
+
Building an UMD bundle to `dist/assemblyscript.js` (does not bundle [binaryen.js](https://github.com/AssemblyScript/binaryen.js)):
0 commit comments