operators.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef operators_h
  2. #define operators_h
  3. typedef struct {
  4. char numargs;
  5. char opflags;
  6. String opstring;
  7. } Opinfo;
  8. typedef enum {
  9. O_NOP,
  10. O_NAME, O_SYM, O_LCON, O_FCON, O_SCON,
  11. O_RVAL, O_INDEX, O_INDIR, O_DOT,
  12. O_COMMA,
  13. O_ITOF, O_ADD, O_ADDF, O_SUB, O_SUBF, O_NEG, O_NEGF,
  14. O_MUL, O_MULF, O_DIVF, O_DIV, O_MOD,
  15. O_AND, O_OR,
  16. O_LT, O_LTF, O_LE, O_LEF, O_GT, O_GTF, O_GE, O_GEF,
  17. O_EQ, O_EQF, O_NE, O_NEF,
  18. O_ALIAS, /* rename a command */
  19. O_ASSIGN, /* assign a value to a program variable */
  20. O_CALL, /* call a procedure in the program */
  21. O_CATCH, /* catch a signal before program does */
  22. O_CHFILE, /* change (or print) the current source file */
  23. O_CONT, /* continue execution */
  24. O_DEBUG, /* invoke a dbx internal debugging routine */
  25. O_DELETE, /* remove a trace/stop */
  26. O_DUMP, /* dump out variables */
  27. O_EDIT, /* edit a file (or function) */
  28. O_FUNC, /* set the current function */
  29. O_GRIPE, /* send mail to debugger support person */
  30. O_HELP, /* print a synopsis of debugger commands */
  31. O_IGNORE, /* let program catch signal */
  32. O_LIST, /* list source lines */
  33. O_PRINT, /* print the values of a list of expressions */
  34. O_PSYM, /* print symbol information */
  35. O_RUN, /* start up program */
  36. O_SKIP, /* skip the current line */
  37. O_SOURCE, /* read commands from a file */
  38. O_STATUS, /* display currently active trace/stop's */
  39. O_STEP, /* execute a single line */
  40. O_STOP, /* stop on an event */
  41. O_STOPI, /* stop on an event at an instruction boundary */
  42. O_TRACE, /* trace something on an event */
  43. O_TRACEI, /* trace at the instruction level */
  44. O_WHATIS, /* print the declaration of a variable */
  45. O_WHERE, /* print a stack trace */
  46. O_WHEREIS, /* print all the symbols with the given name */
  47. O_WHICH, /* print out full qualification of a symbol */
  48. O_EXAMINE, /* examine program instructions/data */
  49. O_ADDEVENT, /* add an event */
  50. O_ENDX, /* end of program reached */
  51. O_IF, /* if first arg is true, do commands in second arg */
  52. O_ONCE, /* add a "one-time" event, delete when first reached */
  53. O_PRINTCALL, /* print out the current procedure and its arguments */
  54. O_PRINTIFCHANGED, /* print the value of the argument if it has changed */
  55. O_PRINTRTN, /* print out the routine and value that just returned */
  56. O_PRINTSRCPOS, /* print out the current source position */
  57. O_PROCRTN, /* CALLPROC completed */
  58. O_QLINE, /* filename, line number */
  59. O_STOPIFCHANGED, /* stop if the value of the argument has changed */
  60. O_STOPX, /* stop execution */
  61. O_TRACEON, /* begin tracing source line, variable, or all lines */
  62. O_TRACEOFF, /* end tracing source line, variable, or all lines */
  63. O_TYPERENAME, /* state the type of an expression */
  64. O_LASTOP
  65. } Operator;
  66. /*
  67. * Operator flags and predicates.
  68. */
  69. #define null 0
  70. #define LEAF 01
  71. #define UNARY 02
  72. #define BINARY 04
  73. #define BOOL 010
  74. #define REALOP 020
  75. #define INTOP 040
  76. #define isbitset(a, m) ((a&m) == m)
  77. #define isleaf(o) isbitset(opinfo[ord(o)].opflags, LEAF)
  78. #define isunary(o) isbitset(opinfo[ord(o)].opflags, UNARY)
  79. #define isbinary(o) isbitset(opinfo[ord(o)].opflags, BINARY)
  80. #define isreal(o) isbitset(opinfo[ord(o)].opflags, REALOP)
  81. #define isint(o) isbitset(opinfo[ord(o)].opflags, INTOP)
  82. #define isboolean(o) isbitset(opinfo[ord(o)].opflags, BOOL)
  83. #define degree(o) (opinfo[ord(o)].opflags&(LEAF|UNARY|BINARY))
  84. #define nargs(o) (opinfo[ord(o)].numargs)
  85. Opinfo opinfo[] ;
  86. #endif