home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dmake40.zip / struct.h < prev    next >
C/C++ Source or Header  |  1994-10-23  |  11KB  |  266 lines

  1. /* RCS      -- $Header: /u5/dvadura/src/public/dmake/src/RCS/struct.h,v 1.1 1994/10/06 17:42:50 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) 1992,1994 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  1994/10/06  17:42:50  dvadura
  33.  * dmake Release Version 4.0, 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.         struct hcell    *ht_link;       /* for temporary lists */
  52.     char        *ht_name;    /* name of this cell */
  53.     char        *ht_value;    /* cell value if any */
  54.     uint32        ht_hash;    /* actual hash_key of cell */
  55.     int        ht_flag;    /* flags belonging to hash entry */
  56.  
  57.     /* NOTE: some macros have corresponding variables defined
  58.      * that control program behaviour.  For these macros a
  59.      * bit of ht_flag indicates the variable value will be set, and the
  60.      * type of the value that will be set.
  61.      *
  62.      * The struct below contains a mask for bit variables, and a
  63.      * pointer to the global STATIC location for that variable.
  64.      * String and char variables point to the same place as ht_value
  65.      * and must be updated when ht_value changes, bit variables must
  66.      * have their value recomputed. See Def_macro code for more
  67.      * details.
  68.      *
  69.      * NOTE:  Macro variables and Targets are always distinct.  Thus
  70.      * the value union contains pointers back at cells that own
  71.      * a particular name entry.  A conflict in this can never
  72.      * arise, ie pointers at cells will never be used as
  73.      * values for a macro variable, since the cell and macro
  74.      * name spaces are completely distinct. */
  75.  
  76.     struct {
  77.         int    mv_mask;    /* bit mask for bit variable      */
  78.         union {
  79.              char**    mv_svar;/* ptr to string valued glob var  */
  80.             char*    mv_cvar;/* ptr to char   valued glob var */
  81.             t_attr*    mv_bvar;/* ptr to bit    valued glob var */
  82.              int*    mv_ivar;/* ptr to int    valued glob var  */
  83.  
  84.             struct {
  85.                struct tcell* ht_owner;/* ptr to CELL owning name */
  86.                struct tcell* ht_root; /* root ptr for explode */
  87.             } ht;
  88.         } val;
  89.     } var;                /* variable's static equivalent */
  90. } HASH, *HASHPTR;
  91.  
  92. #define MV_MASK        var.mv_mask
  93. #define MV_SVAR     var.val.mv_svar
  94. #define MV_CVAR     var.val.mv_cvar
  95. #define MV_BVAR     var.val.mv_bvar
  96. #define MV_IVAR     var.val.mv_ivar
  97. #define CP_OWNR         var.val.ht.ht_owner
  98. #define CP_ROOT         var.val.ht.ht_root
  99.  
  100.  
  101.  
  102. /* This struct holds the list of temporary files that have been created.
  103.  * It gets unlinked when Quit is called due to an execution error */
  104. typedef struct flst {
  105.    char        *fl_name;    /* file name         */
  106.    FILE        *fl_file;    /* the open file    */
  107.    struct flst  *fl_next;    /* pointer to next file */
  108. } FILELIST, *FILELISTPTR;
  109.  
  110.  
  111. /* The next struct is used to link together prerequisite lists */
  112. typedef struct lcell {
  113.     struct tcell    *cl_prq;    /* link to a prerequisite     */
  114.     struct lcell    *cl_next;    /* next cell on dependency list */
  115.     int        cl_flag;    /* flags for link cell        */
  116. } LINK, *LINKPTR;
  117.  
  118.  
  119. /* This is the structure of a target cell in the dag which represents the
  120.  * graph of dependencies.  Each possible target is represented as a cell.
  121.  * 
  122.  * Each cell contains a pointer to the hash table entry for this cell.
  123.  * The hash table entry records the name of the cell. */
  124.  
  125. typedef struct tcell {
  126.     struct hcell    *ce_name;    /* name of this cell                */
  127.         struct hcell    *ce_pushed;     /* local pushed macro definitions   */
  128.  
  129.         struct lcell    ce_all;         /* link for grouping UPDATEALL cells*/
  130.         struct tcell    *ce_set;        /* set rep. valid if ce_all != NULL */
  131.     struct tcell    *ce_setdir;    /* SETDIR ROOT pointer for this cell*/
  132.     struct tcell    *ce_link;    /* link for temporary list making   */
  133.         struct tcell    *ce_parent;     /* used by inner loop, not a static */
  134.  
  135.     struct lcell    *ce_prq;    /* list of prerequisites for cell   */
  136.     struct lcell    *ce_prqorg;    /* list of original prerequisites   */
  137.     struct lcell    *ce_indprq;    /* indirect prerequisites for % cell*/
  138.  
  139.     struct str      *ce_recipe;    /* recipe for making this cell      */
  140.     FILELISTPTR     ce_files;    /* list of temporary files for cell */
  141.         struct str      *ce_cond;       /* conditional macro assignments    */
  142.  
  143.     char         *ce_per;    /* value of % in %-meta expansion   */
  144.     char        *ce_fname;    /* file name associated with target */
  145.     char        *ce_lib;    /* archive name, if A_LIBRARYM      */
  146.     char        *ce_dir;    /* value for .SETDIR attribute      */
  147.  
  148.     int        ce_count;    /* value for :: recipe set          */
  149.     int        ce_index;    /* value of count for next :: child */
  150.     int           ce_flag;    /* all kinds of goodies            */
  151.     t_attr        ce_attr;    /* attributes for this target        */
  152.     time_t        ce_time;    /* time stamp value of target if any*/
  153. } CELL, *CELLPTR;
  154.  
  155. #define CE_NAME        ce_name->ht_name
  156. #define CE_RECIPE       ce_recipe
  157. #define CE_PRQ          ce_prq
  158. #define CeMeToo(C)      &((C)->ce_all)
  159. #define CeNotMe(C)      (C)->ce_all.cl_next
  160.  
  161.  
  162. /* This struct represents that used by Get_token to return and control
  163.  * access to a token list inside a particular string.  This gives the
  164.  * ability to access non overlapping tokens simultaneously from
  165.  * multiple strings. */
  166.     
  167. typedef struct {
  168.     char *tk_str;              /* the string to search for tokens  */
  169.     char tk_cchar;             /* current char under *str          */
  170.     int  tk_quote;               /* if we are scanning a quoted str  */
  171. }  TKSTR, *TKSTRPTR;
  172.  
  173.  
  174.  
  175. /* Below is the struct used to represent a string.  It points at possibly
  176.  * another string, since the set of rules for making a target is a collection
  177.  * of strings. */
  178.  
  179.  
  180. typedef struct str {
  181.     char        *st_string;    /* the string value */
  182.     struct str    *st_next;    /* pointer to the next string */
  183.     t_attr        st_attr;    /* attr for rule operations */
  184. } STRING, *STRINGPTR;
  185.  
  186.  
  187.  
  188. /* These structs are used in processing of the % rules, and in building
  189.  * the NFA machine that is used to match an arbitrary target string to
  190.  * one of the % rules that is represented by each DFA */
  191.  
  192. typedef int16 statecnt;        /* limits the max number of dfa states    */
  193.  
  194.  
  195. /* Each state of the DFA contains four pieces of information. */
  196. typedef struct st {
  197.     struct st    *no_match;    /* state to go to if no match */
  198.     struct st    *match;        /* state to go to if we do match */
  199.     char        symbol;        /* symbol on which we transit */
  200.     char        action;        /* action to perform if match */
  201. } STATE, *STATEPTR;
  202.  
  203.  
  204. /* Each DFA machine looks like this.  It must have two pointers that represent
  205.  * the value of % in the matched string, and it contains a pointer into the
  206.  * current state, as well as the array of all states. */
  207. typedef struct {
  208.     char        *pstart;    /* start of % string match */
  209.     char        *pend;        /* end of % string match */
  210.     STATEPTR    c_state;    /* current DFA state */
  211.     CELLPTR        node;        /* % target represented by this DFA */
  212.     STATEPTR    states;        /* table of states for the DFA */
  213. } DFA, *DFAPTR;
  214.  
  215.  
  216. /* An NFA is a collection of DFA's.  For each DFA we must know it's current
  217.  * state and where the next NFA is. */
  218. typedef struct nfa_machine {
  219.     DFAPTR        dfa;        /* The DFA for this eps transition */
  220.     char        status;        /* DFA state */
  221.     struct nfa_machine *next;     /* the next DFA in NFA */
  222. } NFA, *NFAPTR;
  223.  
  224.  
  225.  
  226. /* The next struct is used to link together DFA nodes for inference. */
  227.  
  228. typedef struct dfal {
  229.     struct tcell    *dl_meta;    /* link to %-meta cell        */
  230.     struct dfal    *dl_next;    /* next cell on matched DFA list*/
  231.     struct dfal    *dl_prev;    /* prev cell on matched DFA list*/
  232.     struct dfal    *dl_member;    /* used during subset calc    */
  233.     char        dl_delete;    /* used during subset calc    */
  234.     char           *dl_per;    /* value of % for matched DFA   */
  235.     statecnt        dl_state;    /* matched state of the DFA    */
  236.     int        dl_prep;    /* repetion count for the cell    */
  237. } DFALINK, *DFALINKPTR;
  238.  
  239.  
  240. /* This struct is used to store the stack of DFA sets during inference */
  241. typedef struct dfst {
  242.    DFALINKPTR    df_set;            /* pointer to the set        */
  243.    struct dfst *df_next;        /* next element in the stack    */
  244. } DFASET, *DFASETPTR;
  245.  
  246.  
  247. /* We need sets of items during inference, here is the item, we form sets
  248.  * by linking them together. */
  249.  
  250. typedef struct ic {
  251.    CELLPTR    ic_meta;        /* Edge we used to make this cell*/
  252.    DFALINKPTR   ic_dfa;            /* Dfa that we matched against     */
  253.    CELLPTR    ic_setdirroot;        /* setdir root pointer for cell     */
  254.    DFASET       ic_dfastack;        /* set of dfas we're working with*/
  255.    int        ic_dmax;        /* max depth of cycles in graph  */
  256.    char           *ic_name;        /* name of the cell to insert    */
  257.    char        *ic_dir;            /* dir to CD to prior to recurse */
  258.    struct ic   *ic_next;        /* next pointer to link         */
  259.    struct ic   *ic_link;        /* link all ICELL'S together     */
  260.    struct ic   *ic_parent;        /* pointer to post-requisite     */
  261.    char        ic_flag;        /* flag, used for NOINFER only     */
  262.    char         ic_exists;        /* TRUE if prerequisite exists     */
  263. } ICELL, *ICELLPTR;
  264.  
  265. #endif
  266.