1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
   2: 
   3: /*
   4:   $Header: b3tra.c,v 1.4 85/08/22 16:59:43 timo Exp $
   5: */
   6: 
   7: /* Trace facility for interpreter */
   8: 
   9: #include "b.h"
  10: #include "b0fea.h"
  11: #include "b1obj.h"
  12: #include "b2nod.h"
  13: #include "b3err.h" /* For 'tracing' */
  14: #include "b3int.h"
  15: 
  16: #ifdef EXT_COMMAND
  17: 
  18: Visible Procedure tr_on() {
  19:     tracing= Yes;
  20: }
  21: 
  22: Visible Procedure tr_off() {
  23:     tracing= No;
  24: }
  25: 
  26: #endif EXT_COMMAND
  27: 
  28: Visible string opcodes[] = {
  29:     "HOW_TO",
  30:     "YIELD",
  31:     "TEST",
  32:     "REFINEMENT",
  33: 
  34: /* Commands */
  35: 
  36:     "SUITE",
  37:     "PUT",
  38:     "INSERT",
  39:     "REMOVE",
  40:     "CHOOSE",
  41:     "DRAW",
  42:     "SET_RANDOM",
  43:     "DELETE",
  44:     "CHECK",
  45:     "SHARE",
  46: 
  47:     "WRITE",
  48:     "READ",
  49:     "READ_RAW",
  50: 
  51:     "IF",
  52:     "WHILE",
  53:     "FOR",
  54: 
  55:     "SELECT",
  56:     "TEST_SUITE",
  57:     "ELSE",
  58: 
  59:     "QUIT",
  60:     "RETURN",
  61:     "REPORT",
  62:     "SUCCEED",
  63:     "FAIL",
  64: 
  65:     "USER_COMMAND",
  66:     "EXTENDED_COMMAND",
  67: 
  68: /* Expressions, targets, tests */
  69: 
  70:     "TAG",
  71:     "COMPOUND",
  72: 
  73: /* Expressions, targets */
  74: 
  75:     "COLLATERAL",
  76:     "SELECTION",
  77:     "BEHEAD",
  78:     "CURTAIL",
  79: 
  80: /* Expressions, tests */
  81: 
  82:     "UNPARSED",
  83: 
  84: /* Expressions */
  85: 
  86:     "MONF",
  87:     "DYAF",
  88:     "NUMBER",
  89:     "TEXT_DIS",
  90:     "TEXT_LIT",
  91:     "TEXT_CONV",
  92:     "ELT_DIS",
  93:     "LIST_DIS",
  94:     "RANGE_DIS",
  95:     "TAB_DIS",
  96: 
  97: /* Tests */
  98: 
  99:     "AND",
 100:     "OR",
 101:     "NOT",
 102:     "SOME_IN",
 103:     "EACH_IN",
 104:     "NO_IN",
 105:     "SOME_PARSING",
 106:     "EACH_PARSING",
 107:     "NO_PARSING",
 108:     "MONPRD",
 109:     "DYAPRD",
 110:     "LESS_THAN",
 111:     "AT_MOST",
 112:     "GREATER_THAN",
 113:     "AT_LEAST",
 114:     "EQUAL",
 115:     "UNEQUAL",
 116:     "Nonode",
 117: 
 118:     "TAGformal",
 119:     "TAGlocal",
 120:     "TAGglobal",
 121:     "TAGmystery",
 122:     "TAGrefinement",
 123:     "TAGzerfun",
 124:     "TAGzerprd",
 125: };
 126: 
 127: #define NOPCODES ((sizeof opcodes) / (sizeof opcodes[0]))
 128: 
 129: Visible Procedure tr_node(p) parsetree p; {
 130:     int n;
 131:     fprintf(stderr, "*** %8x ", p);
 132:     if (p == Halt)
 133:         fprintf(stderr, "Halt\r\n");
 134:     else if (p == Stop)
 135:         fprintf(stderr, "Stop\r\n");
 136:     else if (!Is_parsetree(p)) {
 137:         if (IsSmallInt(p))
 138:             fprintf(stderr, "Error %d\r\n", SmallIntVal(p));
 139:         else
 140:             fprintf(stderr, "Trace bad node\r\n");
 141:     }
 142:     else {
 143:         n= Nodetype(p);
 144:         if (n < 0 || n >= NOPCODES)
 145:             fprintf(stderr, "Opcode %d", n);
 146:         else
 147:             fprintf(stderr, "%s", opcodes[n]);
 148:         if (Thread2(p))
 149:             fprintf(stderr, " [*]");
 150:         fprintf(stderr, "\r\n");
 151:     }
 152: }
 153: 
 154: Visible Procedure tr_jump() {
 155:     fprintf(stderr, "*** Jump\r\n");
 156: }
 157: 
 158: Visible Procedure tr_call() {
 159:     fprintf(stderr, "*** Call\r\n");
 160: }
 161: 
 162: Visible Procedure tr_ret() {
 163:     fprintf(stderr, "*** Return\r\n");
 164: }

Defined functions

tr_call defined in line 158; used 1 times
tr_jump defined in line 154; used 1 times
tr_node defined in line 129; used 1 times
tr_off defined in line 22; never used
tr_on defined in line 18; never used
tr_ret defined in line 162; used 1 times

Defined variables

opcodes defined in line 28; used 4 times

Defined macros

NOPCODES defined in line 127; used 1 times
Last modified: 1985-08-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1061
Valid CSS Valid XHTML 1.0 Strict