diff --git a/src/compilation.h b/src/compilation.h index 7be68fd14c2eee0e293601434f3346b08762034d..ee7d7c04a19c9087a914cf3957d3c11fb43d92dd 100644 --- a/src/compilation.h +++ b/src/compilation.h @@ -1,5 +1,5 @@ /* - * $Id: compilation.h,v 1.17 2000/07/10 14:32:05 grubba Exp $ + * $Id: compilation.h,v 1.18 2000/07/10 18:21:33 grubba Exp $ * * Compilator state push / pop operator construction file * @@ -111,17 +111,17 @@ #ifdef PIKE_DEBUG -#define STRMEMBER(X,Y,Z) \ - PCODE(if(Pike_compiler->X) fatal("Variable %s not deallocated properly.\n",Y);) \ - ZMEMBER(struct pike_string *,X,Z) +#define STRMEMBER(X,Y) \ + PCODE(if(Pike_compiler->X) fatal("Variable " #X " not deallocated properly.\n");) \ + ZMEMBER(struct pike_string *,X,Y) #else -#define STRMEMBER(X,Y,Z) \ - ZMEMBER(struct pike_string *,X,Z) +#define STRMEMBER(X,Y) \ + ZMEMBER(struct pike_string *,X,Y) #endif SNAME(program_state,Pike_compiler) ZMEMBER(INT32,last_line,0) - STRMEMBER(last_file,"last_file",0) + STRMEMBER(last_file,0) ZMEMBER(struct object *,fake_object,0) ZMEMBER(struct program *,new_program,0) ZMEMBER(struct program *,malloc_size_program,0) @@ -135,6 +135,7 @@ ZMEMBER(int,catch_level,0) ZMEMBER(INT32,current_modifiers,0) ZMEMBER(int,varargs,0) + STRMEMBER(last_identifier,0) ZMEMBER(struct mapping *,module_index_cache,0) STACKMEMBER(unsigned char *,type_stackp,type_stack) STACKMEMBER(unsigned char **,pike_type_mark_stackp,pike_type_mark_stack) diff --git a/src/language.yacc b/src/language.yacc index a706bf77b5a858076fd3cce0a000521c401f49cc..9e402c24744acb69a4826c6db11bc7d4c3c2822b 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -109,7 +109,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.199 2000/07/10 15:36:35 grubba Exp $"); +RCSID("$Id: language.yacc,v 1.200 2000/07/10 18:21:33 grubba Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -145,7 +145,6 @@ int low_add_local_name(struct compiler_frame *, struct pike_string *,struct pike_string *,node *); static node *lexical_islocal(struct pike_string *); -static struct pike_string *last_identifier=0; static int inherit_depth; static struct program_state *inherit_state = NULL; @@ -385,9 +384,9 @@ low_program_ref: string_constant } | idents { - if(last_identifier) + if(Pike_compiler->last_identifier) { - ref_push_string(last_identifier); + ref_push_string(Pike_compiler->last_identifier); }else{ push_constant_text(""); } @@ -2439,12 +2438,12 @@ idents2: idents { int i; - if(last_identifier) free_string(last_identifier); - copy_shared_string(last_identifier, $3->u.sval.u.string); + if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); + copy_shared_string(Pike_compiler->last_identifier, $3->u.sval.u.string); - if (((i = find_shared_string_identifier(last_identifier, + if (((i = find_shared_string_identifier(Pike_compiler->last_identifier, Pike_compiler->new_program)) >= 0) || - ((i = really_low_find_shared_string_identifier(last_identifier, + ((i = really_low_find_shared_string_identifier(Pike_compiler->last_identifier, Pike_compiler->new_program, SEE_STATIC| SEE_PRIVATE)) >= 0)) { @@ -2472,7 +2471,7 @@ idents2: idents } else { if (!Pike_compiler->num_parse_error) { if (Pike_compiler->compiler_pass == 2) { - my_yyerror("'%s' not defined in local scope.", last_identifier->str); + my_yyerror("'%s' not defined in local scope.", Pike_compiler->last_identifier->str); $$ = 0; } else { $$ = mknode(F_UNDEFINED, 0, 0); @@ -2493,11 +2492,11 @@ idents2: idents idents: low_idents | idents '.' TOK_IDENTIFIER { - $$=index_node($1, last_identifier?last_identifier->str:NULL, + $$=index_node($1, Pike_compiler->last_identifier?Pike_compiler->last_identifier->str:NULL, $3->u.sval.u.string); free_node($1); - if(last_identifier) free_string(last_identifier); - copy_shared_string(last_identifier, $3->u.sval.u.string); + if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); + copy_shared_string(Pike_compiler->last_identifier, $3->u.sval.u.string); free_node($3); } | '.' TOK_IDENTIFIER @@ -2515,8 +2514,8 @@ idents: low_idents pop_stack(); $$=index_node(tmp, ".", $2->u.sval.u.string); free_node(tmp); - if(last_identifier) free_string(last_identifier); - copy_shared_string(last_identifier, $2->u.sval.u.string); + if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); + copy_shared_string(Pike_compiler->last_identifier, $2->u.sval.u.string); free_node($2); } | idents '.' bad_identifier {} @@ -2576,20 +2575,20 @@ low_idents: TOK_IDENTIFIER { int i; struct efun *f; - if(last_identifier) free_string(last_identifier); - copy_shared_string(last_identifier, $1->u.sval.u.string); + if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); + copy_shared_string(Pike_compiler->last_identifier, $1->u.sval.u.string); - if(($$=lexical_islocal(last_identifier))) + if(($$=lexical_islocal(Pike_compiler->last_identifier))) { /* done, nothing to do here */ - }else if((i=isidentifier(last_identifier))>=0){ + }else if((i=isidentifier(Pike_compiler->last_identifier))>=0){ $$=mkidentifiernode(i); - }else if(!($$=find_module_identifier(last_identifier,1))){ + }else if(!($$=find_module_identifier(Pike_compiler->last_identifier,1))){ if(!Pike_compiler->num_parse_error) { if(Pike_compiler->compiler_pass==2) { - my_yyerror("'%s' undefined.", last_identifier->str); + my_yyerror("'%s' undefined.", Pike_compiler->last_identifier->str); $$=0; }else{ $$=mknode(F_UNDEFINED,0,0); @@ -2608,8 +2607,8 @@ low_idents: TOK_IDENTIFIER #ifdef __CHECKER__ tmp.subtype=0; #endif /* __CHECKER__ */ - if(last_identifier) free_string(last_identifier); - copy_shared_string(last_identifier, $3->u.sval.u.string); + if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); + copy_shared_string(Pike_compiler->last_identifier, $3->u.sval.u.string); tmp.u.mapping=get_builtin_constants(); tmp2=mkconstantsvaluenode(&tmp); $$=index_node(tmp2, "predef", $3->u.sval.u.string); @@ -2627,12 +2626,12 @@ low_idents: TOK_IDENTIFIER if ($1) { int id; - if(last_identifier) free_string(last_identifier); - copy_shared_string(last_identifier, $2->u.sval.u.string); + if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); + copy_shared_string(Pike_compiler->last_identifier, $2->u.sval.u.string); id = low_reference_inherited_identifier(inherit_state, $1, - last_identifier, + Pike_compiler->last_identifier, SEE_STATIC); if (id != -1) { @@ -2642,21 +2641,21 @@ low_idents: TOK_IDENTIFIER } else { $$ = mkidentifiernode(id); } - } else if(ISCONSTSTR(last_identifier, "`->") || - ISCONSTSTR(last_identifier, "`[]")) { + } else if(ISCONSTSTR(Pike_compiler->last_identifier, "`->") || + ISCONSTSTR(Pike_compiler->last_identifier, "`[]")) { $$ = mknode(F_MAGIC_INDEX, mknewintnode($1), mknewintnode(inherit_depth+1)); - } else if(ISCONSTSTR(last_identifier, "`->=") || - ISCONSTSTR(last_identifier, "`[]=")) { + } else if(ISCONSTSTR(Pike_compiler->last_identifier, "`->=") || + ISCONSTSTR(Pike_compiler->last_identifier, "`[]=")) { $$ = mknode(F_MAGIC_SET_INDEX, mknewintnode($1), mknewintnode(inherit_depth+1)); } else { if (inherit_state->new_program->inherits[$1].name) { my_yyerror("Undefined identifier %s::%s.", inherit_state->new_program->inherits[$1].name->str, - last_identifier->str); + Pike_compiler->last_identifier->str); } else { - my_yyerror("Undefined identifier %s.", last_identifier->str); + my_yyerror("Undefined identifier %s.", Pike_compiler->last_identifier->str); } $$=0; } @@ -2672,8 +2671,8 @@ low_idents: TOK_IDENTIFIER { int e,i; - if(last_identifier) free_string(last_identifier); - copy_shared_string(last_identifier, $2->u.sval.u.string); + if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier); + copy_shared_string(Pike_compiler->last_identifier, $2->u.sval.u.string); $$=0; for(e=1;e<(int)Pike_compiler->new_program->num_inherits;e++) @@ -2898,7 +2897,7 @@ string: TOK_STRING * Some error-handling */ -/* FIXME: Should probably set last_identifier. */ +/* FIXME: Should probably set Pike_compiler->last_identifier. */ bad_identifier: bad_expr_ident | TOK_CLASS { yyerror("class is a reserved word."); } @@ -3140,9 +3139,4 @@ static node *lexical_islocal(struct pike_string *str) void cleanup_compiler(void) { - if(last_identifier) - { - free_string(last_identifier); - last_identifier=0; - } } diff --git a/src/program.c b/src/program.c index 37a559aea3750d03fd12f17d413e754bacb7fae2..3c2f8787c236995282666251ba6f00fb649e5008 100644 --- a/src/program.c +++ b/src/program.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: program.c,v 1.247 2000/07/07 01:48:08 hubbe Exp $"); +RCSID("$Id: program.c,v 1.248 2000/07/10 18:21:32 grubba Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -1062,6 +1062,12 @@ static void toss_compilation_resources(void) while(Pike_compiler->compiler_frame) pop_compiler_frame(); + if(Pike_compiler->last_identifier) + { + free_string(Pike_compiler->last_identifier); + Pike_compiler->last_identifier=0; + } + if(Pike_compiler->last_file) { free_string(Pike_compiler->last_file); @@ -1378,7 +1384,7 @@ struct program *debug_end_program(void) * Allocate needed for this program in the object structure. * An offset to the data is returned. */ -SIZE_T low_add_storage(SIZE_T size, SIZE_T alignment, int modulo_orig) +size_t low_add_storage(size_t size, size_t alignment, int modulo_orig) { long offset; int modulo; @@ -1946,7 +1952,7 @@ int isidentifier(struct pike_string *s) int low_define_variable(struct pike_string *name, struct pike_string *type, INT32 flags, - INT32 offset, + size_t offset, INT32 run_time_type) { int n; @@ -1991,7 +1997,7 @@ int low_define_variable(struct pike_string *name, int map_variable(char *name, char *type, INT32 flags, - INT32 offset, + size_t offset, INT32 run_time_type) { int ret; @@ -2012,7 +2018,7 @@ int map_variable(char *name, int quick_map_variable(char *name, int name_length, - INT32 offset, + size_t offset, char *type, int type_length, INT32 run_time_type, diff --git a/src/program.h b/src/program.h index 7a494c06f90599a836bc4cf91b4e35d6ded1d82e..6741f5372b7ca232a9cf5a926e2d1285d50734b2 100644 --- a/src/program.h +++ b/src/program.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: program.h,v 1.93 2000/06/26 16:43:09 grubba Exp $ + * $Id: program.h,v 1.94 2000/07/10 18:21:33 grubba Exp $ */ #ifndef PROGRAM_H #define PROGRAM_H @@ -279,7 +279,7 @@ struct program unsigned INT32 num_clones; #endif /* PROFILING */ - SIZE_T total_size; + size_t total_size; #define FOO(NUMTYPE,TYPE,NAME) TYPE * NAME ; #include "program_areas.h" @@ -346,7 +346,7 @@ int sizeof_variable(int run_time_type); void check_program(struct program *p); struct program *end_first_pass(int finish); struct program *debug_end_program(void); -SIZE_T low_add_storage(SIZE_T size, SIZE_T alignment, int modulo_orig); +size_t low_add_storage(size_t size, size_t alignment, int modulo_orig); void set_init_callback(void (*init)(struct object *)); void set_exit_callback(void (*exit)(struct object *)); void set_gc_recurse_callback(void (*m)(struct object *)); @@ -378,16 +378,16 @@ int isidentifier(struct pike_string *s); int low_define_variable(struct pike_string *name, struct pike_string *type, INT32 flags, - INT32 offset, + size_t offset, INT32 run_time_type); int map_variable(char *name, char *type, INT32 flags, - INT32 offset, + size_t offset, INT32 run_time_type); int quick_map_variable(char *name, int name_length, - INT32 offset, + size_t offset, char *type, int type_length, INT32 run_time_type,