aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/cgen.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-08 09:16:13 +0200
committerlemon <lsof@mailbox.org>2022-08-08 09:16:13 +0200
commitf8a8add7d0e74d20304b3194e836752a9986ddc3 (patch)
treed4c72f796c9b97c229f299b1632c6a5c9ffc3e37 /bootstrap/cgen.c
parent0a57a8979a75ce5398b34817c86a55c6d0552bca (diff)
direct access of eunion fields
Diffstat (limited to 'bootstrap/cgen.c')
-rw-r--r--bootstrap/cgen.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c
index 433a5a0..f54eccc 100644
--- a/bootstrap/cgen.c
+++ b/bootstrap/cgen.c
@@ -249,7 +249,10 @@ genexpr(struct expr *ex) {
pri("((%t)%n)", ty, ex);
break;
case Eget:
- pri("%e%s%s", ex->get.lhs, ex->get.lhs->ty->t == TYptr ? "->" : ".", ex->get.fld);
+ pri("%e%s%s%s", ex->get.lhs, ex->get.lhs->ty->t == TYptr ? "->" : ".",
+ (ex->get.lhs->ty->t == TYeunion
+ || (ex->get.lhs->ty->t == TYptr && ex->get.lhs->ty->child->t == TYeunion) ? "u." : ""),
+ ex->get.fld);
break;
case Emcall:
decl = container_of(ex->mcall.met, struct decl, fn);
@@ -273,6 +276,9 @@ genexpr(struct expr *ex) {
case Elen:
pri("%e.len", ex->child);
break;
+ case Eeutag:
+ pri("%e%st", ex->child, ex->child->ty->t == TYptr ? "->" : ".");
+ break;
case Eeuini:
pri("((%t)", ty);
geneuiniex(ex);
@@ -470,7 +476,7 @@ liftnestedex(struct expr *ex) {
case Eblock:
liftnested(blocktostmt(ex->block));
break;
- case Eas: case Elen:
+ case Eas: case Elen: case Eeutag:
liftnestedex(ex->child);
break;
case Eini: