commit 14b14db116c59bfeeed0319493db6ccf3bc33d60
parent c1e0104d5d49ab4d4f6545f90fb4c14cb76cd7b8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 26 May 2016 16:43:31 +0200
[cc2] Update the number of cases per switch v2
Diffstat:
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/cc2/parser.c b/cc2/parser.c
@@ -32,6 +32,7 @@ union tokenop {
struct swtch {
int nr;
+ Node *first;
Node *last;
};
@@ -354,21 +355,27 @@ waft(Node *np)
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