summaryrefslogtreecommitdiff
path: root/parse/specialize.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-05-09 16:49:09 -0700
committerOri Bernstein <ori@eigenstate.org>2015-05-09 16:49:09 -0700
commited8711e68e441e9884d734932373317834665833 (patch)
tree08a3f37550af1b6adb1ad912ee6df70fa6c1ceaf /parse/specialize.c
parentbd5fb6d0628831cde25f13e3fe461786d616a06e (diff)
downloadmc-ed8711e68e441e9884d734932373317834665833.tar.gz
Refactor code to add jump tables, and prepare to generate them.
Diffstat (limited to 'parse/specialize.c')
-rw-r--r--parse/specialize.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/parse/specialize.c b/parse/specialize.c
index 6cf5aa9..f7315e2 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -177,10 +177,18 @@ static void fixup(Node *n)
break;
case Nlit:
switch (n->lit.littype) {
- case Lfunc: fixup(n->lit.fnval); break;
case Lchr: case Lint: case Lflt:
case Lstr: case Llbl: case Lbool:
break;
+ case Lfunc:
+ fixup(n->lit.fnval);
+ break;
+ case Ljtab:
+ for (i = 0; i < n->lit.jtab->nval; i++) {
+ fixup(n->lit.jtab->val[i]);
+ fixup(n->lit.jtab->dst[i]);
+ }
+ break;
}
break;
case Nifstmt:
@@ -271,12 +279,13 @@ static Node *specializenode(Node *n, Htab *tsmap)
r->lit.littype = n->lit.littype;
r->lit.type = tysubst(n->expr.type, tsmap);
switch (n->lit.littype) {
- case Lchr: r->lit.chrval = n->lit.chrval; break;
- case Lint: r->lit.intval = n->lit.intval; break;
- case Lflt: r->lit.fltval = n->lit.fltval; break;
- case Lstr: r->lit.strval = n->lit.strval; break;
- case Llbl: r->lit.lblval = n->lit.lblval; break;
- case Lbool: r->lit.boolval = n->lit.boolval; break;
+ case Ljtab: die("jtab in frontend?"); break;
+ case Lchr: r->lit.chrval = n->lit.chrval; break;
+ case Lint: r->lit.intval = n->lit.intval; break;
+ case Lflt: r->lit.fltval = n->lit.fltval; break;
+ case Lstr: r->lit.strval = n->lit.strval; break;
+ case Llbl: r->lit.lblval = n->lit.lblval; break;
+ case Lbool: r->lit.boolval = n->lit.boolval; break;
case Lfunc: r->lit.fnval = specializenode(n->lit.fnval, tsmap); break;
}
break;