Aria

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

commit 763d1ed78735e876ab8323004eb5429aaff1172d
parent fa6845ad461f8c45c162507160cd2121cdd6f335
Author: m21c <ho*******@gmail.com>
Date:   Thu, 18 Jun 2026 12:02:49 +0200

make sure compiler line length <= 80

Diffstat:
Mcompiler.c | 69++++++++++++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 46 insertions(+), 23 deletions(-)

diff --git a/compiler.c b/compiler.c @@ -982,12 +982,14 @@ myallocimpl(MemArena *arena, size_t elemsize) arena->capacity *= 2; if (!arena->capacity) arena->capacity = 1; - arena->pages = realloc(arena->pages, arena->capacity * sizeof(void*)); + arena->pages = realloc( + arena->pages, arena->capacity * sizeof(void*)); assert(arena->pages); } if (!arena->pages[pageindex]) { - arena->pages[pageindex] = calloc(ARENA_PAGE_SIZE, arena->elemsize); + arena->pages[pageindex] = calloc( + ARENA_PAGE_SIZE, arena->elemsize); assert(arena->pages[pageindex]); } @@ -1769,7 +1771,8 @@ skipwhite: if (!mygetline(source)) return source->tok.kind = 0; - source->currloc.column = 0; /* is this needed? */ + /* is this needed? */ + source->currloc.column = 0; ch = peekchar(source); } @@ -2927,7 +2930,8 @@ declaration(Source *source, Type *ty, bool tryreadtype) */ if (tryreadtype) { - decl = finddeclaration(source, source->currenv, source->tok.u.key); + decl = finddeclaration( + source, source->currenv, source->tok.u.key); if (decl && decl->kind == DTYPE) { gettok(source); @@ -2981,8 +2985,8 @@ redodeclaration: goto readvarmodule; } - if ((getkind(source) == ODISP || getkind(source) == COLONDELIM) && - getkind(source) != LPARDELIM && getkind(source) != OASS) + if ((getkind(source) == ODISP || getkind(source) == COLONDELIM) + && getkind(source) != LPARDELIM && getkind(source) != OASS) { error(&loc, "expected type or module"); } @@ -3056,7 +3060,8 @@ redodeclaration: if (selfparam) { param = makedecl(source, auxself, DVAR); - param->type = maketype(&source->arenas, &param->loc, + param->type = maketype( + &source->arenas, &param->loc, prim + TPTR, module); param->flags |= MSPECIAL; /* @note param doesn't need to be added to @@ -3407,8 +3412,10 @@ readrecordinitfield(Source *source, Type *recordtype) gettok(source); if (getkind(source) == COLONDELIM) { gettok(source); - /* @todo associate field name with field in record type */ - fieldinit->lhs = makenode(&source->arenas, &savedtok, NULL); + /* @todo associate field name with field in record + * type */ + fieldinit->lhs = makenode( + &source->arenas, &savedtok, NULL); } else { pushbacktok(source, &savedtok); } @@ -3514,7 +3521,8 @@ readatom(Source *source, int flags) source->lastis = savedis; if (lhs->kind == TYPE) { - /* @note expecting that the type is also set in lhs->type */ + /* @note expecting that the type is also set in + * lhs->type */ lhs->kind = OCAST; skipnewline(source); expect(source, RPARDELIM, "expected ')'"); @@ -3527,7 +3535,9 @@ readatom(Source *source, int flags) lhs->lhs->kind == TYPE && lhs->rhs->kind == TYPE) { - Type *ty = maketype(&source->arenas, &lhs->loc, primitive(TTUPLE), NULL); + Type *ty = maketype( + &source->arenas, &lhs->loc, + primitive(TTUPLE), NULL); ty->target = lhs->lhs->type; ty->u.rtarget = lhs->rhs->type; deletenode(lhs); @@ -3535,7 +3545,8 @@ readatom(Source *source, int flags) skipnewline(source); expect(source, RPARDELIM, "expected ')'"); - lhs = declaration(source, gettype(source, ty), false); + lhs = declaration(source, + gettype(source, ty), false); assert(lhs); return lhs; @@ -4005,8 +4016,8 @@ exprlist(Source *source, bool isparam, Type *paramtype) lhs->lhs->kind == TYPE && lhs->rhs->kind == TYPE) { - lhs->type = maketype(&source->arenas, &lhs->loc, primitive(TTUPLE), - lhs->lhs->type); + lhs->type = maketype(&source->arenas, &lhs->loc, + primitive(TTUPLE), lhs->lhs->type); lhs->type->u.rtarget = lhs->rhs->type; lhs->lhs->type = NULL; @@ -4472,7 +4483,9 @@ selfdispatchcall(Env *env, Node *expr) if (self->type->kind == TSTRUCT || self->type->kind == TUNION) { self = makenode(env->arenas, self, self); self->kind = OADDR; - self->type = maketype(env->arenas, &self->loc, primitive(TINT), self->type); + self->type = maketype( + env->arenas, &self->loc, + primitive(TINT), self->type); } else if (self->type->kind != TPTR) { error(&self->loc, "expected struct or union or pointer type"); } else if (self->type->target->kind != TSTRUCT && @@ -4594,10 +4607,12 @@ forloop(Env *env, Node *expr, Node *header) Decl *it = init->u.declref; if (!it->u.content) { if (!isarithtype(it->type)) { - error(&it->loc, "for loop variable must be initialized"); + error(&it->loc, + "for loop variable must be initialized"); return; } - it->u.content = makenode(env->arenas, header, NULL); + it->u.content = makenode( + env->arenas, header, NULL); it->u.content->kind = NUMBER; it->u.content->type = it->type; it->u.content->u.u = 0; @@ -4607,7 +4622,8 @@ forloop(Env *env, Node *expr, Node *header) } /* @todo do proper typechecking */ - header->rhs = wrap(env, header->lhs->type, typecheck(env, header->rhs)); + header->rhs = wrap( + env, header->lhs->type, typecheck(env, header->rhs)); header->u.payload = wrap( env, header->lhs->type, typecheck(env, header->u.payload)); @@ -4771,7 +4787,9 @@ typecheck(Env *env, Node *expr) reporton(!islvalue(lhs), &expr->loc, "operand is not an lvalue"); - expr->type = maketype(env->arenas, &expr->loc, primitive(TPTR), lhs->type); + expr->type = maketype( + env->arenas, &expr->loc, + primitive(TPTR), lhs->type); return expr; case OPLUS: case OMINUS: @@ -5010,7 +5028,9 @@ typecheck(Env *env, Node *expr) expr->lhs = conv(env, lhs); expr->rhs = conv(env, rhs); - expr->type = maketype(env->arenas, &expr->loc, primitive(TTUPLE), lhs->type); + expr->type = maketype( + env->arenas, &expr->loc, + primitive(TTUPLE), lhs->type); expr->type->u.rtarget = rhs->type; return expr; @@ -5050,8 +5070,9 @@ typecheck(Env *env, Node *expr) Env *funcenv = getfuncenv(env); Type *functype; - reporton(!funcenv, - &expr->loc, "return statement is not inside a function"); + reporton( + !funcenv, &expr->loc, + "return statement is not inside a function"); assert(funcenv->envdecl); assert(funcenv->envdecl->type); @@ -5184,7 +5205,9 @@ foldexpr(Env *env, Node *expr) } else if (expr->kind == ODIV) { evalbinary(/); } else { - evalbinary(/); /* @todo implement modulus for float-types */ + /* @todo implement modulus for + * float-types */ + evalbinary(/); } } } else if (isvalue(lhs, 0)) {