|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)operators.c 5.3 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: /* ! 25: * Tree node classes. ! 26: */ ! 27: ! 28: #include "defs.h" ! 29: #include "operators.h" ! 30: ! 31: #ifndef public ! 32: typedef struct { ! 33: char numargs; ! 34: char opflags; ! 35: String opstring; ! 36: } Opinfo; ! 37: ! 38: typedef enum { ! 39: O_NOP, ! 40: O_NAME, O_SYM, O_LCON, O_CCON, O_FCON, O_SCON, ! 41: O_RVAL, O_INDEX, O_INDIR, O_DOT, ! 42: O_COMMA, ! 43: ! 44: O_ITOF, O_ADD, O_ADDF, O_SUB, O_SUBF, O_NEG, O_NEGF, ! 45: O_MUL, O_MULF, O_DIVF, O_DIV, O_MOD, ! 46: ! 47: O_AND, O_OR, ! 48: ! 49: O_LT, O_LTF, O_LE, O_LEF, O_GT, O_GTF, O_GE, O_GEF, ! 50: O_EQ, O_EQF, O_NE, O_NEF, ! 51: ! 52: O_ALIAS, /* rename a command */ ! 53: O_ASSIGN, /* assign a value to a program variable */ ! 54: O_CALL, /* call a procedure in the program */ ! 55: O_CATCH, /* catch a signal before program does */ ! 56: O_CHFILE, /* change (or print) the current source file */ ! 57: O_CONT, /* continue execution */ ! 58: O_DEBUG, /* invoke a dbx internal debugging routine */ ! 59: O_DELETE, /* remove a trace/stop */ ! 60: O_DUMP, /* dump out variables */ ! 61: O_EDIT, /* edit a file (or function) */ ! 62: O_FUNC, /* set the current function */ ! 63: O_GRIPE, /* send mail to debugger support person */ ! 64: O_HELP, /* print a synopsis of debugger commands */ ! 65: O_IGNORE, /* let program catch signal */ ! 66: O_LIST, /* list source lines */ ! 67: O_PRINT, /* print the values of a list of expressions */ ! 68: O_PSYM, /* print symbol information */ ! 69: O_RUN, /* start up program */ ! 70: O_SKIP, /* skip the current line */ ! 71: O_SOURCE, /* read commands from a file */ ! 72: O_STATUS, /* display currently active trace/stop's */ ! 73: O_STEP, /* execute a single line */ ! 74: O_STOP, /* stop on an event */ ! 75: O_STOPI, /* stop on an event at an instruction boundary */ ! 76: O_TRACE, /* trace something on an event */ ! 77: O_TRACEI, /* trace at the instruction level */ ! 78: O_WHATIS, /* print the declaration of a variable */ ! 79: O_WHERE, /* print a stack trace */ ! 80: O_WHEREIS, /* print all the symbols with the given name */ ! 81: O_WHICH, /* print out full qualification of a symbol */ ! 82: O_EXAMINE, /* examine program instructions/data */ ! 83: ! 84: O_ADDEVENT, /* add an event */ ! 85: O_ENDX, /* end of program reached */ ! 86: O_IF, /* if first arg is true, do commands in second arg */ ! 87: O_ONCE, /* add a "one-time" event, delete when first reached */ ! 88: O_PRINTCALL, /* print out the current procedure and its arguments */ ! 89: O_PRINTIFCHANGED, /* print the value of the argument if it has changed */ ! 90: O_PRINTRTN, /* print out the routine and value that just returned */ ! 91: O_PRINTSRCPOS, /* print out the current source position */ ! 92: O_PROCRTN, /* call completed */ ! 93: O_QLINE, /* filename, line number */ ! 94: O_STOPIFCHANGED, /* stop if the value of the argument has changed */ ! 95: O_STOPX, /* stop execution */ ! 96: O_TRACEON, /* begin tracing source line, variable, or all lines */ ! 97: O_TRACEOFF, /* end tracing source line, variable, or all lines */ ! 98: ! 99: O_TYPERENAME, /* state the type of an expression */ ! 100: O_RERUN, /* re-run program with the same arguments as before */ ! 101: O_RETURN, /* continue execution until procedure returns */ ! 102: O_UP, /* move current function up the call stack */ ! 103: O_DOWN, /* move current function down the call stack */ ! 104: O_CALLPROC, /* call command */ ! 105: O_SEARCH, /* regular expression pattern search through source */ ! 106: O_SET, /* set a debugger variable */ ! 107: O_UNSET, /* unset a debugger variable */ ! 108: O_UNALIAS, /* remove an alias */ ! 109: ! 110: O_LASTOP ! 111: } Operator; ! 112: ! 113: /* ! 114: * Operator flags and predicates. ! 115: */ ! 116: ! 117: #define null 0 ! 118: #define LEAF 01 ! 119: #define UNARY 02 ! 120: #define BINARY 04 ! 121: #define BOOL 010 ! 122: #define REALOP 020 ! 123: #define INTOP 040 ! 124: ! 125: #define isbitset(a, m) ((a&m) == m) ! 126: #define isleaf(o) isbitset(opinfo[ord(o)].opflags, LEAF) ! 127: #define isunary(o) isbitset(opinfo[ord(o)].opflags, UNARY) ! 128: #define isbinary(o) isbitset(opinfo[ord(o)].opflags, BINARY) ! 129: #define isreal(o) isbitset(opinfo[ord(o)].opflags, REALOP) ! 130: #define isint(o) isbitset(opinfo[ord(o)].opflags, INTOP) ! 131: #define isboolean(o) isbitset(opinfo[ord(o)].opflags, BOOL) ! 132: ! 133: #define degree(o) (opinfo[ord(o)].opflags&(LEAF|UNARY|BINARY)) ! 134: #define nargs(o) (opinfo[ord(o)].numargs) ! 135: ! 136: #endif ! 137: ! 138: /* ! 139: * Operator information structure. ! 140: */ ! 141: ! 142: public Opinfo opinfo[] ={ ! 143: /* O_NOP */ 0, null, 0, ! 144: /* O_NAME */ -1, LEAF, 0, ! 145: /* O_SYM */ -1, LEAF, 0, ! 146: /* O_LCON */ -1, LEAF, 0, ! 147: /* O_CCON */ -1, LEAF, 0, ! 148: /* O_FCON */ -1, LEAF, 0, ! 149: /* O_SCON */ -1, LEAF, 0, ! 150: /* O_RVAL */ 1, UNARY, 0, ! 151: /* O_INDEX */ 2, null, 0, ! 152: /* O_INDIR */ 1, UNARY, "^", ! 153: /* O_DOT */ 2, null, ".", ! 154: /* O_COMMA */ 2, null, ",", ! 155: /* O_ITOF */ 1, UNARY|INTOP, 0, ! 156: /* O_ADD */ 2, BINARY|INTOP, "+", ! 157: /* O_ADDF */ 2, BINARY|REALOP, "+", ! 158: /* O_SUB */ 2, BINARY|INTOP, "-", ! 159: /* O_SUBF */ 2, BINARY|REALOP, "-", ! 160: /* O_NEG */ 1, UNARY|INTOP, "-", ! 161: /* O_NEGF */ 1, UNARY|REALOP, "-", ! 162: /* O_MUL */ 2, BINARY|INTOP, "*", ! 163: /* O_MULF */ 2, BINARY|REALOP, "*", ! 164: /* O_DIVF */ 2, BINARY|REALOP, "/", ! 165: /* O_DIV */ 2, BINARY|INTOP, " div ", ! 166: /* O_MOD */ 2, BINARY|INTOP, " mod ", ! 167: /* O_AND */ 2, BINARY|INTOP, " and ", ! 168: /* O_OR */ 2, BINARY|INTOP, " or ", ! 169: /* O_LT */ 2, BINARY|INTOP, " < ", ! 170: /* O_LTF */ 2, BINARY|REALOP, " < ", ! 171: /* O_LE */ 2, BINARY|INTOP, " <= ", ! 172: /* O_LEF */ 2, BINARY|REALOP, " <= ", ! 173: /* O_GT */ 2, BINARY|INTOP, " > ", ! 174: /* O_GTF */ 2, BINARY|REALOP, " > ", ! 175: /* O_GE */ 2, BINARY|INTOP, " >= ", ! 176: /* O_GEF */ 2, BINARY|REALOP, " >= ", ! 177: /* O_EQ */ 2, BINARY|INTOP, " = ", ! 178: /* O_EQF */ 2, BINARY|REALOP, " = ", ! 179: /* O_NE */ 2, BINARY|INTOP, " <> ", ! 180: /* O_NEF */ 2, BINARY|REALOP, " <> ", ! 181: ! 182: /* O_ALIAS */ 2, null, "alias", ! 183: /* O_ASSIGN */ 2, null, " := ", ! 184: /* O_CALL */ 2, null, "call", ! 185: /* O_CATCH */ 0, null, "catch", ! 186: /* O_CHFILE */ 0, null, "file", ! 187: /* O_CONT */ 0, null, "cont", ! 188: /* O_DEBUG */ 0, null, "debug", ! 189: /* O_DELETE */ 1, null, "delete", ! 190: /* O_DUMP */ 1, null, "dump", ! 191: /* O_EDIT */ 0, null, "edit", ! 192: /* O_FUNC */ 1, null, "func", ! 193: /* O_GRIPE */ 0, null, "gripe", ! 194: /* O_HELP */ 0, null, "help", ! 195: /* O_IGNORE */ 0, null, "ignore", ! 196: /* O_LIST */ 2, null, "list", ! 197: /* O_PRINT */ 1, null, "print", ! 198: /* O_PSYM */ 1, null, "psym", ! 199: /* O_RUN */ 0, null, "run", ! 200: /* O_SKIP */ 0, null, "skip", ! 201: /* O_SOURCE */ 0, null, "source", ! 202: /* O_STATUS */ 0, null, "status", ! 203: /* O_STEP */ 0, null, "step", ! 204: /* O_STOP */ 3, null, "stop", ! 205: /* O_STOPI */ 3, null, "stopi", ! 206: /* O_TRACE */ 3, null, "trace", ! 207: /* O_TRACEI */ 3, null, "tracei", ! 208: /* O_WHATIS */ 1, null, "whatis", ! 209: /* O_WHERE */ 0, null, "where", ! 210: /* O_WHEREIS */ 1, null, "whereis", ! 211: /* O_WHICH */ 1, null, "which", ! 212: /* O_EXAMINE */ 0, null, "examine", ! 213: ! 214: /* O_ADDEVENT */ 0, null, "when", ! 215: /* O_ENDX */ 0, null, nil, ! 216: /* O_IF */ 0, null, "if", ! 217: /* O_ONCE */ 0, null, "once", ! 218: /* O_PRINTCALL */ 1, null, "printcall", ! 219: /* O_PRINTIFCHANGED */ 1, null, "printifchanged", ! 220: /* O_PRINTRTN */ 1, null, "printrtn", ! 221: /* O_PRINTSRCPOS */ 1, null, "printsrcpos", ! 222: /* O_PROCRTN */ 1, null, "procrtn", ! 223: /* O_QLINE */ 2, null, nil, ! 224: /* O_STOPIFCHANGED */ 1, null, "stopifchanged", ! 225: /* O_STOPX */ 0, null, "stop", ! 226: /* O_TRACEON */ 1, null, "traceon", ! 227: /* O_TRACEOFF */ 1, null, "traceoff", ! 228: /* O_TYPERENAME */ 2, UNARY, "type rename", ! 229: /* O_RERUN */ 0, null, "rerun", ! 230: /* O_RETURN */ 1, null, "return", ! 231: /* O_UP */ 1, UNARY, "up", ! 232: /* O_DOWN */ 1, UNARY, "down", ! 233: /* O_CALLPROC */ 2, null, "call", ! 234: /* O_SEARCH */ 2, null, "search", ! 235: /* O_SET */ 2, null, "set", ! 236: /* O_UNSET */ 1, null, "unset", ! 237: /* O_UNALIAS */ 1, null, "unalias", ! 238: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.