5c8e891995-10-29Fredrik Hübinette (Hubbe) /*
021fa92000-07-09Henrik Grubbström (Grubba)  * $Id: compilation.h,v 1.15 2000/07/09 18:32:53 grubba Exp $
24ddc71998-03-28Henrik Grubbström (Grubba)  *
5c8e891995-10-29Fredrik Hübinette (Hubbe)  * Compilator state push / pop operator construction file * * (Can you tell I like macros?) */ /*
0f39a41999-12-29Martin Stjernholm  * IMEMBER: do not reset this member when pushing
fb2f661998-11-05Fredrik Hübinette (Hubbe)  * DMEMBER: This member should be the same when popping as when pushing.
5c8e891995-10-29Fredrik Hübinette (Hubbe)  * ZMEMBER: reset this member to zero when pushing
fb2f661998-11-05Fredrik Hübinette (Hubbe)  * STACKMEMBER: Like IMEMBER, but is not allowed to become more when popping
5c8e891995-10-29Fredrik Hübinette (Hubbe)  * * defining STRUCT defines the structures * defining DECLARE creates global vars for saving linked list * of these lists... * defining PUSH pushes the selected state(s) on the stack(s) * defining POP pops the selected state(s) from the stack(s) * * define PROGRAM_STATE to select the program state */
71f3a21998-11-22Fredrik Hübinette (Hubbe) #ifdef PIKE_DEBUG
fb2f661998-11-05Fredrik Hübinette (Hubbe) #define DO_DEBUG_CODE(X) X #else #define DO_DEBUG_CODE(X) #endif
5c8e891995-10-29Fredrik Hübinette (Hubbe) #ifdef STRUCT
9f44771995-11-20Fredrik Hübinette (Hubbe) #define IMEMBER(X,Y) X Y ;
fb2f661998-11-05Fredrik Hübinette (Hubbe) #define DMEMBER(X,Y) X Y ; #define STACKMEMBER(X,Y) X Y ;
9f44771995-11-20Fredrik Hübinette (Hubbe) #define IMEMBER2(X,Y,Z) X Y Z ; #define ZMEMBER(X,Y) X Y ; #define ZMEMBER2(X,Y,Z) X Y Z ;
5c8e891995-10-29Fredrik Hübinette (Hubbe) #define SNAME(X,Y) struct X { struct X *previous; #define SEND }; #endif #ifdef DECLARE
9f44771995-11-20Fredrik Hübinette (Hubbe) #define IMEMBER(X,Y)
fb2f661998-11-05Fredrik Hübinette (Hubbe) #define DMEMBER(X,Y) #define STACKMEMBER(X,Y)
9f44771995-11-20Fredrik Hübinette (Hubbe) #define IMEMBER2(X,Y,Z) #define ZMEMBER(X,Y) #define ZMEMBER2(X,Y,Z)
5c8e891995-10-29Fredrik Hübinette (Hubbe) #define SNAME(X,Y) static struct X * Y = 0; #define SEND #endif #ifdef PUSH
9f44771995-11-20Fredrik Hübinette (Hubbe) #define IMEMBER(X,Y) MEMCPY((char *)&(oLd->Y), (char *)&(Y), sizeof(Y));
fb2f661998-11-05Fredrik Hübinette (Hubbe) #define DMEMBER(X,Y) IMEMBER(X,Y) #define STACKMEMBER(X,Y) (oLd->Y=Y);
9f44771995-11-20Fredrik Hübinette (Hubbe) #define IMEMBER2(X,Y,Z) IMEMBER(X,Y) #define ZMEMBER(X,Y) MEMCPY((char *)&(oLd->Y), (char *)&(Y), sizeof(Y)); \ MEMSET((char *)&(Y), 0, sizeof(Y)); #define ZMEMBER2(X,Y,Z) ZMEMBER(X,Y)
5c8e891995-10-29Fredrik Hübinette (Hubbe) #define SNAME(X,Y) { \ struct X *oLd; \ oLd=ALLOC_STRUCT(X); \ oLd->previous=Y; Y=oLd; #define SEND }
fb2f661998-11-05Fredrik Hübinette (Hubbe) 
5c8e891995-10-29Fredrik Hübinette (Hubbe) #endif #ifdef POP
9f44771995-11-20Fredrik Hübinette (Hubbe) #define IMEMBER(X,Y) MEMCPY((char *)&(Y), (char *)&(oLd->Y), sizeof(Y)); #define IMEMBER2(X,Y,Z) IMEMBER(X,Y) #define ZMEMBER(X,Y) MEMCPY((char *)&(Y), (char *)&(oLd->Y), sizeof(Y)); #define ZMEMBER2(X,Y,Z) ZMEMBER(X,Y)
fb2f661998-11-05Fredrik Hübinette (Hubbe)  #define DMEMBER(X,Y) DO_DEBUG_CODE( \ if(MEMCMP((char *)&(Y), (char *)&(oLd->Y), sizeof(Y))) \ fatal("Variable " #Y " became whacked during compilation.\n"); ) \ IMEMBER(X,Y) #define STACKMEMBER(X,Y) DO_DEBUG_CODE( \ if(Y < oLd->Y) \ fatal("Stack " #Y " shrunk %d steps compilation, currently: %p.\n",oLd->Y - Y,Y); ) \ Y=oLd->Y;
5c8e891995-10-29Fredrik Hübinette (Hubbe) #define SNAME(X,Y) { \ struct X *oLd; \ oLd=Y; Y=oLd->previous;
5ebdb51996-09-22Fredrik Hübinette (Hubbe) #define SEND free((char *)oLd); \
5c8e891995-10-29Fredrik Hübinette (Hubbe)  }
2066df1995-11-15Fredrik Hübinette (Hubbe) #define PCODE(X) X #else #define PCODE(X) #endif
71f3a21998-11-22Fredrik Hübinette (Hubbe) #ifdef PIKE_DEBUG
2066df1995-11-15Fredrik Hübinette (Hubbe) #define STRMEMBER(X,Y) \ PCODE(if(X) fatal("Variable %s not deallocated properly.\n",Y);) \
06983f1996-09-22Fredrik Hübinette (Hubbe)  ZMEMBER(struct pike_string *,X)
2066df1995-11-15Fredrik Hübinette (Hubbe) #else
9f44771995-11-20Fredrik Hübinette (Hubbe) #define STRMEMBER(X,Y) \
06983f1996-09-22Fredrik Hübinette (Hubbe)  ZMEMBER(struct pike_string *,X)
5c8e891995-10-29Fredrik Hübinette (Hubbe) #endif SNAME(program_state,previous_program_state)
9f44771995-11-20Fredrik Hübinette (Hubbe)  ZMEMBER(INT32,last_line)
2066df1995-11-15Fredrik Hübinette (Hubbe)  STRMEMBER(last_file,"last_file")
6d22541998-01-28Fredrik Hübinette (Hubbe)  ZMEMBER(struct object *,fake_object)
b1f4eb1998-01-13Fredrik Hübinette (Hubbe)  ZMEMBER(struct program *,new_program) ZMEMBER(struct program *,malloc_size_program)
9f44771995-11-20Fredrik Hübinette (Hubbe)  ZMEMBER(node *,init_node) ZMEMBER(INT32,last_pc) ZMEMBER(int,num_parse_error)
b1f4eb1998-01-13Fredrik Hübinette (Hubbe)  ZMEMBER(struct compiler_frame *,compiler_frame)
05590d1998-04-23Fredrik Hübinette (Hubbe)  ZMEMBER(INT32,num_used_modules)
b1f4eb1998-01-13Fredrik Hübinette (Hubbe)  IMEMBER(int,compiler_pass)
51ffdb1998-01-19Fredrik Hübinette (Hubbe)  ZMEMBER(int,local_class_counter)
9649491998-02-27Fredrik Hübinette (Hubbe)  ZMEMBER(int,catch_level)
021fa92000-07-09Henrik Grubbström (Grubba)  ZMEMBER(INT32,current_modifiers)
05590d1998-04-23Fredrik Hübinette (Hubbe)  ZMEMBER(struct mapping *,module_index_cache)
fb2f661998-11-05Fredrik Hübinette (Hubbe)  STACKMEMBER(unsigned char *,type_stackp) STACKMEMBER(unsigned char **,pike_type_mark_stackp)
5c8e891995-10-29Fredrik Hübinette (Hubbe)  SEND
b8cda21997-01-21Fredrik Hübinette (Hubbe) 
2066df1995-11-15Fredrik Hübinette (Hubbe) #undef PCODE #undef STRMEMBER
5c8e891995-10-29Fredrik Hübinette (Hubbe) #undef IMEMBER
fb2f661998-11-05Fredrik Hübinette (Hubbe) #undef DMEMBER
5c8e891995-10-29Fredrik Hübinette (Hubbe) #undef ZMEMBER
9f44771995-11-20Fredrik Hübinette (Hubbe) #undef IMEMBER2 #undef ZMEMBER2
5c8e891995-10-29Fredrik Hübinette (Hubbe) #undef SNAME #undef SEND
84cb1f1998-11-08Fredrik Hübinette (Hubbe) #undef STACKMEMBER
b1f4eb1998-01-13Fredrik Hübinette (Hubbe)  #undef STRUCT #undef PUSH #undef POP #undef DECLARE
fb2f661998-11-05Fredrik Hübinette (Hubbe) #undef DO_DEBUG_CODE