forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.html
35 lines (32 loc) · 950 Bytes
/
web.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<script async src="https://cdn.jsdelivr.net/npm/es-module-shims@1.3.2/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@109.0.0-nightly.20220813/index.js",
"long": "https://cdn.jsdelivr.net/npm/long@5.2.0/index.js",
"assemblyscript": "../dist/assemblyscript.js",
"assemblyscript/asc": "../dist/asc.js"
}
}
</script>
<script type="module">
import asc from "assemblyscript/asc";
const files = {
"index.ts": "export function add(a: i32, b: i32): i32 { return a + b; }"
};
const { error, stdout } = await asc.main([
"index.ts", "--textFile", "--optimize"
], {
readFile(name, baseDir) {
if (Object.prototype.hasOwnProperty.call(files, name)) return files[name];
return null;
},
writeFile(name, data, baseDir) {
},
listFiles(dirname, baseDir) {
return [];
}
});
if (error) throw error;
console.log(stdout.toString());
</script>