Main Page | Class List | Directories | File List | Class Members | File Members

compilation.h

Go to the documentation of this file.
00001 /*
00002 || This file is part of Pike. For copyright information see COPYRIGHT.
00003 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
00004 || for more information.
00005 || $Id: compilation.h,v 1.31 2004/03/13 14:45:05 grubba Exp $
00006 */
00007 
00008 /*
00009  * Compilator state push / pop operator construction file
00010  *
00011  * (Can you tell I like macros?)
00012  */
00013 
00014 /*
00015  * IMEMBER: do not reset this member when pushing
00016  * DMEMBER: This member should be the same when popping as when pushing.
00017  * ZMEMBER: reset this member to zero when pushing
00018  * STACKMEMBER: Like IMEMBER, but is not allowed to become more when popping
00019  *
00020  * defining STRUCT defines the structures
00021  * defining DECLARE creates global vars for saving linked list
00022  *                  of these lists...
00023  * defining PUSH pushes the selected state(s) on the stack(s)
00024  * defining POP pops the selected state(s) from the stack(s)
00025  *
00026  * define PROGRAM_STATE to select the program state
00027  */
00028 
00029 #ifdef PIKE_DEBUG
00030 #define DO_DEBUG_CODE(X) X
00031 #else
00032 #define DO_DEBUG_CODE(X)
00033 #endif
00034 
00035 #ifdef STRUCT
00036 #define IMEMBER(X,Y,Z) X Y ;
00037 #define DMEMBER(X,Y,Z) X Y ;
00038 #define STACKMEMBER(X,Y,Z) X Y ;
00039 #define IMEMBER2(X,Y,Z,Q) X Y Z ;
00040 #define ZMEMBER(X,Y,Z) X Y ;
00041 #define ZMEMBER2(X,Y,Z,Q) X Y Z ;
00042 #define SNAME(X,Y) struct X { struct X *previous;
00043 #define SEND };
00044 #endif
00045 
00046 #ifdef EXTERN
00047 #define IMEMBER(X,Y,Z)
00048 #define DMEMBER(X,Y,Z)
00049 #define STACKMEMBER(X,Y,z)
00050 #define IMEMBER2(X,Y,Z,Q)
00051 #define ZMEMBER(X,Y,Z)
00052 #define ZMEMBER2(X,Y,Z,Q)
00053 #define SNAME(X,Y) extern struct X * Y;
00054 #define SEND
00055 #endif
00056 
00057 #ifdef DECLARE
00058 #define IMEMBER(X,Y,Z) Z,
00059 #define DMEMBER(X,Y,Z) Z,
00060 #define STACKMEMBER(X,Y,Z) Z,
00061 #define IMEMBER2(X,Y,Z,Q) Q,
00062 #define ZMEMBER(X,Y,Z) Z,
00063 #define ZMEMBER2(X,Y,Z,Q) Q,
00064 #define SNAME(X,Y) \
00065   extern struct X PIKE_CONCAT(Y,_base); \
00066   struct X * Y = & PIKE_CONCAT(Y,_base); \
00067   struct X PIKE_CONCAT(Y,_base) = { 0, 
00068 #define SEND };
00069 #endif
00070 
00071 #ifdef PUSH
00072 #define IMEMBER(X,Y,Z) MEMCPY((char *)&(nEw->Y), (char *)&(Pike_compiler->Y), sizeof(nEw->Y));
00073 #define DMEMBER(X,Y,Z) IMEMBER(X,Y)
00074 #define STACKMEMBER(X,Y,Z) (nEw->Y=Pike_compiler->Y);
00075 #define IMEMBER2(X,Y,Z,Q) IMEMBER(X,Y)
00076 #define ZMEMBER(X,Y,Z) MEMSET((char *)&(nEw->Y), 0, sizeof(nEw->Y));
00077 #define ZMEMBER2(X,Y,Z,Q) ZMEMBER(X,Y)
00078 #define SNAME(X,Y) { \
00079       struct X *nEw; \
00080       nEw=ALLOC_STRUCT(X); \
00081       nEw->previous=Pike_compiler;
00082 #define SEND \
00083       Pike_compiler=nEw; \
00084       }
00085 
00086 #endif
00087 
00088 
00089 #ifdef POP
00090 #define IMEMBER(X,Y,Z) 
00091 #define IMEMBER2(X,Y,Z,Q) IMEMBER(X,Y)
00092 #define ZMEMBER(X,Y,Z) 
00093 #define ZMEMBER2(X,Y,Z,Q) ZMEMBER(X,Y)
00094 
00095 #define DMEMBER(X,Y,Z) DO_DEBUG_CODE( \
00096     if(MEMCMP((char *)&(Pike_compiler->Y), (char *)&(oLd->Y), sizeof(oLd->Y))) \
00097       Pike_fatal("Variable " #Y " became whacked during compilation.\n"); ) \
00098   IMEMBER(X,Y)
00099 
00100 #define STACKMEMBER(X,Y,Z) DO_DEBUG_CODE( \
00101     if(Pike_compiler->Y < oLd->Y) \
00102       Pike_fatal("Stack " #Y " shrunk %ld steps compilation, currently: %p.\n", \
00103             PTRDIFF_T_TO_LONG(oLd->Y - Pike_compiler->Y), Pike_compiler->Y); )
00104 
00105 #define SNAME(X,Y) { \
00106       struct X *oLd=Pike_compiler->previous;
00107 
00108 #define SEND \
00109      free((char *)Pike_compiler); \
00110      Pike_compiler=oLd; \
00111     }
00112 
00113 #define PCODE(X) X
00114 #else
00115 #define PCODE(X)
00116 #endif
00117 
00118 
00119 #ifdef PIKE_DEBUG
00120 #define STRMEMBER(X,Y) \
00121   PCODE(if(Pike_compiler->X) Pike_fatal("Variable " #X " not deallocated properly.\n");) \
00122   ZMEMBER(struct pike_string *,X,Y)
00123 #else
00124 #define STRMEMBER(X,Y) \
00125   ZMEMBER(struct pike_string *,X,Y)
00126 #endif
00127 
00128   SNAME(program_state,Pike_compiler)
00129   ZMEMBER(INT32,last_line,0)
00130   STRMEMBER(last_file,0)
00131   ZMEMBER(struct object *,fake_object,0)
00132   ZMEMBER(struct program *,new_program,0)
00133   ZMEMBER(struct program *,malloc_size_program,0)
00134   ZMEMBER(node *,init_node,0)
00135   ZMEMBER(INT32,last_pc,0)
00136   ZMEMBER(int,num_parse_error,0)
00137   ZMEMBER(struct compiler_frame *,compiler_frame,0)
00138   ZMEMBER(INT32,num_used_modules,0)
00139   IMEMBER(int,compiler_pass,0)
00140   ZMEMBER(int,local_class_counter,0)
00141   ZMEMBER(int,catch_level,0)
00142   ZMEMBER(INT32,current_modifiers,0)
00143   ZMEMBER(int,varargs,0)
00144   STRMEMBER(last_identifier,0)
00145   ZMEMBER(struct mapping *,module_index_cache,0)
00146   STACKMEMBER(struct pike_type **,type_stackp,type_stack)
00147   STACKMEMBER(struct pike_type ***,pike_type_mark_stackp,pike_type_mark_stack)
00148   ZMEMBER(INT32,parent_identifier,0)
00149   IMEMBER(int, compat_major, PIKE_MAJOR_VERSION)
00150   IMEMBER(int, compat_minor, PIKE_MINOR_VERSION)
00151   ZMEMBER(int, flags, 0)
00152   ZMEMBER(struct compilation *,compiler,0)
00153   SEND
00154 
00155 #undef PCODE
00156 #undef STRMEMBER
00157 #undef IMEMBER
00158 #undef DMEMBER
00159 #undef ZMEMBER
00160 #undef IMEMBER2
00161 #undef ZMEMBER2
00162 #undef SNAME
00163 #undef SEND
00164 #undef STACKMEMBER
00165 
00166 #undef EXTERN
00167 #undef STRUCT
00168 #undef PUSH
00169 #undef POP
00170 #undef DECLARE
00171 #undef DO_DEBUG_CODE

Generated on Fri Jul 22 23:44:24 2005 for Pike by  doxygen 1.3.9.1