home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / h / rmacros.h < prev    next >
C/C++ Source or Header  |  2002-01-18  |  22KB  |  738 lines

  1. /*
  2.  *  Definitions for macros and manifest constants used in the compiler
  3.  *  interpreter.
  4.  */
  5.  
  6. /*
  7.  *  Definitions common to the compiler and interpreter.
  8.  */
  9.  
  10. /*
  11.  * Constants that are not likely to vary between implementations.
  12.  */
  13.  
  14. #define BitOffMask (IntBits-1)
  15. #define CsetSize (256/IntBits)    /* number of ints to hold 256 cset
  16.                  *  bits. Use (256/IntBits)+1 if
  17.                  *  256 % IntBits != 0 */
  18. #define MinListSlots        8    /* number of elements in an expansion
  19.                  * list element block  */
  20.  
  21. #define MaxCvtLen       257    /* largest string in conversions; the extra
  22.                  *  one is for a terminating null */
  23. #define MaxReadStr       512    /* largest string to read() in one piece */
  24. #define MaxIn          32767    /* largest number of bytes to read() at once */
  25. #define RandA        1103515245    /* random seed multiplier */
  26. #define RandC          453816694    /* random seed additive constant */
  27. #define RanScale 4.65661286e-10    /* random scale factor = 1/(2^31-1) */
  28.  
  29. #define Pi 3.14159265358979323846264338327950288419716939937511
  30.  
  31. /*
  32.  * File status flags in status field of file blocks.
  33.  */
  34. #define Fs_Read         01    /* read access */
  35. #define Fs_Write     02    /* write access */
  36. #define Fs_Create     04    /* file created on open */
  37. #define Fs_Append    010    /* append mode */
  38. #define Fs_Pipe        020    /* reading/writing on a pipe */
  39. #define Fs_Untrans    01000    /* untranslated mode file */
  40. #define Fs_Directory  02000    /* reading a directory */
  41. #define Fs_Reading     0100     /* last file operation was read */
  42. #define Fs_Writing     0200     /* last file operation was write */
  43.  
  44. #ifdef Graphics
  45.    #define Fs_Window   0400    /* reading/writing on a window */
  46.  
  47.    #define XKey_Window 0
  48.    #define XKey_Fg 1
  49.  
  50.    #ifndef SHORT
  51.       #define SHORT int
  52.    #endif                /* SHORT */
  53.    #ifndef LONG
  54.       #define LONG int
  55.    #endif                /* LONG */
  56.  
  57.    /*
  58.     * Perform a "C" return, not processed by RTT
  59.     */
  60.    #define VanquishReturn(s) return s;
  61. #endif                    /* Graphics */
  62.  
  63. /*
  64.  * Codes returned by runtime support routines.
  65.  *  Note, some conversion routines also return type codes. Other routines may
  66.  *  return positive values other than return codes. sort() places restrictions
  67.  *  on Less, Equal, and Greater.
  68.  */
  69.  
  70. #define Less        -1
  71. #define Equal        0
  72. #define Greater        1
  73.  
  74. #define CvtFail        -2
  75. #define Cvt        -3
  76. #define NoCvt        -4
  77. #define Failed        -5
  78. #define Defaulted    -6
  79. #define Succeeded    -7
  80. #define Error        -8
  81.  
  82. #define GlobalName    0
  83. #define StaticName    1
  84. #define ParamName    2
  85. #define LocalName    3
  86.  
  87. /*
  88.  * Pointer to block.
  89.  */
  90. #define BlkLoc(d)    ((d).vword.bptr)
  91.  
  92. /*
  93.  * Check for null-valued descriptor.
  94.  */
  95. #define ChkNull(d)    ((d).dword==D_Null)
  96.  
  97. /*
  98.  * Check for equivalent descriptors.
  99.  */
  100. #define EqlDesc(d1,d2)    ((d1).dword == (d2).dword && BlkLoc(d1) == BlkLoc(d2))
  101.  
  102. /*
  103.  * Integer value.
  104.  */
  105. #define IntVal(d)    ((d).vword.integr)
  106.  
  107. /*
  108.  * Offset from top of block to value of variable.
  109.  */
  110. #define Offset(d)    ((d).dword & OffsetMask)
  111.  
  112. /*
  113.  * Check for pointer.
  114.  */
  115. #define Pointer(d)    ((d).dword & F_Ptr)
  116.  
  117. /*
  118.  * Check for qualifier.
  119.  */
  120. #define Qual(d)        (!((d).dword & F_Nqual))
  121.  
  122. /*
  123.  * Length of string.
  124.  */
  125. #define StrLen(q)    ((q).dword)
  126.  
  127. /*
  128.  * Location of first character of string.
  129.  */
  130. #define StrLoc(q)    ((q).vword.sptr)
  131.  
  132. /*
  133.  * Assign a C string to a descriptor. Assume it is reasonable to use the
  134.  *   descriptor expression more than once, but not the string expression.
  135.  */
  136. #define AsgnCStr(d,s) (StrLoc(d) = (s), StrLen(d) = strlen(StrLoc(d)))
  137.  
  138. /*
  139.  * Type of descriptor.
  140.  */
  141. #define Type(d)        (int)((d).dword & TypeMask)
  142.  
  143. /*
  144.  * Check for variable.
  145.  */
  146. #define Var(d)        ((d).dword & F_Var)
  147.  
  148. /*
  149.  * Location of the value of a variable.
  150.  */
  151. #define VarLoc(d)    ((d).vword.descptr)
  152.  
  153. /*
  154.  *  Important note:  The code that follows is not strictly legal C.
  155.  *   It tests to see if pointer p2 is between p1 and p3. This may
  156.  *   involve the comparison of pointers in different arrays, which
  157.  *   is not well-defined.  The casts of these pointers to unsigned "words"
  158.  *   (longs or ints, depending) works with all C compilers and architectures
  159.  *   on which Icon has been implemented.  However, it is possible it will
  160.  *   not work on some system.  If it doesn't, there may be a "false
  161.  *   positive" test, which is likely to cause a memory violation or a
  162.  *   loop. It is not practical to implement Icon on a system on which this
  163.  *   happens.
  164.  */
  165.  
  166. #define InRange(p1,p2,p3) ((uword)(p2) >= (uword)(p1) && (uword)(p2) < (uword)(p3))
  167.  
  168. /*
  169.  * Get floating-point number from real block.
  170.  */
  171. #ifdef Double
  172.    #define GetReal(dp,res) *((struct size_dbl *)&(res)) =\
  173.          *((struct size_dbl *)&(BlkLoc(*dp)->realblk.realval))
  174. #else                    /* Double */
  175.    #define GetReal(dp,res)    res = BlkLoc(*dp)->realblk.realval
  176. #endif                    /* Double */
  177.  
  178. /*
  179.  * Absolute value, maximum, and minimum.
  180.  * N.B. UNSAFE MACROS: may evaluate arguments multiple times.
  181.  */
  182. #define Abs(x)        (((x) < 0) ? (-(x)) : (x))
  183. #define Max(x,y)        ((x)>(y)?(x):(y))
  184. #define Min(x,y)        ((x)<(y)?(x):(y))
  185.  
  186. /*
  187.  * Number of elements of a C array, and element size.
  188.  */
  189. #define ElemCount(a) (sizeof(a)/sizeof(a[0]))
  190. #define ElemSize(a) (sizeof(a[0]))
  191.  
  192. /*
  193.  * Construct an integer descriptor.
  194.  */
  195. #define MakeInt(i,dp)        do { \
  196.              (dp)->dword = D_Integer; \
  197.              IntVal(*dp) = (word)(i); \
  198.              } while (0)
  199.  
  200. /*
  201.  * Construct a string descriptor.
  202.  */
  203. #define MakeStr(s,len,dp)      do { \
  204.              StrLoc(*dp) = (s); \
  205.              StrLen(*dp) = (len); \
  206.              } while (0)
  207.  
  208. /*
  209.  * Offset in word of cset bit.
  210.  */
  211. #define CsetOff(b)    ((b) & BitOffMask)
  212.  
  213. /*
  214.  * Set bit b in cset c.
  215.  */
  216. #define Setb(b,c)    (*CsetPtr(b,c) |= (01 << CsetOff(b)))
  217.  
  218. /*
  219.  * Test bit b in cset c.
  220.  */
  221. #define Testb(b,c)    ((*CsetPtr(b,c) >> CsetOff(b)) & 01)
  222.  
  223. /*
  224.  * Check whether a set or table needs resizing.
  225.  */
  226. #define SP(p) ((struct b_set *)p)
  227. #define TooCrowded(p) \
  228.    ((SP(p)->size > MaxHLoad*(SP(p)->mask+1)) && (SP(p)->hdir[HSegs-1] == NULL))
  229. #define TooSparse(p) \
  230.    ((SP(p)->hdir[1] != NULL) && (SP(p)->size < MinHLoad*(SP(p)->mask+1)))
  231.  
  232. /*
  233.  * Definitions and declarations used for storage management.
  234.  */
  235. #define F_Mark        0100000        /* bit for marking blocks */
  236.  
  237. /*
  238.  * Argument values for the built-in Icon user function "collect()".
  239.  */
  240. #define Static  1            /* collection is for static region */
  241. #define Strings    2            /* collection is for strings */
  242. #define Blocks    3            /* collection is for blocks */
  243.  
  244. /*
  245.  * Get type of block pointed at by x.
  246.  */
  247. #define BlkType(x)   (*(word *)x)
  248.  
  249. /*
  250.  * BlkSize(x) takes the block pointed to by x and if the size of
  251.  *  the block as indicated by bsizes[] is nonzero it returns the
  252.  *  indicated size; otherwise it returns the second word in the
  253.  *  block contains the size.
  254.  */
  255. #define BlkSize(x) (bsizes[*(word *)x & ~F_Mark] ? \
  256.              bsizes[*(word *)x & ~F_Mark] : *((word *)x + 1))
  257.  
  258. /*
  259.  * Here are the events we support (in addition to keyboard characters)
  260.  */
  261. #define MOUSELEFT    (-1)
  262. #define MOUSEMID    (-2)
  263. #define MOUSERIGHT    (-3)
  264. #define MOUSELEFTUP    (-4)
  265. #define MOUSEMIDUP    (-5)
  266. #define MOUSERIGHTUP    (-6)
  267. #define MOUSELEFTDRAG    (-7)
  268. #define MOUSEMIDDRAG    (-8)
  269. #define MOUSERIGHTDRAG    (-9)
  270. #define RESIZED        (-10)
  271. #define LASTEVENTCODE    RESIZED
  272.  
  273. /*
  274.  * Type codes (descriptors and blocks).
  275.  */
  276. #define T_String    -1    /* string -- for reference; not used */
  277. #define T_Null         0    /* null value */
  278. #define T_Integer     1    /* integer */
  279.  
  280. #ifdef LargeInts
  281.    #define T_Lrgint     2    /* long integer */
  282. #endif                    /* LargeInts */
  283.  
  284. #define T_Real         3    /* real number */
  285. #define T_Cset         4    /* cset */
  286. #define T_File         5    /* file */
  287. #define T_Proc         6    /* procedure */
  288. #define T_Record     7    /* record */
  289. #define T_List         8    /* list header */
  290. #define T_Lelem         9    /* list element */
  291. #define T_Set        10    /* set header */
  292. #define T_Selem        11    /* set element */
  293. #define T_Table        12    /* table header */
  294. #define T_Telem        13    /* table element */
  295. #define T_Tvtbl        14    /* table element trapped variable */
  296. #define T_Slots        15    /* set/table hash slots */
  297. #define T_Tvsubs    16    /* substring trapped variable */
  298. #define T_Refresh    17    /* refresh block */
  299. #define T_Coexpr    18    /* co-expression */
  300. #define T_External    19    /* external block */
  301. #define T_Kywdint    20    /* integer keyword */
  302. #define T_Kywdpos    21    /* keyword &pos */
  303. #define T_Kywdsubj    22    /* keyword &subject */
  304. #define T_Kywdwin    23    /* keyword &window */
  305. #define T_Kywdstr    24    /* string keyword */
  306. #define T_Kywdevent    25    /* keyword &eventsource, etc. */
  307.  
  308. #define MaxType        26    /* maximum type number */
  309.  
  310. /*
  311.  * Definitions for keywords.
  312.  */
  313.  
  314. #define k_pos kywd_pos.vword.integr    /* value of &pos */
  315. #define k_random kywd_ran.vword.integr    /* value of &random */
  316. #define k_trace kywd_trc.vword.integr    /* value of &trace */
  317. #define k_dump kywd_dmp.vword.integr    /* value of &dump */
  318.  
  319. #ifdef FncTrace
  320.    #define k_ftrace kywd_ftrc.vword.integr    /* value of &ftrace */
  321. #endif                    /* FncTrace */
  322.  
  323. /*
  324.  * Descriptor types and flags.
  325.  */
  326.  
  327. #define D_Null        (T_Null     | D_Typecode)
  328. #define D_Integer    (T_Integer  | D_Typecode)
  329.  
  330. #ifdef LargeInts
  331.    #define D_Lrgint    (T_Lrgint | D_Typecode | F_Ptr)
  332. #endif                    /* LargeInts */
  333.  
  334. #define D_Real        (T_Real     | D_Typecode | F_Ptr)
  335. #define D_Cset        (T_Cset     | D_Typecode | F_Ptr)
  336. #define D_File        (T_File     | D_Typecode | F_Ptr)
  337. #define D_Proc        (T_Proc     | D_Typecode | F_Ptr)
  338. #define D_List        (T_List     | D_Typecode | F_Ptr)
  339. #define D_Lelem        (T_Lelem    | D_Typecode | F_Ptr)
  340. #define D_Table        (T_Table    | D_Typecode | F_Ptr)
  341. #define D_Telem        (T_Telem    | D_Typecode | F_Ptr)
  342. #define D_Set        (T_Set      | D_Typecode | F_Ptr)
  343. #define D_Selem        (T_Selem    | D_Typecode | F_Ptr)
  344. #define D_Record    (T_Record   | D_Typecode | F_Ptr)
  345. #define D_Tvsubs    (T_Tvsubs   | D_Typecode | F_Ptr | F_Var)
  346. #define D_Tvtbl        (T_Tvtbl    | D_Typecode | F_Ptr | F_Var)
  347. #define D_Kywdint    (T_Kywdint  | D_Typecode | F_Ptr | F_Var)
  348. #define D_Kywdpos    (T_Kywdpos  | D_Typecode | F_Ptr | F_Var)
  349. #define D_Kywdsubj    (T_Kywdsubj | D_Typecode | F_Ptr | F_Var)
  350. #define D_Refresh    (T_Refresh  | D_Typecode | F_Ptr)
  351. #define D_Coexpr    (T_Coexpr   | D_Typecode | F_Ptr)
  352. #define D_External    (T_External | D_Typecode | F_Ptr)
  353. #define D_Slots        (T_Slots    | D_Typecode | F_Ptr)
  354. #define D_Kywdwin    (T_Kywdwin  | D_Typecode | F_Ptr | F_Var)
  355. #define D_Kywdstr    (T_Kywdstr  | D_Typecode | F_Ptr | F_Var)
  356. #define D_Kywdevent    (T_Kywdevent| D_Typecode | F_Ptr | F_Var)
  357.  
  358. #define D_Var        (F_Var | F_Nqual | F_Ptr)
  359. #define D_Typecode    (F_Nqual | F_Typecode)
  360.  
  361. #define TypeMask    63    /* type mask */
  362. #define OffsetMask    (~(D_Var)) /* offset mask for variables */
  363.  
  364. /*
  365.  * "In place" dereferencing.
  366.  */
  367. #define Deref(d) if (Var(d)) deref(&d, &d)
  368.  
  369. /*
  370.  * Construct a substring trapped variable.
  371.  */
  372. #define SubStr(dest,var,len,pos)\
  373.    if ((var)->dword == D_Tvsubs)\
  374.       (dest)->vword.bptr = (union block *)alcsubs(len, (pos) +\
  375.          BlkLoc(*(var))->tvsubs.sspos - 1, &BlkLoc(*(var))->tvsubs.ssvar);\
  376.    else\
  377.       (dest)->vword.bptr = (union block *)alcsubs(len, pos, (var));\
  378.    (dest)->dword = D_Tvsubs;
  379.  
  380. /*
  381.  * Find debug struct in procedure frame, assuming debugging is enabled.
  382.  *  Note that there is always one descriptor in array even if it is not
  383.  *  being used.
  384.  */
  385. #define PFDebug(pf) ((struct debug *)((char *)(pf).tend.d +\
  386.    sizeof(struct descrip) * ((pf).tend.num ? (pf).tend.num : 1)))
  387.  
  388. /*
  389.  * Macro for initialized procedure block.
  390.  */
  391. #define B_IProc(n) struct {word title; word blksize; int (*ccode)();\
  392.    word nparam; word ndynam; word nstatic; word fstatic;\
  393.    struct sdescrip quals[n];}
  394.  
  395. #define ssize    (curstring->size)
  396. #define strbase  (curstring->base)
  397. #define strend   (curstring->end)
  398. #define strfree  (curstring->free)
  399.  
  400. #define abrsize  (curblock->size)
  401. #define blkbase  (curblock->base)
  402. #define blkend   (curblock->end)
  403. #define blkfree  (curblock->free)
  404.  
  405. #if COMPILER
  406.  
  407.    #ifdef Graphics
  408.       #define Poll() if (!pollctr--) pollctr = pollevent()
  409.    #else                /* Graphics */
  410.       #define Poll()
  411.    #endif                /* Graphics */
  412.  
  413. #else                    /* COMPILER */
  414.  
  415.    /*
  416.     * Definitions for the interpreter.
  417.     */
  418.  
  419.    /*
  420.     * Codes returned by invoke to indicate action.
  421.     */
  422.    #define I_Builtin    201    /* A built-in routine is to be invoked */
  423.    #define I_Fail    202    /* goal-directed evaluation failed */
  424.    #define I_Continue    203    /* Continue execution in the interp loop */
  425.    #define I_Vararg    204    /* A function with a variable number of args */
  426.  
  427.    /*
  428.     * Generator types.
  429.     */
  430.    #define G_Csusp        1
  431.    #define G_Esusp        2
  432.    #define G_Psusp        3
  433.    #define G_Fsusp        4
  434.    #define G_Osusp        5
  435.  
  436.    /*
  437.     * Evaluation stack overflow margin
  438.     */
  439.    #define PerilDelta 100
  440.  
  441.    /*
  442.     * Macro definitions related to descriptors.
  443.     */
  444.  
  445.    /*
  446.     * The following code is operating-system dependent [@rt.01].  Define
  447.     *  PushAval for computers that store longs and pointers differently.
  448.     */
  449.  
  450.    #if PORT
  451.       #define PushAVal(x) PushVal(x)
  452.       Deliberate Syntax Error
  453.    #endif                /* PORT */
  454.  
  455.    #if AMIGA || ARM || MACINTOSH || UNIX || VMS
  456.       #define PushAVal(x) PushVal(x)
  457.    #endif                /* AMIGA || ARM || ... */
  458.  
  459.    #if MSDOS || OS2
  460.       #if HIGHC_386 || ZTC_386 || INTEL_386 || WATCOM || BORLAND_386 || SCCX_MX
  461.          #define PushAVal(x) PushVal(x)
  462.       #else                /* HIGHC_386 || ZTC_386 || ... */
  463.          static union {
  464.                pointer stkadr;
  465.                word stkint;
  466.             } stkword;
  467.  
  468.          #define PushAVal(x)  {sp++; \
  469.                 stkword.stkadr = (char *)(x); \
  470.                 *sp = stkword.stkint;}
  471.       #endif                /* HIGHC_386 || ZTC_386 || ... */
  472.    #endif                /* MSDOS || OS2 */
  473.  
  474.    /*
  475.     * End of operating-system specific code.
  476.     */
  477.  
  478.    /*
  479.     * Macros for pushing values on the interpreter stack.
  480.     */
  481.  
  482.    /*
  483.     * Push descriptor.
  484.     */
  485.    #define PushDesc(d)    {*++sp = ((d).dword); sp++;*sp =((d).vword.integr);}
  486.  
  487.    /*
  488.     * Push null-valued descriptor.
  489.     */
  490.    #define PushNull    {*++sp = D_Null; sp++; *sp = 0;}
  491.  
  492.    /*
  493.     * Push word.
  494.     */
  495.    #define PushVal(v)    {*++sp = (word)(v);}
  496.  
  497.    /*
  498.     * Macros related to function and operator definition.
  499.     */
  500.  
  501.    /*
  502.     * Procedure block for a function.
  503.     */
  504.  
  505.    #if VMS
  506.       #define FncBlock(f,nargs,deref) \
  507.          struct b_iproc Cat(B,f) = {\
  508.          T_Proc,\
  509.          Vsizeof(struct b_proc),\
  510.          Cat(Y,f),\
  511.          nargs,\
  512.          -1,\
  513.          deref, 0,\
  514.          {sizeof(Lit(f))-1,Lit(f)}};
  515.    #else                /* VMS */
  516.       #define FncBlock(f,nargs,deref) \
  517.          struct b_iproc Cat(B,f) = {\
  518.          T_Proc,\
  519.          Vsizeof(struct b_proc),\
  520.          Cat(Z,f),\
  521.          nargs,\
  522.          -1,\
  523.          deref, 0,\
  524.          {sizeof(Lit(f))-1,Lit(f)}};
  525.    #endif                /* VMS */
  526.  
  527.    /*
  528.     * Procedure block for an operator.
  529.     */
  530.    #define OpBlock(f,nargs,sname,xtrargs)\
  531.       struct b_iproc Cat(B,f) = {\
  532.       T_Proc,\
  533.       Vsizeof(struct b_proc),\
  534.       Cat(O,f),\
  535.       nargs,\
  536.       -1,\
  537.       xtrargs,\
  538.       0,\
  539.       {sizeof(sname)-1,sname}};
  540.  
  541.    /*
  542.     * Operator declaration.
  543.     */
  544.    #define OpDcl(nm,n,pn) OpBlock(nm,n,pn,0) Cat(O,nm)(cargp) register dptr cargp;
  545.  
  546.    /*
  547.     * Operator declaration with extra working argument.
  548.     */
  549.    #define OpDclE(nm,n,pn) OpBlock(nm,-n,pn,0) Cat(O,nm)(cargp) register dptr cargp;
  550.  
  551.    /*
  552.     * Agent routine declaration.
  553.     */
  554.    #define AgtDcl(nm) Cat(A,nm)(cargp) register dptr cargp;
  555.  
  556.    /*
  557.     * Macros to access Icon arguments in C functions.
  558.     */
  559.  
  560.    /*
  561.     * n-th argument.
  562.     */
  563.    #define Arg(n)    (cargp[n])
  564.  
  565.    /*
  566.     * Type field of n-th argument.
  567.     */
  568.    #define ArgType(n)    (cargp[n].dword)
  569.  
  570.    /*
  571.     * Value field of n-th argument.
  572.     */
  573.    #define ArgVal(n)    (cargp[n].vword.integr)
  574.  
  575.    /*
  576.     * Specific arguments.
  577.     */
  578.    #define Arg0    (cargp[0])
  579.    #define Arg1    (cargp[1])
  580.    #define Arg2    (cargp[2])
  581.    #define Arg3    (cargp[3])
  582.    #define Arg4    (cargp[4])
  583.    #define Arg5    (cargp[5])
  584.    #define Arg6    (cargp[6])
  585.    #define Arg7    (cargp[7])
  586.    #define Arg8    (cargp[8])
  587.  
  588.    /*
  589.     * Miscellaneous macro definitions.
  590.     */
  591.  
  592.    #ifdef MultiThread
  593.       #define glbl_argp (curpstate->Glbl_argp)
  594.       #define kywd_err  (curpstate->Kywd_err)
  595.       #define kywd_pos  (curpstate->Kywd_pos)
  596.       #define kywd_prog  (curpstate->Kywd_prog)
  597.       #define kywd_ran  (curpstate->Kywd_ran)
  598.       #define k_eventcode (curpstate->eventcode)
  599.       #define k_eventsource (curpstate->eventsource)
  600.       #define k_eventvalue (curpstate->eventval)
  601.       #define k_subject (curpstate->ksub)
  602.       #define kywd_trc  (curpstate->Kywd_trc)
  603.       #define mainhead (curpstate->Mainhead)
  604.       #define code (curpstate->Code)
  605.       #define ecode (curpstate->Ecode)
  606.       #define records (curpstate->Records)
  607.       #define ftabp (curpstate->Ftabp)
  608.       #ifdef FieldTableCompression
  609.          #define ftabwidth (curpstate->Ftabwidth)
  610.          #define foffwidth (curpstate->Foffwidth)
  611.          #define ftabcp (curpstate->Ftabcp)
  612.          #define ftabsp (curpstate->Ftabsp)
  613.          #define focp (curpstate->Focp)
  614.          #define fosp (curpstate->Fosp)
  615.          #define fo (curpstate->Fo)
  616.          #define bm (curpstate->Bm)
  617.       #endif                /* FieldTableCompression */
  618.       #define fnames (curpstate->Fnames)
  619.       #define efnames (curpstate->Efnames)
  620.       #define globals (curpstate->Globals)
  621.       #define eglobals (curpstate->Eglobals)
  622.       #define gnames (curpstate->Gnames)
  623.       #define egnames (curpstate->Egnames)
  624.       #define statics (curpstate->Statics)
  625.       #define estatics (curpstate->Estatics)
  626.       #define n_globals (curpstate->NGlobals)
  627.       #define n_statics (curpstate->NStatics)
  628.       #define strcons (curpstate->Strcons)
  629.       #define filenms (curpstate->Filenms)
  630.       #define efilenms (curpstate->Efilenms)
  631.       #define ilines (curpstate->Ilines)
  632.       #define elines (curpstate->Elines)
  633.       #define current_line_ptr (curpstate->Current_line_ptr)
  634.  
  635.       #ifdef Graphics
  636.          #define amperX   (curpstate->AmperX)
  637.          #define amperY   (curpstate->AmperY)
  638.          #define amperRow (curpstate->AmperRow)
  639.          #define amperCol (curpstate->AmperCol)
  640.          #define amperInterval (curpstate->AmperInterval)
  641.          #define lastEventWin (curpstate->LastEventWin)
  642.          #define lastEvFWidth (curpstate->LastEvFWidth)
  643.          #define lastEvLeading (curpstate->LastEvLeading)
  644.          #define lastEvAscent (curpstate->LastEvAscent)
  645.          #define kywd_xwin (curpstate->Kywd_xwin)
  646.          #define xmod_control (curpstate->Xmod_Control)
  647.          #define xmod_shift (curpstate->Xmod_Shift)
  648.          #define xmod_meta (curpstate->Xmod_Meta)
  649.       #endif                /* Graphics */
  650.  
  651.       #ifdef EventMon
  652.          #define linenum  (curpstate->Linenum)
  653.          #define column   (curpstate->Column)
  654.          #define lastline (curpstate->Lastline)
  655.          #define lastcol  (curpstate->Lastcol)
  656.       #endif                /* EventMon */
  657.  
  658.       #define coexp_ser (curpstate->Coexp_ser)
  659.       #define list_ser  (curpstate->List_ser)
  660.       #define set_ser   (curpstate->Set_ser)
  661.       #define table_ser (curpstate->Table_ser)
  662.  
  663.       #define curstring (curpstate->stringregion)
  664.       #define curblock  (curpstate->blockregion)
  665.       #define strtotal  (curpstate->stringtotal)
  666.       #define blktotal  (curpstate->blocktotal)
  667.  
  668.       #define coll_tot  (curpstate->colltot)
  669.       #define coll_stat (curpstate->collstat)
  670.       #define coll_str  (curpstate->collstr)
  671.       #define coll_blk  (curpstate->collblk)
  672.  
  673.       #define lastop    (curpstate->Lastop)
  674.       #define lastopnd  (curpstate->Lastopnd)
  675.  
  676.       #define xargp     (curpstate->Xargp)
  677.       #define xnargs    (curpstate->Xnargs)
  678.  
  679.       #define k_current     (curpstate->K_current)
  680.       #define k_errornumber (curpstate->K_errornumber)
  681.       #define k_errortext   (curpstate->K_errortext)
  682.       #define k_errorvalue  (curpstate->K_errorvalue)
  683.       #define have_errval   (curpstate->Have_errval)
  684.       #define t_errornumber (curpstate->T_errornumber)
  685.       #define t_have_val    (curpstate->T_have_val)
  686.       #define t_errorvalue  (curpstate->T_errorvalue)
  687.  
  688.       #define k_main        (curpstate->K_main)
  689.       #define k_errout      (curpstate->K_errout)
  690.       #define k_input       (curpstate->K_input)
  691.       #define k_output      (curpstate->K_output)
  692.  
  693.       #define ENTERPSTATE(p) if (((p)!=NULL)) { curpstate = (p); }
  694.    #endif                /* MultiThread */
  695.  
  696. #endif                    /* COMPILER */
  697.  
  698. /*
  699.  * Constants controlling expression evaluation.
  700.  */
  701. #if COMPILER
  702.    #define A_Resume    -1    /* expression failed: resume a generator */
  703.    #define A_Continue    -2    /* expression returned: continue execution */
  704.    #define A_FallThru    -3      /* body function: fell through end of code */
  705.    #define A_Coact    1    /* co-expression activation */
  706.    #define A_Coret    2    /* co-expression return */
  707.    #define A_Cofail    3    /* co-expression failure */
  708. #else                    /* COMPILER */
  709.    #define A_Resume    1    /* routine failed */
  710.    #define A_Pret_uw    2    /* interp unwind for Op_Pret */
  711.    #define A_Unmark_uw    3    /* interp unwind for Op_Unmark */
  712.    #define A_Pfail_uw    4    /* interp unwind for Op_Pfail */
  713.    #define A_Lsusp_uw    5    /* interp unwind for Op_Lsusp */
  714.    #define A_Eret_uw    6    /* interp unwind for Op_Eret */
  715.    #define A_Continue    7    /* routine returned */
  716.    #define A_Coact    8    /* co-expression activated */
  717.    #define A_Coret    9    /* co-expression returned */
  718.    #define A_Cofail    10    /* co-expression failed */
  719.    #ifdef MultiThread
  720.       #define A_MTEvent    11    /* multithread event */
  721.    #endif                /* MultiThread */
  722. #endif                    /* COMPILER */
  723.  
  724. /*
  725.  * Address of word containing cset bit b (c is a struct descrip of type Cset).
  726.  */
  727. #define CsetPtr(b,c)    (BlkLoc(c)->cset.bits + (((b)&0377) >> LogIntBits))
  728.  
  729. #if MSDOS
  730.    #if (MICROSOFT && defined(M_I86HM)) || (TURBO && defined(__HUGE__))
  731.       #define ptr2word(x) ((uword)((char huge *)x - (char huge *)zptr))
  732.       #define word2ptr(x) ((char huge *)((char huge *)zptr + (uword)x))
  733.    #else                /* MICROSOFT ... */
  734.       #define ptr2word(x) (uword)x
  735.       #define word2ptr(x) ((char *)x)
  736.    #endif                /* MICROSOFT ... */
  737. #endif                    /* MSDOS */
  738.