shithub: mc

Download patch

ref: 849dee9be47627e40d26594257d03c081d501152
parent: f76f863288e8d289c9377dadb31a40bf83baa279
author: Michael Forney <mforney@mforney.org>
date: Wed Jun 28 21:38:56 EDT 2017

Use switch statement in postcheckpass

We don't need to check for Nexpr since exprop asserts e->type == Nexpr.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2199,16 +2199,13 @@
 	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();
 	}
 }