Commit | Line | Data |
---|---|---|
252367af DF |
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[] = "@(#)lval.c 5.1 (Berkeley) %G%"; | |
9 | #endif not lint | |
10 | ||
695246fe PK |
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 | * A "variable" | |
23 | */ | |
24 | lvalue(r) | |
25 | register int *r; | |
26 | { | |
27 | register *c, *co; | |
28 | ||
29 | ppid(r[2]); | |
30 | for (c = r[3]; c != NIL; c = c[2]) { | |
31 | co = c[1]; | |
32 | if (co == NIL) | |
33 | continue; | |
34 | switch (co[0]) { | |
35 | case T_PTR: | |
36 | ppop("^"); | |
37 | continue; | |
38 | case T_ARY: | |
39 | arycod(co[1]); | |
40 | continue; | |
41 | case T_FIELD: | |
42 | ppop("."); | |
43 | ppid(co[1]); | |
44 | continue; | |
45 | case T_ARGL: | |
46 | ppid("{unexpected argument list}"); | |
47 | break; | |
48 | default: | |
49 | panic("lval2"); | |
50 | } | |
51 | } | |
52 | } | |
53 | ||
54 | /* | |
55 | * Subscripting | |
56 | */ | |
57 | arycod(el) | |
58 | register int *el; | |
59 | { | |
60 | ||
61 | ppbra("["); | |
62 | if (el != NIL) | |
63 | for (;;) { | |
64 | rvalue(el[1], NIL); | |
65 | el = el[2]; | |
66 | if (el == NIL) | |
67 | break; | |
68 | ppsep(", "); | |
69 | } | |
70 | else | |
71 | rvalue(NIL, NIL); | |
72 | ppket("]"); | |
73 | } |