home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / SymTable.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-04  |  4.7 KB  |  154 lines  |  [TEXT/ALFA]

  1. /*
  2.  * Harvest C
  3.  * 
  4.  * Copyright 1991 Eric W. Sink   All rights reserved.
  5.  * 
  6.  * This file defines the interface for the symbol tables.
  7.  * 
  8.  */
  9.  
  10. #ifndef SymTable_INTERFACE
  11. #define SymTable_INTERFACE
  12.  
  13. #include "Common.h"
  14.  
  15. typedef struct stabS            SYM_t;
  16. typedef struct labelsym         LabSYM_t;
  17. typedef struct stablist         SymList_t;
  18. typedef struct labstablist      LabSymList_t;
  19. typedef SYM_t P__H             *SYMVia_t;
  20. typedef SymList_t P__H         *SymListVia_t;
  21. typedef LabSYM_t P__H          *LabSYMVia_t;
  22. typedef LabSymList_t P__H      *LabSymListVia_t;
  23. typedef struct SymTableStack_S  SymTableStack_t;
  24. typedef SymTableStack_t P__H   *SymTableStackVia_t;
  25. typedef struct SymImage_S       SymImage_t;
  26. typedef SymImage_t P__H        *SymImageVia_t;
  27.  
  28. #include "TypeRecord.h"
  29. #include "ParseTree.h"
  30. #include "CodeGen.h"
  31.  
  32. /* ------------------ Symbol Tables ------------------ */
  33.  
  34. /*
  35.  * Below, the structure declaration for symbol records.  TODO This structure
  36.  * needs a full explanation here, when one is available. Note : this
  37.  * structure is the storage record for SYMBOLS.  All kinds of symbols may go
  38.  * here, but it is not a storage record for the parse tree.  The parse tree
  39.  * format follows...
  40.  */
  41.  
  42. union intnumbers {
  43.     int                             CountParams;    /* Symbols : macro funcs */
  44.     int                             EnumVal;    /* Symbols : enum const value */
  45.     int                             structoffset;    /* Symbols : struct
  46.                              * members */
  47.     int                             CountUses;    /* Symbols : number of uses. */
  48. };
  49.  
  50. /* Mask constants for types. */
  51. #define ISINLINEMASK 1
  52. #define YADUMPEDMASK 2
  53. #define INCOMPLETEMASK 4
  54. #define ISPASCALMASK 8
  55. #define ISACLASS 16
  56. #define SIZEDONE 32
  57. #define SIGNKNOWN 64
  58. #define SIGNEDTYPE 128
  59.  
  60. /* Mask constants for symbols. */
  61. #define BEINGEXPANDED 1
  62. #define CODEOUTPUT 2
  63. #define PREPROCLOCKED 4
  64. #define PREPROCUNDEF 8
  65. #define REFOUTPUT 16
  66. #define ISTRAPMASK 32
  67. #define ISPASCALSTRING 64
  68. #define ISINSTANCEVAR 128
  69. #define ISPUBLIC 256
  70. #define HASPARAM 512
  71. #define DEADPPSYM 1024
  72.  
  73. /*
  74.  * This structure is used for symbol tables of all kinds.  This obnoxious
  75.  * size of this structure is one of my big motivations for implementing OO
  76.  * stuff in Ecc, so I can create a class for symbol lists, and subclass it
  77.  * for each kind of symbol list that I need
  78.  */
  79.  
  80. struct stablist {        /* This is a standard symbol table. */
  81.     SYMVia_t P__H                  *hashtable;
  82.     short                           count;
  83.     short                           tablesize;
  84.     short                           isShadow;
  85. };
  86.  
  87. struct stabS {
  88.     unsigned short                  IndexInserted;
  89.     unsigned short                  SymbolFlags;
  90.     SYMVia_t                        next;
  91.     TypeRecordVia_t                 TP;
  92.     enum StorageClassCode           storage_class;
  93.  
  94.     union intnumbers                numbers;
  95.  
  96.     union Trees {
  97.     SymListVia_t                    superclass;
  98.     ParseTreeVia_t                  FuncBody;    /* For functions */
  99.     ParseTreeVia_t                  Initializer;    /* For data objects */
  100.     ParseTreeVia_t                  Stmt;    /* For C labels */
  101.     ParseTreeVia_t                  CaseConstant;
  102.     EString_t                       PreProcValue;    /* Macro expansion */
  103.     struct TwoShorts {
  104.         short                           StartBit;
  105.         short                           EndBit;
  106.     }                               StartEndBits;    /* For bit fields */
  107.     }                               Definition;
  108.     union M68kDef_U {
  109.     InstVia_t                       where;    /* For labels */
  110.     LocAMVia_t                      Loc;    /* For data & functions */
  111.     }                               M68kDef;
  112.     char                            name[1];    /* The NewHandle will ensure
  113.                          * that enough space is
  114.                          * allocated for the name to
  115.                          * be stored here */
  116. };
  117.  
  118. struct labelsym {
  119.     short                           IndexInserted;
  120.     unsigned long                   HashKey;
  121.     unsigned short                  SymbolFlags;
  122.     LabSYMVia_t                     left;
  123.     LabSYMVia_t                     right;
  124.  
  125.     union Trees                     Definition;
  126.     union M68kDef_U                 M68kDef;
  127.     char                            name[1];
  128. };
  129.  
  130. struct labstablist {
  131.     LabSYMVia_t                     _head;
  132.     short                           count;
  133. };
  134.  
  135. struct SymTableStack_S {
  136.     SymList_t P__H                 *table;
  137.     struct SymTableStack_S P__H    *next;
  138. };
  139.  
  140. struct SymImage_S {
  141.     SYMVia_t                        Symbol;
  142.     struct SymImage_S P__H         *next;
  143.     short                           count;
  144. };
  145.  
  146. TypeRecordVia_t
  147. GetSymTP(SYMVia_t s);
  148.  
  149. void SetSymTP(SYMVia_t s, TypeRecordVia_t TP);
  150. void GetSymName(SYMVia_t s, char *nm);
  151. SYMVia_t TableSearch(SymListVia_t,char *);
  152.  
  153. #endif
  154.