summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-11-06 01:38:19 -0800
committerOri Bernstein <ori@eigenstate.org>2015-11-06 01:38:19 -0800
commiteac5baa8515b5e6fe46ecf609d2cac94ffed5dc6 (patch)
tree11a2e920e00c4475e4e0c1e547fe930f3824c185 /mi
parent2a27b2d8ac101e17e300a2e25421fc25c403b05b (diff)
downloadmc-eac5baa8515b5e6fe46ecf609d2cac94ffed5dc6.tar.gz
Fix patterns with multiple sequential wildcards
(a, b) was an invalid pattern, since we would never generate the jump to the pattern check for b.
Diffstat (limited to 'mi')
-rw-r--r--mi/match.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/mi/match.c b/mi/match.c
index 878a30a..2588f59 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -692,8 +692,12 @@ void genmatchcode(Dtree *dt, Node ***out, size_t *nout)
if (emit)
lappend(out, nout, fail);
}
- if (dt->any)
+ if (dt->any) {
+ jmp = mkexpr(dt->loc, Ojmp, dt->any->lbl, NULL);
+ jmp->expr.type = mktype(dt->loc, Tyvoid);
+ lappend(out, nout, jmp);
genmatchcode(dt->any, out, nout);
+ }
}
void genonematch(Node *pat, Node *val, Node *iftrue, Node *iffalse, Node ***out, size_t *nout, Node ***cap, size_t *ncap)
@@ -743,9 +747,11 @@ void genmatch(Node *m, Node *val, Node ***out, size_t *nout)
}
lappend(out, nout, endlbl);
- //dtreedump(stdout, dt);
- //for (i = 0; i < *nout; i++)
- // dump((*out)[i], stdout);
+ if (debugopt['m']) {
+ dtreedump(stdout, dt);
+ for (i = 0; i < *nout; i++)
+ dump((*out)[i], stdout);
+ }
}