1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)case.c	5.1 (Berkeley) 6/5/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * pxp - Pascal execution profiler
  13:  *
  14:  * Bill Joy UCB
  15:  * Version 1.2 January 1979
  16:  */
  17: 
  18: #include "0.h"
  19: #include "tree.h"
  20: 
  21: /*
  22:  * Case statement
  23:  *	r	[0]	T_CASE
  24:  *		[1]	lineof "case"
  25:  *		[2]	expression
  26:  *		[3]	list of cased statements:
  27:  *			cstat	[0]	T_CSTAT
  28:  *				[1]	lineof ":"
  29:  *				[2]	list of constant labels
  30:  *				[3]	statement
  31:  */
  32: caseop(r)
  33:     int *r;
  34: {
  35:     register *cl, *cs, i;
  36:     struct pxcnt scnt;
  37: #	ifdef RMOTHERS
  38:         int *othersp;       /* tree where others is, or NIL */
  39:         int hasothers;      /* 1 if others found, else 0 */
  40: #	endif RMOTHERS
  41: 
  42: #	ifdef RMOTHERS
  43:         if (rmothers) {
  44:         hasothers = needscaseguard(r,&othersp);
  45:         if (hasothers) {
  46:             precaseguard(r);
  47:         }
  48:         }
  49: #	endif RMOTHERS
  50:     savecnt(&scnt);
  51:     ppkw("case");
  52:     ppspac();
  53:     rvalue(r[2], NIL);
  54:     ppspac();
  55:     ppkw("of");
  56:     for (cl = r[3]; cl != NIL;) {
  57:         cs = cl[1];
  58:         if (cs == NIL)
  59:             continue;
  60:         baroff();
  61:         ppgoin(DECL);
  62:         setline(cs[1]);
  63:         ppnl();
  64:         indent();
  65:         ppbra(NIL);
  66:         cs = cs[2];
  67:         if (cs != NIL) {
  68:             i = 0;
  69:             for (;;) {
  70:                 gconst(cs[1]);
  71:                 cs = cs[2];
  72:                 if (cs == NIL)
  73:                     break;
  74:                 i++;
  75:                 if (i == 7) {
  76:                     ppsep(",");
  77:                     ppitem();
  78:                     i = 0;
  79:                 } else
  80:                     ppsep(", ");
  81:             }
  82:         } else
  83:             ppid("{case label list}");
  84:         ppket(":");
  85:         cs = cl[1];
  86:         cs = cs[3];
  87:         getcnt();
  88:         ppgoin(STAT);
  89:         if (cs != NIL && cs[0] == T_BLOCK) {
  90:             ppnl();
  91:             indent();
  92:             baron();
  93:             ppstbl1(cs, STAT);
  94:             baroff();
  95:             ppstbl2();
  96:             baron();
  97:         } else {
  98:             baron();
  99:             statement(cs);
 100:         }
 101:         ppgoout(STAT);
 102:         ppgoout(DECL);
 103:         cl = cl[2];
 104:         if (cl == NIL)
 105:             break;
 106:         ppsep(";");
 107:     }
 108:     if (rescnt(&scnt))
 109:         getcnt();
 110:     ppnl();
 111:     indent();
 112:     ppkw("end");
 113: #	ifdef RMOTHERS
 114:         if (rmothers) {
 115:         if (hasothers) {
 116:             postcaseguard(othersp);
 117:         }
 118:         }
 119: #	endif RMOTHERS
 120: }

Defined functions

caseop defined in line 32; used 1 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-06-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1121
Valid CSS Valid XHTML 1.0 Strict