ref: b800e22d23759457e662d62c49ec27bed3210992
parent: b5135305eafca5a12d50f677a8eb2c85fb92907c
author: Ori Bernstein <[email protected]>
date: Wed Oct 15 15:44:02 EDT 2014
Add support for checking structs.
--- a/opt/match.c
+++ b/opt/match.c
@@ -107,7 +107,18 @@
static Dtree *addstruct(Dtree *t, Node *pat, Node ***cap, size_t *ncap)
{
- return NULL;
+ Node *elt;
+ size_t i, j;
+
+ for (i = 0; i < pat->expr.nargs; i++) {
+ elt = pat->expr.args[i];
+ for (j = 0; j < t->nval; j++) {
+ if (!strcmp(namestr(elt->expr.idx), namestr(t->val[j]->expr.idx)))
+ t = addpat(t, pat->expr.args[i], cap, ncap);
+ break;
+ }
+ }
+ return t;
}
static Dtree *addpat(Dtree *t, Node *pat, Node ***cap, size_t *ncap)