Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals  

data.h

00001  /*
00002   * plint/prog/data.h : data structures & declarations of program's variables
00003   * 
00004   * Time-stamp: <2003-01-08 21:28:04 gseba>
00005   * 
00006   * Copyright (C) Sebastian Glita, email: gseba@users.sourceforge.net
00007   * 
00008   * This file is part of plint.
00009   * 
00010   * plint is free software; you can  redistribute it and/or modify it under the
00011   * terms of the  GNU General Public License as published  by the Free Software
00012   * Foundation; either version 2, or (at your option) any later version.
00013   *
00014   * plint  is distributed  in the  hope  that it  will be  useful, but  WITHOUT
00015   * ANY  WARRANTY; without  even  the implied  warranty  of MERCHANTABILITY  or
00016   * FITNESS FOR A  PARTICULAR PURPOSE.  See the GNU  General Public License for
00017   * more details.
00018   * 
00019   * You should  have received a  copy of the  GNU General Public  License along
00020   * with  plint; see  the file  COPYING.  If  not, write  to the  Free Software
00021   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA USA.
00022   *
00023   */
00024 
00025 #ifndef PLINT_PROG_DATA_H
00026 #define PLINT_PROG_DATA_H
00027 
00028 #include "share/common.h"
00029 #include "share/defines.h"
00030 #include "share/functions.h"
00031 
00032 #include "share/hash.h"
00033 #include "share/cache.h"
00034 #include "share/slot.h"
00035 
00036 #include "type.h"
00037 
00038 #include <misc/sys.h>
00039 
00040 #define PLINT_OUT_LEN (10 + 1 + 2 + 2 * (sizeof(pid_t) + 2 * sizeof(unsigned int)) + 1)
00041 
00042 
00043 #include "types.h"
00044 
00045 #include "block.h"
00046 #define PLINT_RET_MEM (plint->prog.stack.top->block.ret)
00047 
00048 #define PLINT_WRAP_GET_EXIT (plint->prog.stack.top->down->block.arg.wrap.exit)
00049 #define PLINT_WRAP_SET_EXIT(__x__) (PLINT_WRAP_GET_EXIT = (__x__))
00050 #define PLINT_WRAP_GET_RET (plint->prog.stack.top->down->block.arg.wrap.ret)
00051 #define PLINT_WRAP_SET_RET(__x__) (PLINT_WRAP_GET_RET = (__x__))
00052 #define PLINT_WRAP_GET_OWN_DATA (plint->prog.stack.top->down->block.arg.wrap.data)
00053 #define PLINT_WRAP_SET_OWN_DATA(__x__) (PLINT_WRAP_GET_OWN_DATA = (__x__))
00054 #define PLINT_WRAP_GET_ABORT_FUNC (plint->prog.stack.top->down->block.arg.wrap.abort)
00055 #define PLINT_WRAP_SET_ABORT_FUNC(__x__) (PLINT_WRAP_GET_ABORT_FUNC = (__x__))
00056 #define PLINT_WRAP_GET_POP_FUNC (plint->prog.stack.top->down->block.arg.wrap.pop)
00057 #define PLINT_WRAP_SET_POP_FUNC(__x__) (PLINT_WRAP_GET_POP_FUNC = (__x__))
00058 #define PLINT_WRAP_GET_CONTROL_FUNC (plint->prog.stack.top->down->block.arg.wrap.control)
00059 #define PLINT_WRAP_SET_CONTROL_FUNC(__x__) (PLINT_WRAP_GET_CONTROL_FUNC = (__x__))
00060 
00061 
00062 
00063 struct _plint_list
00064 {
00065 
00066   plint_stack_t home;
00067   plint_list_t next;
00068   hashindex_t name;
00069   plint_mem_t var;
00070 
00071   flag_t touch:1;
00072 
00073 };
00074 
00075 struct _plint_proc
00076 {
00077   hashindex_t name /* if bad this isn't a procedure */, * args /* if 0 no arguments */;
00078   size_t arrity;
00079 
00080   /* even if name is bad, comparison is valid */
00081 #define PROC_SIG_EQU(__x__, __y__) (HASH_INDEX_EQU((__x__).name, (__y__).name) && (__x__).arrity == (__y__).arrity)
00082 
00083 };
00084 
00085 typedef enum
00086 {
00087 
00088   PLINT_FRM_PROC,
00089   PLINT_FRM_METH,
00090   PLINT_FRM_NORM,
00091 
00092 } plint_efrm_t;
00093 
00094 struct _plint_tree
00095 {
00096   plint_eblk_t blk;                     
00097   plint_efrm_t frm;                     
00099   plint_proc_t proc;                    
00101   plint_tree_t prnt;                    
00103   flag_t host_id:1;                     
00104   union {
00105     plint_tree_t d;                             
00106     plint_tree_t * i;                           
00107   } host;                               
00109   plint_tree_t * chlds;                 
00110   int nchlds;                           
00112   int flag;  /* -1(11111111111111111111111111111111) : insertion point, still parsing
00113               * -2(11111111111111111111111111111110) : insertion point, parsing done
00114               * +1(00000000000000000000000000000001) : normal point   , still parsing
00115               * +2(00000000000000000000000000000010) : normal point   , parsing done
00116               * +4(00000000000000000000000000000100) : normal point   , parsing done, was called
00117               * +6(00000000000000000000000000000110) : normal point   , parsing done, was called and its most recent instance written on the stack backtrace
00118               */
00119 
00120 #define PLINT_TREE_NOPRC(__r__) HASH_INDEX_DOBAD((__r__)->proc.name)
00121 #define PLINT_TREE_ISPRC(__r__) (!HASH_INDEX_ISBAD((__r__)->proc.name))
00122 #define PLINT_TREE_ISINS(__r__) ((__r__)->flag & ~(~(unsigned int)0 >> 1))
00123 #define PLINT_TREE_ISPRS(__r__) ((__r__)->flag & ~(~(unsigned int)0 << 1))
00124 #define PLINT_TREE_ISWRP(__r__) ((__r__)->blk == PLINT_BLK_WRAP)
00125 
00126   /* what is ~(~0 << 1) ? :-) */
00127 
00128   int level;                            
00130   FILE * file;                          
00131   char * srcfile;                       
00133   plint_stack_t top;                    
00135   slot_key_t user;                      
00137 };
00138 
00139 typedef enum
00140 {
00141 
00142   PLINT_INS_INSERT,
00143   PLINT_INS_INCLUD,
00144 
00145 } plint_eins_t;
00146 
00147 struct _plint_insert
00148 {
00149 
00150   plint_eins_t type;
00151   plint_insert_t down;
00152   file_t file;                          
00153   plint_tree_t point;                   
00154   char * dir, * base;
00155   int line;
00156   int level;
00157 
00158   noref_t count;                        
00160 };
00161 
00162 
00163 struct _plint_include
00164 {
00165 
00166   plint_insert_t ins;
00167   plint_include_t next;
00168 
00169 };
00170 
00171 
00172 struct _plint_include_stack
00173 {
00174 
00175   plint_include_t head;
00176   plint_include_stack_t down;
00177 
00178 };
00179 
00180 
00181 struct _plint_insprnt
00182 {
00183 
00184   plint_tree_t insp;
00185   plint_tree_t prnt;
00186   plint_insprnt_t next;
00187   
00188 };
00189 
00190 
00191 struct _plint_stack
00192 {
00193 
00194   plint_stack_t up;
00195   plint_stack_t down;
00196   plint_stack_t proc;
00197   plint_list_t head;
00198   size_t count;
00199 
00200 #define PLINT_BLOCK__(__s__) ((__s__)->head)
00201 #define PLINT_METH_SELF(__s__) ((__s__)->proc->head->next)
00202 #define PLINT_ARGV (plint->prog.stack.bot->head->next)
00203 #define PLINT_ARGO (plint->prog.stack.bot->head->next->next)
00204 
00205   plint_block_t block;
00206   plint_insprnt_t insprnt;
00207 
00208 };
00209 
00210 /*
00211 
00212   This is how it looks: a source file like:
00213 
00214    plot name {
00215        ...
00216    }
00217 
00218   has ... inside a (top) block which is inside the (top) procedure `name'.
00219 
00220   So it is equivalent with:
00221   procedure name {
00222     {
00223        ...
00224     }
00225   }
00226 
00227   tree_t
00228   0 -> (root = top procedure) --chlds[0]--> (top block) --chlds[i]--> ...
00229 
00230   stack_t
00231   0 ----up---> dummy ----up---> (bot <=> top procedure) ----up---> (<=> top block) ----up---> ...
00232     <--down---       <--down---                         <--down---                 <--down---
00233 
00234   The top block has the equivalence of the top procedure !!!
00235   That means that from the programmer's point of view there is no extra level between ... and top procedure,
00236   in which case would have been possible to use both `1_' and `2_' variables.
00237 
00238   If we're on the stack `s', the test to see if we're on the top procedure is: `s->down == plint->prog.stack.bot' !!!
00239 
00240  */
00241 
00242 
00243 __BEGIN_DECLS
00244 
00245 inline int plint_tree_user_new(plint_tree_t TREE);
00246 inline int plint_tree_user_del(plint_tree_t TREE, int TYPE);
00247 inline void plint_tree_user_set(plint_tree_t TREE, int TYPE, void * DATA);
00248 inline void * plint_tree_user_get(plint_tree_t TREE, int TYPE);
00249 int plint_tree_user_slot_add(slot_key_t SLOT, plint_tree_t TREE, void * DATA);
00250 int plint_tree_user_slot_rem(slot_key_t SLOT, plint_tree_t TREE);
00251 inline void * plint_tree_user_slot_get(slot_key_t SLOT, plint_tree_t TREE);
00252 
00253 void plint_proc_log(FILE * F, plint_tree_t TREE);
00254 
00255 inline plint_tree_t plint_tree_non_ins(plint_tree_t TREE);
00256 inline plint_tree_t plint_tree_non_ins_wrp(plint_tree_t TREE);
00257 #define plint_tree_non_wrp_ins plint_tree_non_ins_wrp
00258 inline plint_tree_t plint_tree_host(plint_tree_t TREE);
00259 
00260 plint_tree_t plint_proc_lup_sig(plint_tree_t TREE);
00261 int plint_proc_lup_ptr(plint_tree_t TREE);
00262 
00263 plint_stack_t plint_stack_block(int);
00264 
00265 __END_DECLS
00266 
00267 
00268 #endif

Generated on Thu Jan 9 19:02:37 2003 for plint by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002