1: #ifndef lint
   2: static char sccsid[] = "@(#)r0.c	1.2 (Berkeley) 8/11/83";
   3: #endif
   4: 
   5: #include "r.h"
   6: 
   7: int swlevel = -1;
   8: int swexit[5];
   9: int nextcase[5];
  10: 
  11: swcode() {
  12:     transfer = 0;
  13:     putcom("switch");
  14:     swlevel++;
  15:     if (swlevel >= 5)
  16:         error("Switches nested > 5");
  17:     swexit[swlevel] = yyval = genlab(1);
  18:     outcode("\tI");
  19:     outnum(yyval);
  20:     outcode(" = ");
  21:     balpar();
  22:     outdon();
  23:     nextcase[swlevel] = 0;
  24:     indent++;
  25: }
  26: 
  27: getcase() {
  28:     int t, lpar;
  29:     char token[100];
  30: 
  31:     if (nextcase[swlevel] != 0) {
  32:         outgoto(swexit[swlevel]);
  33:         outcont(nextcase[swlevel]);
  34:     }
  35:     indent--;
  36:     outcode("\tif(.not.(");
  37:     do {
  38:         outcode("I");
  39:         outnum(swexit[swlevel]);
  40:         outcode(".eq.(");
  41:         lpar = 0;
  42:         do {
  43:             if ((t=gtok(token)) == ':')
  44:                 break;
  45:             if (t == '(')
  46:                 lpar++;
  47:             else if (t == ')')
  48:                 lpar--;
  49:             else if (t == ',') {
  50:                 if (lpar == 0)
  51:                     break;
  52:                 }
  53:             outcode(token);
  54:         } while (lpar >= 0);
  55:         if (lpar < 0)
  56:             error("Missing left parenthesis in case");
  57:         if (t == ',')
  58:             outcode(").or.");
  59:     } while (t != ':');
  60:     if (lpar != 0)
  61:         error("Missing parenthesis in case");
  62:     outcode(")))");
  63:     nextcase[swlevel] = genlab(1);
  64:     outgoto(nextcase[swlevel]);
  65:     indent++;
  66: }
  67: 
  68: getdefault() {
  69:     char token[20];
  70:     if (gnbtok(token) != ':')
  71:         error("Missing colon after default");
  72:     outgoto(swexit[swlevel]);
  73:     outcont(nextcase[swlevel]);
  74:     indent--;
  75:     putcom("default");
  76:     indent++;
  77: }
  78: 
  79: endsw(n, def) {
  80:     if (def == 0)
  81:         outcont(nextcase[swlevel]);
  82:     swlevel--;
  83:     if (swlevel < -1)
  84:         error("Switches unwound too far");
  85:     indent--;
  86:     outcont(n);
  87: }

Defined functions

endsw defined in line 79; never used
getcase defined in line 27; never used
getdefault defined in line 68; never used
swcode defined in line 11; never used

Defined variables

nextcase defined in line 9; used 7 times
sccsid defined in line 2; never used
swexit defined in line 8; used 4 times
swlevel defined in line 7; used 15 times
Last modified: 1983-08-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 956
Valid CSS Valid XHTML 1.0 Strict