Annotation of 43BSDTahoe/lib/old_compiler/dbx/operators.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.