home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DMAKE38A.ZIP / STRUCT.H < prev    next >
C/C++ Source or Header  |  1992-01-23  |  10KB  |  260 lines

  1. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/struct.h,v 1.1 1992/01/24 03:29:32 dvadura Exp $
  2. -- SYNOPSIS -- structure definitions
  3. -- 
  4. -- DESCRIPTION
  5. --    dmake main data structure definitions.  See each of the individual
  6. --    struct declarations for more detailed information on the defined
  7. --    fields and their use.
  8. -- 
  9. -- AUTHOR
  10. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  11. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  12. --
  13. -- COPYRIGHT
  14. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  15. -- 
  16. --      This program is free software; you can redistribute it and/or
  17. --      modify it under the terms of the GNU General Public License
  18. --      (version 1), as published by the Free Software Foundation, and
  19. --      found in the file 'LICENSE' included with this distribution.
  20. -- 
  21. --      This program is distributed in the hope that it will be useful,
  22. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  23. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24. --      GNU General Public License for more details.
  25. -- 
  26. --      You should have received a copy of the GNU General Public License
  27. --      along with this program;  if not, write to the Free Software
  28. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. --
  30. -- LOG
  31. --     $Log: struct.h,v $
  32.  * Revision 1.1  1992/01/24  03:29:32  dvadura
  33.  * dmake Version 3.8, Initial revision
  34.  *
  35. */
  36.  
  37. #ifndef _STRUCT_INCLUDED_
  38. #define _STRUCT_INCLUDED_
  39.  
  40. typedef uint32 t_attr;
  41.  
  42. /* The following struct is the cell used in the hash table.
  43.  * NOTE:  It contains the actual hash value.  This allows the hash table
  44.  *        insertion to compare hash values and to do a string compare only
  45.  *        for entries that have matching hash_key values.  This elliminates
  46.  *        99.9999% of all extraneous string compare operations when searching
  47.  *        a hash table chain for matching entries.  */
  48.  
  49. typedef struct hcell {
  50.     struct hcell    *ht_next;    /* next entry in the hash table */
  51.     char        *ht_name;    /* name of this cell */
  52.     char        *ht_value;    /* cell value if and */
  53.     uint32        ht_hash;    /* actual hash_value of cell */
  54.     int        ht_flag;    /* flags belonging to hash entry */
  55.  
  56.     /* NOTE: some macros have corresponding variables defined
  57.      * that control program behaviour.  For these macros a
  58.      * bit of ht_flag indicates the variable value will be set, and the
  59.      * type of the value that will be set.
  60.      *
  61.      * The struct below contains a mask for bit variables, and a
  62.      * pointer to the global STATIC location for that variable.
  63.      * String and char variables point to the same place as ht_value
  64.      * and must be updated when ht_value changes, bit variables must
  65.      * have their value recomputed. See Def_macro code for more
  66.      * details.
  67.      *
  68.      * NOTE:  Macro variables and Targets are always distinct.  Thus
  69.      * the value union contains pointers back at cells that own
  70.      * a particular name entry.  A conflict in this can never
  71.      * arise, ie pointers at cells will never be used as
  72.      * values for a macro variable, since the cell and macro
  73.      * name spaces are completely distinct. */
  74.  
  75.     struct {
  76.         int    mv_mask;    /* bit mask for bit variable      */
  77.         union {
  78.              char**    mv_svar;/* ptr to string valued glob var  */
  79.             char*    mv_cvar;/* ptr to char   valued glob var */
  80.             t_attr*    mv_bvar;/* ptr to bit    valued glob var */
  81.              int*    mv_ivar;/* ptr to int    valued glob var  */
  82.  
  83.             struct {
  84.                struct tcell*  ht_owner;/* ptr to CELL owning name */
  85.                struct tcell*  ht_root; /* root ptr for explode */
  86.             } ht;
  87.         } val;
  88.     } var;                /* variable's static equivalent */
  89. } HASH, *HASHPTR;
  90.  
  91. #define MV_MASK        var.mv_mask
  92. #define MV_SVAR     var.val.mv_svar
  93. #define MV_CVAR     var.val.mv_cvar
  94. #define MV_BVAR     var.val.mv_bvar
  95. #define MV_IVAR     var.val.mv_ivar
  96. #define CP_OWNR         var.val.ht.ht_owner
  97. #define CP_ROOT         var.val.ht.ht_root
  98.  
  99.  
  100.  
  101. /* This struct holds the list of temporary files that have been created.
  102.  * It gets unlinked when Quit is called due to an execution error */
  103. typedef struct flst {
  104.    char        *fl_name;    /* file name         */
  105.    FILE        *fl_file;    /* the open file    */
  106.    struct flst  *fl_next;    /* pointer to next file */
  107. } FILELIST, *FILELISTPTR;
  108.  
  109.  
  110.  
  111. /* This is the structure of a target cell in the dag which represents the
  112.  * graph of dependencies.  Each possible target is represented as a cell.
  113.  * 
  114.  * Each cell contains a pointer to the hash table entry for this cell.
  115.  * The hash table entry records the name of the cell. */
  116.  
  117. typedef struct tcell {
  118.     struct hcell    *ce_name;    /* name of this cell                */
  119.  
  120.     struct tcell    *ce_all;    /* link for grouping UPDATEALL cells*/
  121.     struct tcell    *ce_setdir;    /* SETDIR ROOT pointer for this cell*/
  122.     struct tcell    *ce_link;    /* link for temporary list making   */
  123.  
  124.     struct lcell    *ce_prq;    /* list of prerequisites for cell   */
  125.     struct lcell    *ce_indprq;    /* indirect prerequisites for % cell*/
  126.  
  127.     struct str      *ce_recipe;    /* recipe for making this cell      */
  128.     FILELISTPTR     ce_files;    /* list of temporary files for cell */
  129.  
  130.     char         *ce_per;    /* value of % in %-meta expansion   */
  131.     char        *ce_fname;    /* file name associated with target */
  132.     char        *ce_lib;    /* archive name, if A_LIBRARYM      */
  133.     char        *ce_dir;    /* value for .SETDIR attribute      */
  134.  
  135.     int        ce_count;    /* value for :: recipe set          */
  136.     int        ce_index;    /* value of count for next :: child */
  137.     int           ce_flag;    /* all kinds of goodies            */
  138.     t_attr        ce_attr;    /* attributes for this target        */
  139.     time_t        ce_time;    /* time stamp value of target if any*/
  140. } CELL, *CELLPTR;
  141.  
  142. #define CE_NAME        ce_name->ht_name
  143. #define CE_RECIPE       ce_recipe
  144. #define CE_PRQ          ce_prq
  145.  
  146.  
  147. /* This struct represents that used by Get_token to return and control
  148.  * access to a token list inside a particular string.  This gives the
  149.  * ability to access non overlapping tokens simultaneously from
  150.  * multiple strings. */
  151.     
  152. typedef struct {
  153.     char *tk_str;              /* the string to search for tokens  */
  154.     char tk_cchar;             /* current char under *str          */
  155.     int  tk_quote;               /* if we are scanning a quoted str  */
  156. }  TKSTR, *TKSTRPTR;
  157.  
  158.  
  159.  
  160. /* Below is the struct used to represent a string.  It points at possibly
  161.  * another string, since the set of rules for making a target is a collection
  162.  * of strings. */
  163.  
  164.  
  165. typedef struct str {
  166.     char        *st_string;    /* the string value */
  167.     struct str    *st_next;    /* pointer to the next string */
  168.     t_attr        st_attr;    /* attr for rule operations */
  169. } STRING, *STRINGPTR;
  170.  
  171.  
  172. /* The next struct is used to link together prerequisite lists */
  173.  
  174. typedef struct lcell {
  175.     struct tcell    *cl_prq;    /* link to a prerequisite     */
  176.     struct lcell    *cl_next;    /* next cell on dependency list */
  177.     int        cl_flag;    /* flags for link cell        */
  178. } LINK, *LINKPTR;
  179.  
  180.  
  181.  
  182. /* These structs are used in processing of the % rules, and in building
  183.  * the NFA machine that is used to match an arbitrary target string to
  184.  * one of the % rules that is represented by each DFA */
  185.  
  186. typedef int16 statecnt;        /* limits the max number of dfa states    */
  187.  
  188.  
  189. /* Each state of the DFA contains four pieces of information. */
  190. typedef struct st {
  191.     struct st    *no_match;    /* state to go to if no match */
  192.     struct st    *match;        /* state to go to if we do match */
  193.     char        symbol;        /* symbol on which we transit */
  194.     char        action;        /* action to perform if match */
  195. } STATE, *STATEPTR;
  196.  
  197.  
  198. /* Each DFA machine looks like this.  It must have two pointers that represent
  199.  * the value of % in the matched string, and it contains a pointer into the
  200.  * current state, as well as the array of all states. */
  201. typedef struct {
  202.     char        *pstart;    /* start of % string match */
  203.     char        *pend;        /* end of % string match */
  204.     STATEPTR    c_state;    /* current DFA state */
  205.     CELLPTR        node;        /* % target represented by this DFA */
  206.     STATEPTR    states;        /* table of states for the DFA */
  207. } DFA, *DFAPTR;
  208.  
  209.  
  210. /* An NFA is a collection of DFA's.  For each DFA we must know it's current
  211.  * state and where the next NFA is. */
  212. typedef struct nfa_machine {
  213.     DFAPTR        dfa;        /* The DFA for this eps transition */
  214.     char        status;        /* DFA state */
  215.     struct nfa_machine *next;     /* the next DFA in NFA */
  216. } NFA, *NFAPTR;
  217.  
  218.  
  219.  
  220. /* The next struct is used to link together DFA nodes for inference. */
  221.  
  222. typedef struct dfal {
  223.     struct tcell    *dl_meta;    /* link to %-meta cell        */
  224.     struct dfal    *dl_next;    /* next cell on matched DFA list*/
  225.     struct dfal    *dl_prev;    /* prev cell on matched DFA list*/
  226.     struct dfal    *dl_member;    /* used during subset calc    */
  227.     char        dl_delete;    /* used during subset calc    */
  228.     char           *dl_per;    /* value of % for matched DFA   */
  229.     statecnt        dl_state;    /* matched state of the DFA    */
  230.     int        dl_prep;    /* repetion count for the cell    */
  231. } DFALINK, *DFALINKPTR;
  232.  
  233.  
  234. /* This struct is used to store the stack of DFA sets during inference */
  235. typedef struct dfst {
  236.    DFALINKPTR    df_set;            /* pointer to the set        */
  237.    struct dfst *df_next;        /* next element in the stack    */
  238. } DFASET, *DFASETPTR;
  239.  
  240.  
  241. /* We need sets of items during inference, here is the item, we form sets
  242.  * by linking them together. */
  243.  
  244. typedef struct ic {
  245.    CELLPTR    ic_meta;        /* Edge we used to make this cell*/
  246.    DFALINKPTR   ic_dfa;            /* Dfa that we matched against     */
  247.    CELLPTR    ic_setdirroot;        /* setdir root pointer for cell     */
  248.    DFASET       ic_dfastack;        /* set of dfas we're working with*/
  249.    int        ic_dmax;        /* max depth of cycles in graph  */
  250.    char           *ic_name;        /* name of the cell to insert    */
  251.    char        *ic_dir;            /* dir to CD to prior to recurse */
  252.    struct ic   *ic_next;        /* next pointer to link         */
  253.    struct ic   *ic_link;        /* link all ICELL'S together     */
  254.    struct ic   *ic_parent;        /* pointer to post-requisite     */
  255.    char        ic_flag;        /* flag, used for NOINFER only     */
  256.    char         ic_exists;        /* TRUE if prerequisite exists     */
  257. } ICELL, *ICELLPTR;
  258.  
  259. #endif
  260.