ast_printer: add support for method data
This commit is contained in:
parent
e0d712cd9f
commit
20e5c2339f
1 changed files with 20 additions and 3 deletions
|
@ -37,14 +37,31 @@ fn printBlock(ident: usize, block: var, endNewline: bool) void {
|
||||||
pub fn printNode(node: *Node, ident: usize) void {
|
pub fn printNode(node: *Node, ident: usize) void {
|
||||||
switch (node.*) {
|
switch (node.*) {
|
||||||
.FnDecl => |decl| {
|
.FnDecl => |decl| {
|
||||||
print(ident, "(fn {} (", decl.func_name.lexeme);
|
const name = decl.func_name.lexeme;
|
||||||
|
|
||||||
|
printIdent(ident);
|
||||||
|
|
||||||
|
// TODO print return types
|
||||||
|
|
||||||
|
if (decl.method) |method| {
|
||||||
|
const vari = method.variable.lexeme;
|
||||||
|
const typ = method.typ.lexeme;
|
||||||
|
|
||||||
|
if (method.mutable) {
|
||||||
|
warn("(method mut {} {} {} ", vari, typ, name);
|
||||||
|
} else {
|
||||||
|
warn("(method {} {} {} ", vari, typ, name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
warn("(fn {} (", name);
|
||||||
|
}
|
||||||
|
|
||||||
for (decl.params.toSlice()) |param| {
|
for (decl.params.toSlice()) |param| {
|
||||||
std.debug.warn("({} {}) ", param.name.lexeme, param.typ.lexeme);
|
warn("({} {}) ", param.name.lexeme, param.typ.lexeme);
|
||||||
}
|
}
|
||||||
|
|
||||||
printBlock(ident + 1, decl.body, false);
|
printBlock(ident + 1, decl.body, false);
|
||||||
std.debug.warn(")\n");
|
warn(")\n");
|
||||||
},
|
},
|
||||||
|
|
||||||
.ConstDecl => |consts| {
|
.ConstDecl => |consts| {
|
||||||
|
|
Loading…
Reference in a new issue