home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / forth / pfe-0.000 / pfe-0 / pfe-0.9.13 / src / preload.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-17  |  4.5 KB  |  148 lines

  1. /*
  2.  * This file is part of the portable Forth environment written in ANSI C.
  3.  * Copyright (C) 1995  Dirk Uwe Zoller
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13.  * See the GNU Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public
  16.  * License along with this library; if not, write to the Free
  17.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * This file is version 0.9.13 of 17-July-95
  20.  * Check for the latest version of this package via anonymous ftp at
  21.  *    roxi.rz.fht-mannheim.de:/pub/languages/forth/pfe-VERSION.tar.gz
  22.  * or    sunsite.unc.edu:/pub/languages/forth/pfe-VERSION.tar.gz
  23.  * or    ftp.cygnus.com:/pub/forth/pfe-VERSION.tar.gz
  24.  *
  25.  * Please direct any comments via internet to
  26.  *    duz@roxi.rz.fht-mannheim.de.
  27.  * Thank You.
  28.  */
  29. /*
  30.  * preload.h --- types, codes and macros for initial symbol table load
  31.  * (duz 09Jul93)
  32.  */
  33.  
  34. #ifndef __CONFIG_H
  35. #include "config.h"
  36. #endif
  37.  
  38. #ifndef __MACROS_H
  39. #include "macros.h"
  40. #endif
  41.  
  42. typedef struct            /* describe a word for registration */
  43. {                /* in the dictionary */
  44.   const char *name;        /* name of word */
  45.   pCode ptr;            /* code it executes or something */
  46. }                /* according to spc@pineal.math.fau.edu: */
  47. Word;                /* 'void *' doesn't work here on SGI */
  48.  
  49. typedef struct            /* describes the set of words */
  50. {                /* a module loads into the dictionary */
  51.   int n;            /* how many words? */
  52.   const Word *w;        /* pointer to vector of words */
  53. #if defined DEBUG
  54.   const char *name;        /* name of word set */
  55. #endif
  56. }
  57. Words;
  58.  
  59. typedef struct            /* list of word sets to load into */
  60. {                /* a word list */
  61.   int n;            /* how many word lists? */
  62.   const Words *const *ws;    /* pointer to vector of word sets */
  63.   Wordl *wid;            /* pointer to word list */
  64. }
  65. preloadList;
  66.  
  67. extern preloadList only_list;
  68. extern preloadList forth_list;
  69. extern preloadList extensions_list;
  70. extern const preloadList *preload_list [];
  71. extern const int preload_lists;
  72.  
  73.  
  74. #define LISTWORDS(SET)    static const Word APPEND (SET,_word) []
  75.  
  76. #if defined DEBUG
  77.  
  78. #define COUNTWORDS(SET,NAME)            \
  79. const Words APPEND (SET,_words) =        \
  80. {                        \
  81.   DIM (APPEND (SET,_word)),            \
  82.   APPEND (SET,_word),                \
  83.   NAME                        \
  84. }
  85.  
  86. #else
  87.  
  88. #define COUNTWORDS(SET,NAME)            \
  89. const Words APPEND (SET,_words) =        \
  90. {                        \
  91.   DIM (APPEND (SET,_word)),            \
  92.   APPEND (SET,_word)                \
  93. }
  94.  
  95. #endif
  96.  
  97. /* Encoding the kind of definition i.e. which runtime to fill into the cfa. */
  98. /* Octal 1XY, where X&1 means "immediate" */
  99.  
  100. #define _CO 0100    /* code definition */
  101. #define _CI 0110    /* immediate code definition */
  102. #define _CS 0130    /* immediate state smart words */
  103.  
  104. #define _SV 0101    /* system variable */
  105. #define _SC 0102    /* system constant */
  106.  
  107. #define _DV 0103    /* dictionary related system variable */
  108. #define _DC 0104    /* dictionary related system constant */
  109.  
  110. #define _OV 0105    /* ordinary variable */
  111. #define _OC 0106    /* ordinary constant */
  112. #define _OL 0107    /* ordinary value */
  113.  
  114. #define _IV 0115    /* immediate variable */
  115. #define _IC 0116    /* immediate constant */
  116. #define _IL 0117    /* immediate value */
  117.  
  118. #define _VO 0120    /* vocabulary */
  119. #define _OY 0121    /* the special only vocabulary */
  120.  
  121. /* macros to build entries in the wordlists: */
  122.  
  123. #define    CO(NM,PCODE)    { "\100"NM, APPEND (PCODE,_) }
  124. #define    CI(NM,PCODE)    { "\110"NM, APPEND (PCODE,_) }
  125. #define CS(NM,SEM)    { "\130"NM, (pCode)&APPEND(SEM,_semantics) }
  126.  
  127. #define    SV(NM,VAR)    { "\101"NM, (pCode)&(VAR) }
  128. #define    SC(NM,VAR)    { "\102"NM, (pCode)&(VAR) }
  129.  
  130. #if __IBMC__ && __OS2__    /* IBM C Set/2 thinks OFFSET_OF is no constant expr */
  131. #define    DV(NM,MEMBER)    { "\103"NM, (pCode)do_##MEMBER }
  132. #define    DC(NM,MEMBER)    { "\104"NM, (pCode)do_##MEMBER }
  133. #else
  134. #define    DV(NM,MEMBER)    { "\103"NM, (pCode)OFFSET_OF(Dict, MEMBER) }
  135. #define    DC(NM,MEMBER)    { "\104"NM, (pCode)OFFSET_OF(Dict, MEMBER) }
  136. #endif
  137.  
  138. #define OV(NM)        { "\105"NM, (pCode)0) }
  139. #define    OC(NM,VAL)    { "\106"NM, (pCode)(VAL) }
  140. #define OL(NM,VAL)    { "\107"NM, (pCode)(VAL) }
  141.  
  142. #define IV(NM)        { "\115"NM, (pCode)0) }
  143. #define    IC(NM,VAL)    { "\116"NM, (pCode)(VAL) }
  144. #define IL(NM,VAL)    { "\117"NM, (pCode)(VAL) }
  145.  
  146. #define    VO(NM,LIST)    { "\120"NM, (pCode)(LIST) }
  147. #define    OY(NM,LIST)    { "\121"NM, (pCode)(LIST) }
  148.