Aria

A low-level systems programming language
git clone git://git.m21c.me/Aria.git
Log | Files | Refs | README | LICENSE

commit 63f0afafe1b8a80498f4333057241451b06e4d3d
parent bd67b4f2a919b5e538d0e230279e75ad0e39213f
Author: m21c <ho*******@gmail.com>
Date:   Mon, 22 Jun 2026 22:11:42 +0200

fold type/module dispatch (Type.var_or_func)

Diffstat:
Mcompiler.c | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/compiler.c b/compiler.c @@ -5140,6 +5140,23 @@ folddeclaration(Env *env, Node *expr) } static Node * +folddispatch(Env *env, Node *expr) +{ + Node *lhs = expr->lhs, *rhs = expr->rhs; + Decl *field = expr->u.declref; + + assert(expr->kind == ODISP && lhs->kind == TYPE); + assert(field); + + expr->kind = ADECLREF; + expr->rhs = NULL; + expr->lhs = NULL; + /* deletenode(lhs); */ + /* deletenode(rhs); */ + return foldexpr(env, expr); +} + +static Node * foldexpr(Env *env, Node *expr) { Node *lhs = expr->lhs, *rhs = expr->rhs; @@ -5173,6 +5190,8 @@ foldexpr(Env *env, Node *expr) rhs = foldexpr(env, rhs); /* FALLTHROUGH */ case 1: + if (expr->kind == ODISP && lhs->kind == TYPE) + return folddispatch(env, expr); lhs = foldexpr(env, lhs); }