summaryrefslogtreecommitdiff
path: root/parse/gram.y
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-20 23:06:03 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-20 23:06:03 -0800
commit6361a241f462769284053e07d51cd0638d3e94af (patch)
tree9c69b768bdccb941da1384e53745f87e4c94afa5 /parse/gram.y
parent631e14604ba34ad97514cf302de75c3c3102d316 (diff)
downloadmc-6361a241f462769284053e07d51cd0638d3e94af.tar.gz
Add a distinction between label values and names.
This allows us to have labels work across scopes in assembly source.
Diffstat (limited to 'parse/gram.y')
-rw-r--r--parse/gram.y12
1 files changed, 10 insertions, 2 deletions
diff --git a/parse/gram.y b/parse/gram.y
index 0fdfed1..505ab14 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -580,7 +580,10 @@ unionelt /* nb: the ucon union type gets filled in when we have context */
| Tendln {$$ = NULL;}
;
-goto : Tgoto Tident {$$ = mkexpr($1->loc, Ojmp, mklbl($2->loc, $2->id), NULL);}
+goto : Tgoto Tident {
+ $$ = mkexpr($1->loc, Ojmp, mklbl($2->loc, ""), NULL);
+ $$->expr.args[0]->lit.lblname = strdup($2->id);
+ }
;
retexpr : Tret expr {$$ = mkexpr($1->loc, Oret, $2, NULL);}
@@ -971,7 +974,12 @@ blkbody : decl {
}
;
-label : Tcolon Tident {$$ = mklbl($2->loc, $2->id);}
+label : Tcolon Tident {
+ char buf[512];
+ genlblstr(buf, sizeof buf, $2->id);
+ $$ = mklbl($2->loc, buf);
+ $$->expr.args[0]->lit.lblname = strdup($2->id);
+ }
;
%%