Skip to content

Commit 1d53303

Browse files
committed
Initial commit
0 parents  commit 1d53303

32 files changed

+8460
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
npm-debug.*
3+
out/

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
AssemblyScript NEXT
2+
===================
3+
4+
This repository contains compiler component prototypes for the next iteration of the AssemblyScript compiler written in AssemblyScript itself.
5+
6+
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.
7+
8+
Why is this necessary?
9+
----------------------
10+
11+
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.
12+
13+
Cons:
14+
- A lot of work
15+
- Dealing with TypeScript compatibility issues
16+
17+
Pros:
18+
- One day compiling to WebAssembly for performance
19+
- Necessary features only, reducing binary size
20+
- Linking against Binaryen compiled to WebAssembly, reducing overhead
21+
22+
Side effects:
23+
- Good fire test for the compiler
24+
- Good benchmark when comparing both versions
25+
- Benefits standard library design ideas

package-lock.json

+219
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"devDependencies": {
3+
"@types/chalk": "^0.4.31",
4+
"@types/diff": "^3.2.2",
5+
"@types/long": "^3.0.32",
6+
"chalk": "^2.1.0",
7+
"diff": "^3.3.1",
8+
"long": "^3.2.0",
9+
"ts-node": "^3.3.0",
10+
"typescript": "^2.5.2"
11+
},
12+
"dependencies": {
13+
"@types/node": "^8.0.28",
14+
"binaryen": "37.0.0-nightly.20170912"
15+
}
16+
}

scripts/build-diagnostics.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var fs = require("fs");
2+
3+
var messages = require(__dirname + "/../src/diagnosticMessages.json");
4+
5+
var sb = [ "// code below is generated from diagnosticsMessages.json by scripts/build-diagnostics\n\n" ];
6+
7+
function makeKey(text) {
8+
return text.replace(/[^\w]+/g, "_").replace(/_+$/, "");
9+
}
10+
11+
sb.push("export enum DiagnosticCode {\n");
12+
13+
var first = true;
14+
Object.keys(messages).forEach(text => {
15+
var key = makeKey(text);
16+
if (first)
17+
first = false;
18+
else {
19+
sb.push(",\n");
20+
}
21+
sb.push(" " + key + " = " + messages[text]);
22+
});
23+
24+
sb.push("\n}\n\nexport function diagnosticCodeToString(code: DiagnosticCode): string {\n switch (code) {\n");
25+
26+
Object.keys(messages).forEach(text => {
27+
sb.push(" case " + messages[text] + ": return " + JSON.stringify(text) + ";\n");
28+
});
29+
30+
sb.push(" default: return \"\";\n }\n}\n");
31+
32+
fs.writeFileSync(__dirname + "/../src/diagnosticMessages.generated.ts", sb.join(""), { encoding: "utf8" });

0 commit comments

Comments
 (0)