aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-20 11:06:38 +0200
committerlemon <lsof@mailbox.org>2022-08-20 11:06:38 +0200
commit46e1f128fd310bd29a2b4335b36c60d6cc0aa3a7 (patch)
treefeb93a69cf93773d0542435ae09c76de04e509c8 /bootstrap
parentdf41a4512932f1312e4725d0409757a683b091ed (diff)
initial work on IR
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/cgen.c7
-rw-r--r--bootstrap/parse.c5
2 files changed, 9 insertions, 3 deletions
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c
index 5fae699..e4ba1fd 100644
--- a/bootstrap/cgen.c
+++ b/bootstrap/cgen.c
@@ -246,7 +246,10 @@ genexpr(struct expr *ex) {
pri(")");
break;
case Eas:
- pri("((%t)%e)", ex->ty, ex->child);
+ if (ex->ty->t != TYarr)
+ pri("((%t)%e)", ex->ty, ex->child);
+ else
+ pri("(%e)", ex->child);
break;
case Eenumval:
pri("/*%s:%s*/", ex->ty->enu.name, ex->enu.vname);
@@ -341,7 +344,7 @@ genstmt(struct blockstmt *block, struct stmt *stmt) {
&& (decl.var.ini->t == Ezeroini || decl.var.ini->t == Eini))
{
geniniex(decl.var.ini);
- } else if (decl.var.ty->t == TYeunion) {
+ } else if (decl.var.ini->t == Eeuini) {
geneuiniex(decl.var.ini);
} else {
pri("%e", decl.var.ini);
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 371289f..91c7567 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -1644,7 +1644,10 @@ pexprefix(struct parser *P) {
ex = pexprefix(P);
from = ex.ty;
- if (typeof2(to, from)) ;
+ if (to->t == TYarr && to->length < 0 && ex.t == Eini) {
+ ex.ty = to = mkarraytype(to->child, ex.ini.maxn + 1);
+ }
+ else if (typeof2(to, from)) ;
else if (to->t == TYint && from->t == TYptr && to->size == from->size) ;
else if (from->t == TYint && to->t == TYptr && to->size == from->size) ;
else if (from->t == TYptr && to->t == TYptr) ;