-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathmytransform.mjs
27 lines (25 loc) · 941 Bytes
/
mytransform.mjs
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
import * as assemblyscript from "assemblyscript";
import { Transform } from "assemblyscript/transform";
import binaryen from "binaryen";
class MyTransform extends Transform {
afterParse(parser) {
this.log("[mytransform.js] afterParse called, baseDir = " + this.baseDir);
var sources = this.program.sources;
sources.forEach((source) =>
this.log(" " + source.internalPath + " [" + assemblyscript.SourceKind[source.sourceKind] + "]")
);
}
afterInitialize(program) {
this.log("[mytransform.js] afterInitialize called");
var elements = program.elementsByName;
elements.forEach((element) =>
this.log(" " + element.internalName + " [" + assemblyscript.ElementKind[element.kind] + "]")
);
}
afterCompile(asModule) {
this.log("[mytransform.js] afterCompile called");
var module = binaryen.wrapModule(asModule.ref);
this.log(module.emitBinary());
}
}
export default MyTransform;