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

  1. /*
  2.  * Harvest C
  3.  * 
  4.  * Copyright 1991 Eric W. Sink   All rights reserved.
  5.  * 
  6.  * Global variables
  7.  * 
  8.  */
  9.  
  10. #ifndef Globals_INTERFACE
  11. #define Globals_INTERFACE
  12.  
  13. #include "SymTable.h"
  14. #include "PPSymTable.h"
  15. #include "SRC.h"
  16.  
  17.     /* The following contain the working data structures for this C source file */
  18. extern     ParamRecVia_t            ParamList;
  19. extern LabSymListVia_t          SwitchCases;
  20. #define MAXSWITCHES 64
  21. extern LabSymListVia_t          Switches[MAXSWITCHES];
  22. extern int                      CountSwitch;
  23.  
  24. extern LabSymListVia_t          Labels;    /* list of asm labels */
  25. extern SymListVia_t             StringLits;    /* String literal pool */
  26. extern SymListVia_t             TagsTable;    /* Struct/union/enum tags */
  27. extern SymListVia_t             LabelsTable;    /* C labels */
  28. extern SymListVia_t             StaticTable;    /* global list of static
  29.                          * variables (static within
  30.                          * functions) */
  31. extern SymListVia_t             GlobalSymbolTable;    /* All external symbols
  32.                              * are defined here. */
  33. extern SymListVia_t             TP_defnames;    /* All TP_defnames are
  34.                          * defined here. */
  35. extern LabSymListVia_t             SegmentNames;    /* All segment names are
  36.                          * stored here. */
  37. extern PPSymListVia_t           Defines;    /* the list of all symbols
  38.                          * defined my the
  39.                          * preprocessor.  This
  40.                          * includes both simple
  41.                          * #defines and macros. */
  42. /*
  43.  * A SRC is the logical source of the C program text being lexed/parsed.  It
  44.  * may be a region of memory or a file
  45.  */
  46.  
  47. extern SRCListVia_t             SRCStack;    /* the SRC stack */
  48. extern SRCKind_t                CurrentSRC;    /* the current SRC for C code */
  49.  
  50. extern FloatLitVia_t            FloatList;    /* floating point literal
  51.                          * pool */
  52. extern InstListVia_t            GlobalCodes;    /* very important - this is
  53.                          * the list of 68k
  54.                          * instruction records into
  55.                          * which code is generated.
  56.                          * Harvest C currently uses
  57.                          * no intermediate
  58.                          * representation for
  59.                          * generated code. The parser
  60.                          * creates a tree
  61.                          * representation of C
  62.                          * declarations and
  63.                          * expressions.  The code
  64.                          * generator converts this
  65.                          * tree into data structures
  66.                          * representing 68000 machine
  67.                          * instructions and assembler
  68.                          * directives, storing them
  69.                          * in this list.  This list
  70.                          * is then either dumped as
  71.                          * assembly source or as an
  72.                          * MPW linker file. */
  73. extern MPWDictListVia_t         OBJNameList;
  74. extern MPWListVia_t             GlobalRecords;
  75.  
  76. extern int                      ExtraBlocks;    /* used primarily in
  77.                          * parsestmt.c, for keeping
  78.                          * track of scopes */
  79. extern char                     Errm[MAXERRORMSG];    /* used as a buffer for
  80.                              * constructing error
  81.                              * messages */
  82.  
  83. extern struct OptionsS          Opts, DefaultOpts;    /* A single structure
  84.                              * containing all user
  85.                              * options pertaining to
  86.                              * compilation, parsing
  87.                              * and code generation.  */
  88.  
  89. extern unsigned int             CountIncludes;
  90.  
  91. /*
  92.  * The next variables are used while constructing struct declarations
  93.  */
  94. extern int                      CurFieldOffset;    /* offset of current bit
  95.                          * field */
  96. extern int                      NextStructOffset;    /* offset of next member */
  97. extern int                      CurFieldBit;
  98. extern int                      CurStructSize;
  99. extern ParseTreeVia_t           LastSwitchExpression;    /* used by the parser to
  100.                              * remember the
  101.                              * expression in the
  102.                              * last switch(expr)
  103.                              * statement, so we can
  104.                              * typecheck the case
  105.                              * labels against that
  106.                              * expression */
  107. extern int                      InPreprocIf;    /* a flag which indicates to
  108.                          * the parser whether or not
  109.                          * we are parsing the
  110.                          * expression following an
  111.                          * #if or #elif directive */
  112. extern KW_t                     KWTable[KEYWORDTABLESIZE];    /* The KWTable is a hash
  113.                                  * table for C reserved
  114.                                  * words.  Since
  115.                                  * virtually every token
  116.                                  * must be checked
  117.                                  * against the list of
  118.                                  * reserved word, it is
  119.                                  * worthwhile to make
  120.                                  * this search
  121.                                  * efficient. */
  122. extern long                     CurrentEnumK;    /* The value of the current
  123.                          * enum constant. Used during
  124.                          * construction of an enum
  125.                          * declaration. */
  126. extern TypeRecordVia_t          EnumBeingDeclared;    /* During an enum
  127.                              * declaration, this
  128.                              * points to the type
  129.                              * record of the enum
  130.                              * being declared.  Each
  131.                              * enum constant bears a
  132.                              * pointer to its own
  133.                              * type. */
  134. extern SYMVia_t                 FunctionBeingDefined;    /* During a function
  135.                              * definition, this
  136.                              * points to the symbol
  137.                              * being defined.  */
  138. /*
  139.  * All of the following variables are used in calculating various metrics
  140.  */
  141. extern unsigned int             T_PreprocSubsts;
  142. extern unsigned int             T_PreprocBefore;
  143. extern unsigned int             T_PreprocAfter;
  144. extern unsigned int             T_CommentBytes;
  145. extern unsigned int             T_StmtCount;
  146. extern unsigned int             T_CountIdentifiers;
  147. extern unsigned int             T_TotalIdentifierLength;
  148. extern unsigned int             T_CountCasts;
  149. extern unsigned int             T_CountPreprocCondits;
  150. extern unsigned int             T_CountComments;
  151. extern int                      FunctionReturnCount;
  152. extern int                      FunctionComplexity;
  153. extern int                      HalTotalOperands;
  154. extern int                      HalTotalOperators;
  155. extern int                      HalUniqOperators;
  156. extern int                      HalUniqOperands;
  157. extern int                      PreprocSymbolCount;
  158. extern int                      DuplicateStringLits;
  159. extern int                      TotalLines;
  160. extern int                      CountFunctions;
  161.  
  162. extern int                      SumGlobals;
  163. extern int                      SumGlobalSpace;
  164. extern LocAMVia_t               StructDoubleReturnLoc;    /* During code
  165.                              * generation, this
  166.                              * points to the place
  167.                              * to return a struct.
  168.                              * doubles are now
  169.                              * returned in d0-d1 */
  170. /* These keep track of the efficiency of the keyword hash table. */
  171. extern int                      HashCollisions;
  172. extern int                      HashCount;
  173.  
  174. extern int                      OddGlobal;    /* true if an odd number of
  175.                          * bytes have been generated
  176.                          * for global data.
  177.                          * depending on the next
  178.                          * global variable, an
  179.                          * alignment directive may be
  180.                          * needed */
  181. extern int                      DiscardedFunctionCall;    /* a flag indicating to
  182.                              * the code generator
  183.                              * that the result of
  184.                              * the function call
  185.                              * being generated is
  186.                              * not needed. for
  187.                              * example, extern int
  188.                              * x(void); x(); */
  189.  
  190. extern char                     LastPreproc[64];    /* records the name of
  191.                              * the last preproc
  192.                              * directive used */
  193.  
  194. extern int                      TokenOnDeck;    /* flag indicating if a
  195.                          * single token has been read
  196.                          * and then putback. Such a
  197.                          * token is on deck and is
  198.                          * easily available to the
  199.                          * parser in NextIs() */
  200. extern char                     NextToken[MAXIDLENGTH];    /* tokens on deck are
  201.                              * stored here */
  202. extern Codigo_t                 NextTokenKind;    /* tokens on deck are stored
  203.                          * here */
  204.  
  205. extern char                    *LastToken;    /* A very important variable.
  206.                          * This contains the string
  207.                          * of the last token read. */
  208. extern int                      SizeOfFloat;    /* size of float type in
  209.                          * bytes */
  210. extern int                      SizeOfDouble;
  211. extern int                      SizeOfLongDouble;
  212. extern Codigo_t                 LastTokenKind;    /* code for the last token
  213.                          * read */
  214. extern long double              LastFloatingConstant;    /* value of the last
  215.                              * floating point
  216.                              * constant read -
  217.                              * probably only valid
  218.                              * if the last token
  219.                              * really was a floating
  220.                              * point constant */
  221. extern long                     LastIntegerConstant;
  222. extern char                     ThisToken[MAXIDLENGTH];    /* tokens are
  223.                              * constructed here
  224.                              * during lexing */
  225. extern char                     LastChar;    /* The last character read
  226.                          * which contributed to a
  227.                          * token.  TODO - is this
  228.                          * correct or is this the
  229.                          * last character returned
  230.                          * from RawCharacter() ? */
  231.  
  232. extern GenericFileVia_t         outfile;    /* output file for assembler
  233.                          * source, etc */
  234. extern GenericFileVia_t         errfile;    /* error file */
  235.  
  236. extern int                      NumErrors;    /* Cumulative count of
  237.                          * errors. */
  238. extern int                      AttemptWarnings;    /* Cumulative count of
  239.                              * warnings. */
  240. extern int                      NumWarnings;    /* Cumulative count of
  241.                          * warnings. */
  242. extern int                      gAllDone;    /* This is set true when the
  243.                          * SRCStack is empty. */
  244.  
  245.  
  246. /*
  247.  * The Preprocessor uses the variable PPStatus to signal to the parser that
  248.  * tokens are to be ignored, due to the a conditional compilation directive.
  249.  * However, since these directives may be nested, there is a stack to keep
  250.  * old values of PPStatus.  This stack is implemented as an array of int and
  251.  * PPSP is the stack pointer.
  252.  */
  253. extern int                      PreprocStack[MAXNESTIFDEF];
  254. extern int                      PPSP;
  255. extern int                      PPStatus;
  256. /*
  257.  * The following are used for macro definition by the preprocessor.
  258.  * MacroValue is used to temporarily store the value of the macro being
  259.  * defined. The 'value' of a a macro, as I define it, is the string used in
  260.  * expanding it.  In other words, it is the part just to the right of the id
  261.  * and arguments : #define macro(a,b,c) VALUE
  262.  */
  263. extern EString_t                MacroValue;
  264.  
  265. extern BlockStackVia_t          CurrentBlock;    /* used in keeping track of
  266.                          * scopes. This points to the
  267.                          * top of the scope stack.
  268.                          * When looking up the
  269.                          * meaning of some identifer,
  270.                          * during parsing, the search
  271.                          * starts in the symbol
  272.                          * tables of the top scope,
  273.                          * and proceeds downward
  274.                          * until it is found or the
  275.                          * end of the stack is
  276.                          * reached. */
  277. extern LabSYMVia_t              FunctionLastLabel;    /* during code
  278.                              * generation, this is
  279.                              * the number of the
  280.                              * label which will
  281.                              * occur at the end of
  282.                              * the function. a
  283.                              * return statement is
  284.                              * compiled with a jump
  285.                              * to this label */
  286. extern int                      NextFloatLitLabel;    /* number of the next
  287.                              * label for floating
  288.                              * point literals */
  289. extern int                      NextLitLabel;    /* number of the next label
  290.                          * for string literals */
  291. extern int                      NextEccLabel;    /* number of the next general
  292.                          * Ecc generated label */
  293. /*
  294.  * used by the register allocator, these next three variables keep track of
  295.  * which register is the next candidate for allocation. Register allocation
  296.  * is done on the fly
  297.  */
  298. extern int                      NextTempFloatReg;
  299. extern int                      NextTempDataReg;
  300. extern int                      NextTempAddrReg;
  301. /*
  302.  * these arrays are part of the register allocator, and contain data
  303.  * structures representing the machine registers.
  304.  */
  305. extern RegisterRecord_t         TempFloats[8];
  306. extern RegisterRecord_t         TempDatas[8];
  307. extern RegisterRecord_t         TempAddrs[8];
  308. /*
  309.  * used by the register allocator and code generator, this is a list of spill
  310.  * slots
  311.  */
  312. extern SpillSlotVia_t           SpillList;
  313. extern LabSYMVia_t              BreakLabel;    /* The current break label.
  314.                          * A break statement is
  315.                          * simply compiled as a jump
  316.                          * to this label.  This label
  317.                          * is set in the routine that
  318.                          * generates code for a loop
  319.                          * of some kind */
  320. extern LabSYMVia_t              ContinueLabel;    /* similar to BreakLabel */
  321. extern InstVia_t                LinkInst;    /* The pointer to the
  322.                          * instruction record for the
  323.                          * link instruction for the
  324.                          * function being compiled.
  325.                          * The constant contained
  326.                          * herein may be modified
  327.                          * during compilation to
  328.                          * allocate more space on the
  329.                          * stack */
  330. extern EString_t                InitDataAcc;    /* used for accumulating data
  331.                          * for an initializer */
  332. extern int                      InitDataAccIndex;    /* index used for
  333.                              * accumulating
  334.                              * initializer data */
  335. extern int                      InitDataAccSize;
  336. extern void                    *RainyDayZone;
  337.  
  338. extern unsigned char           *BitsBuffer;
  339. extern int                      BBIndex;
  340. extern int                      thesz;    /* bitmap form of Ext                   */
  341. extern int                      Pass;
  342. extern int                      Pc;    /* Program Counter                      */
  343. extern int                      Old_pc;    /* Program Counter at beginning         */
  344. extern int                      Fwdsize;    /* default fwd ref size                 */
  345. extern short                    CurVolrefnum;
  346. extern long                     CurDirID;
  347. extern char                     asmLine[];
  348. extern LabSYMVia_t                      CurrentSegmentLabel;
  349. extern LabSYMVia_t              LibLabelULMODT;
  350. extern LabSYMVia_t              LibLabelLMODT;
  351. extern LabSYMVia_t              LibLabelULMULT;
  352. extern LabSYMVia_t              LibLabelULDIVT;
  353. extern LabSYMVia_t              LibLabelLDIVT;
  354. extern LabSYMVia_t              LibLabelXTOI;
  355. extern int                      PartDone;
  356. extern StringPoolVia_t          ParserStrings;
  357. extern int                      gAbortCompile;
  358.  
  359. #endif
  360.