cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 2c7f9d3a0131ca4f2060d05edfa2a67a190cd11f
parent e8b57d5e943171add23fc3674a34dbbb93d49046
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 15 Feb 2019 20:14:50 -0800

Some small cleanups

Diffstat:
Minit.c | 28++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/init.c b/init.c @@ -88,7 +88,7 @@ subobj(struct initparser *p, struct type *t, uint64_t off) off += p->sub->offset; if (++p->sub == p->obj + LEN(p->obj)) fatal("internal error: too many designators"); - p->sub->type = t; + p->sub->type = typeunqual(t, NULL); p->sub->offset = off; p->sub->iscur = false; } @@ -174,42 +174,38 @@ focus(struct initparser *p) default: t = p->sub->type; } - subobj(p, typeunqual(t, NULL), 0); + subobj(p, t, 0); } static void advance(struct initparser *p) { struct type *t; - uint64_t offset; for (;;) { --p->sub; - switch (p->sub->type->kind) { + t = p->sub->type; + switch (t->kind) { case TYPEARRAY: ++p->sub->idx; - if (p->sub->type->incomplete) - updatearray(p->sub->type, p->sub->idx); - if (p->sub->idx < p->sub->type->array.length) { - t = p->sub->type->base; - offset = t->size * p->sub->idx; - goto done; + if (t->incomplete) + updatearray(t, p->sub->idx); + if (p->sub->idx < t->array.length) { + subobj(p, t->base, t->base->size * p->sub->idx); + return; } break; case TYPESTRUCT: p->sub->mem = p->sub->mem->next; if (p->sub->mem) { - t = p->sub->mem->type; - offset = p->sub->mem->offset; - goto done; + subobj(p, p->sub->mem->type, p->sub->mem->offset); + return; } break; } if (p->sub == p->cur) error(&tok.loc, "too many initializers for type"); } -done: - subobj(p, typeunqual(t, NULL), offset); } /* 6.7.9 Initialization */ @@ -245,7 +241,7 @@ parseinit(struct scope *s, struct type *t) } expr = assignexpr(s); for (;;) { - t = typeunqual(p.sub->type, NULL); + t = p.sub->type; switch (t->kind) { case TYPEARRAY: if (expr->flags & EXPRFLAG_DECAYED && expr->unary.base->kind == EXPRSTRING) {