ref: a5b425e6cfe4e58dc32f1d126af43416e76ee3c4
parent: 0252c2debe6b62c840af38dfdb3b973f0e6d8c02
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu May 26 12:43:31 EDT 2016
[cc2] Update the number of cases per switch v2
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -32,6 +32,7 @@
struct swtch {
int nr;
+ Node *first;
Node *last;
};
@@ -354,21 +355,27 @@
static void
bswitch(char *token, union tokenop u)
{
- if (swp++ == &swtbl[NR_BLOCK+1])
+ struct swtch *cur;
+
+ if (swp == &swtbl[NR_BLOCK+1])
error(EWTACKO);
+ cur = swp++;
+ cur->nr = 0;
jump(token, u);
- swp->nr = 0;
- swp->last = push(pop());
+ cur->first = cur->last = push(pop());
}
static void
eswitch(char *token, union tokenop u)
{
+ struct swtch *cur;
+
if (swp == swtbl)
error(EWTACKU);
jump(token, u);
waft(pop());
- --swp;
+ cur = swp--;
+ cur->first->u.i = cur->nr;
}
static void