1 /*- 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)lval.c 8.1 (Berkeley) 06/06/93"; 10 #endif /* not lint */ 11 12 /* 13 * pxp - Pascal execution profiler 14 * 15 * Bill Joy UCB 16 * Version 1.2 January 1979 17 */ 18 19 #include "0.h" 20 #include "tree.h" 21 22 /* 23 * A "variable" 24 */ 25 lvalue(r) 26 register int *r; 27 { 28 register *c, *co; 29 30 ppid(r[2]); 31 for (c = r[3]; c != NIL; c = c[2]) { 32 co = c[1]; 33 if (co == NIL) 34 continue; 35 switch (co[0]) { 36 case T_PTR: 37 ppop("^"); 38 continue; 39 case T_ARY: 40 arycod(co[1]); 41 continue; 42 case T_FIELD: 43 ppop("."); 44 ppid(co[1]); 45 continue; 46 case T_ARGL: 47 ppid("{unexpected argument list}"); 48 break; 49 default: 50 panic("lval2"); 51 } 52 } 53 } 54 55 /* 56 * Subscripting 57 */ 58 arycod(el) 59 register int *el; 60 { 61 62 ppbra("["); 63 if (el != NIL) 64 for (;;) { 65 rvalue(el[1], NIL); 66 el = el[2]; 67 if (el == NIL) 68 break; 69 ppsep(", "); 70 } 71 else 72 rvalue(NIL, NIL); 73 ppket("]"); 74 } 75