commit 14b14db116c59bfeeed0319493db6ccf3bc33d60
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Thu May 26 16:43:31 2016 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Thu May 26 16:43:31 2016 +0200

    [cc2] Update the number of cases per switch v2

diff --git a/cc2/parser.c b/cc2/parser.c
index 292d1ce..077d95a 100644
--- 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

Reply via email to