summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-26 23:47:46 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-26 23:47:46 -0700
commitc74b0bc06994e9a4921131696a5714cf83642acc (patch)
tree415b1001ccfc44b55c7fa4d8a2d130ee38907ee2 /mi
parentbb4ff654b3f0ce2e067e707f83310af5ebc50679 (diff)
downloadmc-c74b0bc06994e9a4921131696a5714cf83642acc.tar.gz
Separate out the concepts of code and func ptrs.
In order to pass around functions with environments for closures, we need to refer to the type of a function pointer, as well as the type of code. This is ugly. When I rewrite the backend I should change it.
Diffstat (limited to 'mi')
-rw-r--r--mi/dfcheck.c2
-rw-r--r--mi/match.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/mi/dfcheck.c b/mi/dfcheck.c
index fbd536d..a7257cc 100644
--- a/mi/dfcheck.c
+++ b/mi/dfcheck.c
@@ -118,7 +118,7 @@ static void checkret(Cfg *cfg)
Type *ft;
ft = tybase(decltype(cfg->fn));
- assert(ft->type == Tyfunc);
+ assert(ft->type == Tyfunc || ft->type == Tycode);
if (ft->sub[0]->type == Tyvoid)
return;
diff --git a/mi/match.c b/mi/match.c
index 68af507..366bf1b 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -75,14 +75,15 @@ static size_t nconstructors(Type *t)
/* complex types */
case Typtr: return 1; break;
- case Tyfunc: return 0; break;
case Tyarray: return 1; break;
case Tytuple: return 1; break;
case Tystruct: return 1;
case Tyunion: return t->nmemb; break;
case Tyslice: return ~0ULL; break;
+
case Tyvar: case Typaram: case Tyunres: case Tyname:
case Tybad: case Tyvalist: case Tygeneric: case Ntypes:
+ case Tyfunc: case Tycode:
die("Invalid constructor type %s in match", tystr(t));
break;
}
@@ -204,6 +205,7 @@ static Dtree *addpat(Dtree *t, Node *pat, Node *val, Node ***cap, size_t *ncap)
if (pat == NULL)
return t;
+ pat = fold(pat, 1);
switch (exprop(pat)) {
case Ovar:
dcl = decls[pat->expr.did];