diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-10-24 15:57:22 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-11-06 00:38:56 -0800 |
commit | da4798f000d99dd326a542758da83ad04be72f86 (patch) | |
tree | 8f2e086ed1c4c57683bb43db75cb057dafd4080b /mi | |
parent | 74270f8f47a704652ca301975da7ff88926e5cc8 (diff) | |
download | mc-da4798f000d99dd326a542758da83ad04be72f86.tar.gz |
Shuffle around functions.
Move some code into the frontend so the middle end can call it.
Diffstat (limited to 'mi')
-rw-r--r-- | mi/match.c | 8 | ||||
-rw-r--r-- | mi/mi.h | 2 |
2 files changed, 3 insertions, 7 deletions
@@ -490,7 +490,7 @@ static Node *genmatch(Srcloc loc, Dtree *dt, Node *lastany) } /* val must be a pure, fully evaluated value */ -Node *gensimpmatch(Node *m, Node *val) +void gensimpmatch(Node *m, Node *val, Node ***out, size_t *nout) { Node **pat, **cap; size_t npat, ncap; @@ -505,9 +505,6 @@ Node *gensimpmatch(Node *m, Node *val) cap = NULL; ncap = 0; leaf = addpat(t, pat[i]->match.pat, val, &cap, &ncap); - /* TODO: NULL is returned by unsupported patterns. */ - if (!leaf) - return NULL; if (leaf->act) fatal(pat[i], "pattern matched by earlier case on line %d", leaf->act->loc.line); leaf->act = pat[i]->match.block; @@ -517,8 +514,7 @@ Node *gensimpmatch(Node *m, Node *val) if (!exhaustivematch(m, t, exprtype(m->matchstmt.val))) fatal(m, "nonexhaustive pattern set in match statement"); n = genmatch(m->loc, t, deadblock()); - assert(n->type == Nifstmt); - return n; + lappend(out, nout, n); } char *dtnodestr(Node *n) @@ -48,4 +48,4 @@ void dumpcfg(Cfg *c, FILE *fd); void check(Cfg *cfg); /* pattern matching */ -Node *gensimpmatch(Node *m, Node *val); +void gensimpmatch(Node *m, Node *val, Node ***out, size_t *nout); |