0.11.4 • Published 2 years ago
visitor-as v0.11.4
Visitor utilities for AssemblyScript Compiler transformers
Example
List Fields
The transformer:
import {
ClassDeclaration,
FieldDeclaration,
MethodDeclaration,
} from "../../as";
import { ClassDecorator, registerDecorator } from "../decorator";
import { getName } from "../utils";
class ListMembers extends ClassDecorator {
visitFieldDeclaration(node: FieldDeclaration): void {
if (!node.name) console.log(getName(node) + "\n");
const name = getName(node);
const _type = getName(node.type!);
this.stdout.write(name + ": " + _type + "\n");
}
visitMethodDeclaration(node: MethodDeclaration): void {
const name = getName(node);
if (name == "constructor") {
return;
}
const sig = getName(node.signature);
this.stdout.write(name + ": " + sig + "\n");
}
visitClassDeclaration(node: ClassDeclaration): void {
this.visit(node.members);
}
get name(): string {
return "list";
}
}
export = registerDecorator(new ListMembers());
assembly/foo.ts:
@list
class Foo {
a: u8;
b: bool;
i: i32;
}
And then compile with --transform
flag:
asc assembly/foo.ts --transform ./dist/examples/list --noEmit
Which prints the following to the console:
a: u8
b: bool
i: i32
0.11.0
2 years ago
0.11.1
2 years ago
0.11.2
2 years ago
0.11.3
2 years ago
0.11.4
2 years ago
0.10.1
2 years ago
0.10.2
2 years ago
0.10.0
2 years ago
0.7.1-0
3 years ago
0.8.0
3 years ago
0.7.0-2
3 years ago
0.7.0-1
3 years ago
0.7.0-0
3 years ago
0.5.1-0
3 years ago
0.6.0
3 years ago
0.5.0-0
4 years ago
0.5.0
4 years ago
0.4.0
4 years ago
0.3.2
4 years ago
0.3.1
4 years ago
0.3.0
4 years ago
0.2.0
4 years ago
0.2.0-1
4 years ago
0.2.0-0
4 years ago
0.1.0
5 years ago
0.0.1
5 years ago