home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / language / perl / Source / H / Cmd < prev    next >
Encoding:
Text File  |  1990-11-11  |  5.3 KB  |  185 lines

  1. /* $Header: cmd.h,v 3.0.1.4 90/10/15 15:34:50 lwall Locked $
  2.  *
  3.  *    Copyright (c) 1989, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of the GNU General Public License
  6.  *    as specified in the README file that comes with the perl 3.0 kit.
  7.  *
  8.  * $Log:    cmd.h,v $
  9.  * Revision 3.0.1.4  90/10/15  15:34:50  lwall
  10.  * patch29: scripts now run at almost full speed under the debugger
  11.  * patch29: added caller
  12.  * 
  13.  * Revision 3.0.1.3  90/08/09  02:29:58  lwall
  14.  * patch19: did preliminary work toward debugging packages and evals
  15.  * 
  16.  * Revision 3.0.1.2  90/02/28  16:39:36  lwall
  17.  * patch9: volatilized some more variables for super-optimizing compilers
  18.  * 
  19.  * Revision 3.0.1.1  89/10/26  23:05:43  lwall
  20.  * patch1: unless was broken when run under the debugger
  21.  * 
  22.  * Revision 3.0  89/10/18  15:09:15  lwall
  23.  * 3.0 baseline
  24.  * 
  25.  */
  26.  
  27. #define C_NULL 0
  28. #define C_IF 1
  29. #define C_ELSE 2
  30. #define C_WHILE 3
  31. #define C_BLOCK 4
  32. #define C_EXPR 5
  33. #define C_NEXT 6
  34. #define C_ELSIF 7    /* temporary--turns into an IF + ELSE */
  35. #define C_CSWITCH 8    /* created by switch optimization in block_head() */
  36. #define C_NSWITCH 9    /* likewise */
  37.  
  38. #ifdef DEBUGGING
  39. #ifndef DOINIT
  40. extern char *cmdname[];
  41. #else
  42. char *cmdname[] = {
  43.     "NULL",
  44.     "IF",
  45.     "ELSE",
  46.     "WHILE",
  47.     "BLOCK",
  48.     "EXPR",
  49.     "NEXT",
  50.     "ELSIF",
  51.     "CSWITCH",
  52.     "NSWITCH",
  53.     "10"
  54. };
  55. #endif
  56. #endif /* DEBUGGING */
  57.  
  58. #define CF_OPTIMIZE 077    /* type of optimization */
  59. #define CF_FIRSTNEG 0100/* conditional is ($register NE 'string') */
  60. #define CF_NESURE 0200    /* if short doesn't match we're sure */
  61. #define CF_EQSURE 0400    /* if short does match we're sure */
  62. #define CF_COND    01000    /* test c_expr as conditional first, if not null. */
  63.             /* Set for everything except do {} while currently */
  64. #define CF_LOOP 02000    /* loop on the c_expr conditional (loop modifiers) */
  65. #define CF_INVERT 04000    /* it's an "unless" or an "until" */
  66. #define CF_ONCE 010000    /* we've already pushed the label on the stack */
  67. #define CF_FLIP 020000    /* on a match do flipflop */
  68. #define CF_TERM 040000    /* value of this cmd might be returned */
  69. #define CF_DBSUB 0100000 /* this is an inserted cmd for debugging */
  70.  
  71. #define CFT_FALSE 0    /* c_expr is always false */
  72. #define CFT_TRUE 1    /* c_expr is always true */
  73. #define CFT_REG 2    /* c_expr is a simple register */
  74. #define CFT_ANCHOR 3    /* c_expr is an anchored search /^.../ */
  75. #define CFT_STROP 4    /* c_expr is a string comparison */
  76. #define CFT_SCAN 5    /* c_expr is an unanchored search /.../ */
  77. #define CFT_GETS 6    /* c_expr is <filehandle> */
  78. #define CFT_EVAL 7    /* c_expr is not optimized, so call eval() */
  79. #define CFT_UNFLIP 8    /* 2nd half of range not optimized */
  80. #define CFT_CHOP 9    /* c_expr is a chop on a register */
  81. #define CFT_ARRAY 10    /* this is a foreach loop */
  82. #define CFT_INDGETS 11    /* c_expr is <$variable> */
  83. #define CFT_NUMOP 12    /* c_expr is a numeric comparison */
  84. #define CFT_CCLASS 13    /* c_expr must start with one of these characters */
  85. #define CFT_D0 14    /* no special breakpoint at this line */
  86. #define CFT_D1 15    /* possible special breakpoint at this line */
  87.  
  88. #ifdef DEBUGGING
  89. #ifndef DOINIT
  90. extern char *cmdopt[];
  91. #else
  92. char *cmdopt[] = {
  93.     "FALSE",
  94.     "TRUE",
  95.     "REG",
  96.     "ANCHOR",
  97.     "STROP",
  98.     "SCAN",
  99.     "GETS",
  100.     "EVAL",
  101.     "UNFLIP",
  102.     "CHOP",
  103.     "ARRAY",
  104.     "INDGETS",
  105.     "NUMOP",
  106.     "CCLASS",
  107.     "14"
  108. };
  109. #endif
  110. #endif /* DEBUGGING */
  111.  
  112. struct acmd {
  113.     STAB    *ac_stab;    /* a symbol table entry */
  114.     ARG        *ac_expr;    /* any associated expression */
  115. };
  116.  
  117. struct ccmd {
  118.     CMD        *cc_true;    /* normal code to do on if and while */
  119.     CMD        *cc_alt;    /* else cmd ptr or continue code */
  120. };
  121.  
  122. struct scmd {
  123.     CMD        **sc_next;    /* array of pointers to commands */
  124.     short    sc_offset;    /* first value - 1 */
  125.     short    sc_max;        /* last value + 1 */
  126. };
  127.  
  128. struct cmd {
  129.     CMD        *c_next;    /* the next command at this level */
  130.     ARG        *c_expr;    /* conditional expression */
  131.     CMD        *c_head;    /* head of this command list */
  132.     STR        *c_short;    /* string to match as shortcut */
  133.     STAB    *c_stab;    /* a symbol table entry, mostly for fp */
  134.     SPAT    *c_spat;    /* pattern used by optimization */
  135.     char    *c_label;    /* label for this construct */
  136.     union ucmd {
  137.     struct acmd acmd;    /* normal command */
  138.     struct ccmd ccmd;    /* compound command */
  139.     struct scmd scmd;    /* switch command */
  140.     } ucmd;
  141.     short    c_slen;        /* len of c_short, if not null */
  142.     VOLATILE short c_flags;    /* optimization flags--see above */
  143.     HASH    *c_stash;    /* package line was compiled in */
  144.     STAB    *c_filestab;    /* file the following line # is from */
  145.     line_t      c_line;         /* line # of this command */
  146.     char    c_type;        /* what this command does */
  147. };
  148.  
  149. #define Nullcmd Null(CMD*)
  150. #define Nullcsv Null(CSV*)
  151.  
  152. EXT CMD * VOLATILE main_root INIT(Nullcmd);
  153. EXT CMD * VOLATILE eval_root INIT(Nullcmd);
  154.  
  155. EXT CMD compiling;
  156. EXT CMD * VOLATILE curcmd INIT(&compiling);
  157. EXT CSV * VOLATILE curcsv INIT(Nullcsv);
  158.  
  159. struct callsave {
  160.     SUBR *sub;
  161.     STAB *stab;
  162.     CSV *curcsv;
  163.     CMD *curcmd;
  164.     ARRAY *savearray;
  165.     ARRAY *argarray;
  166.     long depth;
  167.     int wantarray;
  168.     char hasargs;
  169. };
  170.  
  171. struct compcmd {
  172.     CMD *comp_true;
  173.     CMD *comp_alt;
  174. };
  175.  
  176. extern void opt_arg PROTO((CMD *, int, int));
  177. extern void evalstatic PROTO((ARG *));
  178. extern int cmd_exec PROTO((CMD *, int, int));
  179. extern int copyopt PROTO((CMD *, CMD *));
  180. extern void savenostab PROTO((STAB *));
  181.  
  182. #ifdef DEBUGGING
  183. extern void deb PROTO((char *, ...));
  184. #endif
  185.