|
|
1.1 root 1: /* Copyright (c) 1982 Regents of the University of California */
2:
3: static char sccsid[] = "@(#)operators.c 1.4 5/18/83";
4:
5: /*
6: * Tree node classes.
7: */
8:
9: #include "defs.h"
10: #include "operators.h"
11:
12: #ifndef public
13: typedef struct {
14: char numargs;
15: char opflags;
16: String opstring;
17: } Opinfo;
18:
19: typedef enum {
20: O_NOP,
21: O_NAME, O_SYM, O_LCON, O_FCON, O_SCON,
22: O_RVAL, O_INDEX, O_INDIR, O_DOT,
23: O_COMMA,
24:
25: O_ITOF, O_ADD, O_ADDF, O_SUB, O_SUBF, O_NEG, O_NEGF,
26: O_MUL, O_MULF, O_DIVF, O_DIV, O_MOD,
27:
28: O_AND, O_OR,
29:
30: O_LT, O_LTF, O_LE, O_LEF, O_GT, O_GTF, O_GE, O_GEF,
31: O_EQ, O_EQF, O_NE, O_NEF,
32:
33: O_ALIAS, /* rename a command */
34: O_ASSIGN, /* assign a value to a program variable */
35: O_CALL, /* call a procedure in the program */
36: O_CATCH, /* catch a signal before program does */
37: O_CHFILE, /* change (or print) the current source file */
38: O_CONT, /* continue execution */
39: O_DEBUG, /* invoke a dbx internal debugging routine */
40: O_DELETE, /* remove a trace/stop */
41: O_DUMP, /* dump out variables */
42: O_EDIT, /* edit a file (or function) */
43: O_FUNC, /* set the current function */
44: O_GRIPE, /* send mail to debugger support person */
45: O_HELP, /* print a synopsis of debugger commands */
46: O_IGNORE, /* let program catch signal */
47: O_LIST, /* list source lines */
48: O_PRINT, /* print the values of a list of expressions */
49: O_PSYM, /* print symbol information */
50: O_RUN, /* start up program */
51: O_SKIP, /* skip the current line */
52: O_SOURCE, /* read commands from a file */
53: O_STATUS, /* display currently active trace/stop's */
54: O_STEP, /* execute a single line */
55: O_STOP, /* stop on an event */
56: O_STOPI, /* stop on an event at an instruction boundary */
57: O_TRACE, /* trace something on an event */
58: O_TRACEI, /* trace at the instruction level */
59: O_WHATIS, /* print the declaration of a variable */
60: O_WHERE, /* print a stack trace */
61: O_WHEREIS, /* print all the symbols with the given name */
62: O_WHICH, /* print out full qualification of a symbol */
63: O_EXAMINE, /* examine program instructions/data */
64:
65: O_ADDEVENT, /* add an event */
66: O_ENDX, /* end of program reached */
67: O_IF, /* if first arg is true, do commands in second arg */
68: O_ONCE, /* add a "one-time" event, delete when first reached */
69: O_PRINTCALL, /* print out the current procedure and its arguments */
70: O_PRINTIFCHANGED, /* print the value of the argument if it has changed */
71: O_PRINTRTN, /* print out the routine and value that just returned */
72: O_PRINTSRCPOS, /* print out the current source position */
73: O_PROCRTN, /* CALLPROC completed */
74: O_QLINE, /* filename, line number */
75: O_STOPIFCHANGED, /* stop if the value of the argument has changed */
76: O_STOPX, /* stop execution */
77: O_TRACEON, /* begin tracing source line, variable, or all lines */
78: O_TRACEOFF, /* end tracing source line, variable, or all lines */
79:
80: O_TYPERENAME, /* state the type of an expression */
81:
82: O_LASTOP
83: } Operator;
84:
85: /*
86: * Operator flags and predicates.
87: */
88:
89: #define null 0
90: #define LEAF 01
91: #define UNARY 02
92: #define BINARY 04
93: #define BOOL 010
94: #define REALOP 020
95: #define INTOP 040
96:
97: #define isbitset(a, m) ((a&m) == m)
98: #define isleaf(o) isbitset(opinfo[ord(o)].opflags, LEAF)
99: #define isunary(o) isbitset(opinfo[ord(o)].opflags, UNARY)
100: #define isbinary(o) isbitset(opinfo[ord(o)].opflags, BINARY)
101: #define isreal(o) isbitset(opinfo[ord(o)].opflags, REALOP)
102: #define isint(o) isbitset(opinfo[ord(o)].opflags, INTOP)
103: #define isboolean(o) isbitset(opinfo[ord(o)].opflags, BOOL)
104:
105: #define degree(o) (opinfo[ord(o)].opflags&(LEAF|UNARY|BINARY))
106: #define nargs(o) (opinfo[ord(o)].numargs)
107:
108: #endif
109:
110: /*
111: * Operator information structure.
112: */
113:
114: public Opinfo opinfo[] ={
115: /* O_NOP */ 0, null, 0,
116: /* O_NAME */ -1, LEAF, 0,
117: /* O_SYM */ -1, LEAF, 0,
118: /* O_LCON */ -1, LEAF, 0,
119: /* O_FCON */ -1, LEAF, 0,
120: /* O_SCON */ -1, LEAF, 0,
121: /* O_RVAL */ 1, UNARY, 0,
122: /* O_INDEX */ 2, BINARY, 0,
123: /* O_INDIR */ 1, UNARY, "^",
124: /* O_DOT */ 2, null, ".",
125: /* O_COMMA */ 2, BINARY, ",",
126: /* O_ITOF */ 1, UNARY|INTOP, 0,
127: /* O_ADD */ 2, BINARY|INTOP, "+",
128: /* O_ADDF */ 2, BINARY|REALOP, "+",
129: /* O_SUB */ 2, BINARY|INTOP, "-",
130: /* O_SUBF */ 2, BINARY|REALOP, "-",
131: /* O_NEG */ 1, UNARY|INTOP, "-",
132: /* O_NEGF */ 1, UNARY|REALOP, "-",
133: /* O_MUL */ 2, BINARY|INTOP, "*",
134: /* O_MULF */ 2, BINARY|REALOP, "*",
135: /* O_DIVF */ 2, BINARY|REALOP, "/",
136: /* O_DIV */ 2, BINARY|INTOP, " div ",
137: /* O_MOD */ 2, BINARY|INTOP, " mod ",
138: /* O_AND */ 2, BINARY|INTOP, " and ",
139: /* O_OR */ 2, BINARY|INTOP, " or ",
140: /* O_LT */ 2, BINARY|INTOP, " < ",
141: /* O_LTF */ 2, BINARY|REALOP, " < ",
142: /* O_LE */ 2, BINARY|INTOP, " <= ",
143: /* O_LEF */ 2, BINARY|REALOP, " <= ",
144: /* O_GT */ 2, BINARY|INTOP, " > ",
145: /* O_GTF */ 2, BINARY|REALOP, " > ",
146: /* O_GE */ 2, BINARY|INTOP, " >= ",
147: /* O_GEF */ 2, BINARY|REALOP, " >= ",
148: /* O_EQ */ 2, BINARY|INTOP, " = ",
149: /* O_EQF */ 2, BINARY|REALOP, " = ",
150: /* O_NE */ 2, BINARY|INTOP, " <> ",
151: /* O_NEF */ 2, BINARY|REALOP, " <> ",
152:
153: /* O_ALIAS */ 2, null, "alias",
154: /* O_ASSIGN */ 2, BINARY, " := ",
155: /* O_CALL */ 2, null, "call",
156: /* O_CATCH */ 0, null, "catch",
157: /* O_CHFILE */ 0, null, "file",
158: /* O_CONT */ 0, null, "cont",
159: /* O_DEBUG */ 0, null, "debug",
160: /* O_DELETE */ 0, null, "delete",
161: /* O_DUMP */ 0, null, "dump",
162: /* O_EDIT */ 0, null, "edit",
163: /* O_FUNC */ 1, null, "func",
164: /* O_GRIPE */ 0, null, "gripe",
165: /* O_HELP */ 0, null, "help",
166: /* O_IGNORE */ 0, null, "ignore",
167: /* O_LIST */ 2, null, "list",
168: /* O_PRINT */ 1, null, "print",
169: /* O_PSYM */ 1, null, "psym",
170: /* O_RUN */ 0, null, "run",
171: /* O_SKIP */ 0, null, "skip",
172: /* O_SOURCE */ 0, null, "source",
173: /* O_STATUS */ 0, null, "status",
174: /* O_STEP */ 0, null, "step",
175: /* O_STOP */ 3, null, "stop",
176: /* O_STOPI */ 3, null, "stopi",
177: /* O_TRACE */ 3, null, "trace",
178: /* O_TRACEI */ 3, null, "tracei",
179: /* O_WHATIS */ 1, null, "whatis",
180: /* O_WHERE */ 0, null, "where",
181: /* O_WHEREIS */ 1, null, "whereis",
182: /* O_WHICH */ 1, null, "which",
183: /* O_EXAMINE */ 0, null, "examine",
184:
185: /* O_ADDEVENT */ 0, null, "when",
186: /* O_ENDX */ 0, null, nil,
187: /* O_IF */ 0, null, "if",
188: /* O_ONCE */ 0, null, "once",
189: /* O_PRINTCALL */ 1, null, "printcall",
190: /* O_PRINTIFCHANGED */ 1, null, "printifchanged",
191: /* O_PRINTRTN */ 1, null, "printrtn",
192: /* O_PRINTSRCPOS */ 1, null, "printsrcpos",
193: /* O_PROCRTN */ 1, null, "procrtn",
194: /* O_QLINE */ 2, null, nil,
195: /* O_STOPIFCHANGED */ 1, null, "stopifchanged",
196: /* O_STOPX */ 0, null, "stop",
197: /* O_TRACEON */ 1, null, "traceon",
198: /* O_TRACEOFF */ 1, null, "traceoff",
199: /* O_TYPERENAME */ 2, UNARY, "traceoff",
200: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.