This commit is contained in:
Mid 2025-10-10 17:15:52 +03:00
parent fc16c077d9
commit 2049826870

View File

@ -266,14 +266,17 @@ static char *ast_dumps(AST *tlc, AST *s) {
} else if(s->nodeKind == AST_STMT_EXPR) {
return ast_dumpe(tlc, s->stmtExpr.expr);
} else if(s->nodeKind == AST_STMT_DECL) {
char *a = type_to_string(s->stmtDecl.thing->type);
ScopeItem *si = s->stmtDecl.thing;
const char *name = si->kind == SCOPEITEM_VAR ? si->data.var.name : si->data.symbol.name;
char *a = type_to_string(si->type);
char *c;
if(s->stmtDecl.expression) {
char *b = ast_dumpe(tlc, s->stmtDecl.expression);
c = malp("%s %s = %s;", a, s->stmtDecl.thing->data.var.name, b);
c = malp("%s %s = %s;", a, name, b);
free(b);
} else {
c = malp("%s %s;", a, s->stmtDecl.thing->data.var.name);
c = malp("%s %s;", a, name);
}
free(a);
return c;