summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-10-24 15:57:22 -0700
committerOri Bernstein <ori@eigenstate.org>2015-11-06 00:38:56 -0800
commitda4798f000d99dd326a542758da83ad04be72f86 (patch)
tree8f2e086ed1c4c57683bb43db75cb057dafd4080b /mi
parent74270f8f47a704652ca301975da7ff88926e5cc8 (diff)
downloadmc-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.c8
-rw-r--r--mi/mi.h2
2 files changed, 3 insertions, 7 deletions
diff --git a/mi/match.c b/mi/match.c
index 6fda431..a2bb271 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -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)
diff --git a/mi/mi.h b/mi/mi.h
index 8b92a9d..a29619a 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -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);