summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-06-29 01:38:56 -0700
committerOri Bernstein <ori@eigenstate.org>2017-06-30 23:15:23 -0700
commit849dee9be47627e40d26594257d03c081d501152 (patch)
tree95a09107f3a44c8cb4e2f40f5e80a93b6c77173a
parentf76f863288e8d289c9377dadb31a40bf83baa279 (diff)
downloadmc-849dee9be47627e40d26594257d03c081d501152.tar.gz
Use switch statement in postcheckpass
We don't need to check for Nexpr since exprop asserts e->type == Nexpr.
-rw-r--r--parse/infer.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 87aae5d..6d6cd11 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2199,16 +2199,13 @@ static void postcheckpass(Inferstate *st, Node ***rem, size_t *nrem, Stab ***rem
for (i = 0; i < st->npostcheck; i++) {
n = st->postcheck[i];
pushstab(st->postcheckscope[i]);
- if (n->type == Nexpr && exprop(n) == Omemb)
- infercompn(st, n, rem, nrem, remscope, nremscope);
- else if (n->type == Nexpr && exprop(n) == Ocast)
- checkcast(st, n, rem, nrem, remscope, nremscope);
- else if (n->type == Nexpr && exprop(n) == Ostruct)
- checkstruct(st, n, rem, nrem, remscope, nremscope);
- else if (n->type == Nexpr && exprop(n) == Ovar)
- checkvar(st, n, rem, nrem, remscope, nremscope);
- else
- die("Thing we shouldn't be checking in postcheck\n");
+ switch (exprop(n)) {
+ case Omemb: infercompn(st, n, rem, nrem, remscope, nremscope); break;
+ case Ocast: checkcast(st, n, rem, nrem, remscope, nremscope); break;
+ case Ostruct: checkstruct(st, n, rem, nrem, remscope, nremscope); break;
+ case Ovar: checkvar(st, n, rem, nrem, remscope, nremscope); break;
+ default: die("should not see %s in postcheck\n", opstr[exprop(n)]);
+ }
popstab();
}
}