diff --git a/src/object.c b/src/object.c index 3386be3a919562f52bccf59f99674605aa538823..39463d5fe76653249472b7249c6d8ef84d84dd3b 100644 --- a/src/object.c +++ b/src/object.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: object.c,v 1.176 2001/07/02 20:09:18 mast Exp $"); +RCSID("$Id: object.c,v 1.177 2001/07/03 17:01:49 grubba Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -360,6 +360,8 @@ PMOD_EXPORT struct object *get_master(void) inside = 1; + /* fprintf(stderr, "Need a new master object...\n"); */ + if(!master_program) { struct pike_string *s; @@ -373,6 +375,8 @@ PMOD_EXPORT struct object *get_master(void) return 0; /* crash? */ } + /* fprintf(stderr, "Master file: \"%s\"\n", master_file); */ + tmp=xalloc(strlen(master_file)+3); MEMCPY(tmp, master_file, strlen(master_file)+1); @@ -396,6 +400,10 @@ PMOD_EXPORT struct object *get_master(void) { JMP_BUF tmp; + /* fprintf(stderr, "Trying precompiled file \"%s.o\"...\n", + * master_file); + */ + /* Moved here to avoid gcc warning: "might be clobbered". */ push_string(s); push_int(0); @@ -426,12 +434,21 @@ PMOD_EXPORT struct object *get_master(void) #endif } + + /* fprintf(stderr, "Reading master: \"%s\"...\n", master_file); */ + s=low_read_file(master_file); if(s) { push_string(s); push_text(master_file); + + /* fprintf(stderr, "Calling cpp()...\n"); */ + f_cpp(2); + + /* fprintf(stderr, "Calling compile()...\n"); */ + f_compile(1); compiled: @@ -447,13 +464,20 @@ PMOD_EXPORT struct object *get_master(void) Pike_error("Couldn't load master program. (%s)\n",master_file); } } + + /* fprintf(stderr, "Cloning master...\n"); */ + master_object=low_clone(master_program); debug_malloc_touch(master_object); debug_malloc_touch(master_object->storage); + /* fprintf(stderr, "Initializing master...\n"); */ + call_c_initializers(master_object); call_pike_initializers(master_object,0); + /* fprintf(stderr, "Master loaded.\n"); */ + inside = 0; return master_object; } @@ -604,6 +628,10 @@ void destruct(struct object *o) for(q=0;q<(int)pike_frame->context.prog->num_variable_index;q++) { int d=pike_frame->context.prog->variable_index[q]; + + if (IDENTIFIER_IS_ALIAS(pike_frame->context.prog->identifiers[d]. + identifier_flags)) + continue; if(pike_frame->context.prog->identifiers[d].run_time_type == T_MIXED) { @@ -1290,6 +1318,10 @@ PMOD_EXPORT void gc_mark_object_as_referenced(struct object *o) for(q=0;q<(int)pike_frame->context.prog->num_variable_index;q++) { int d=pike_frame->context.prog->variable_index[q]; + + if (IDENTIFIER_IS_ALIAS(pike_frame->context.prog->identifiers[d]. + identifier_flags)) + continue; if(pike_frame->context.prog->identifiers[d].run_time_type == T_MIXED) { @@ -1347,6 +1379,10 @@ PMOD_EXPORT void real_gc_cycle_check_object(struct object *o, int weak) { int d=pike_frame->context.prog->variable_index[q]; + if (IDENTIFIER_IS_ALIAS(pike_frame->context.prog->identifiers[d]. + identifier_flags)) + continue; + if(pike_frame->context.prog->identifiers[d].run_time_type == T_MIXED) { struct svalue *s; @@ -1408,6 +1444,10 @@ static inline void gc_check_object(struct object *o) { int d=pike_frame->context.prog->variable_index[q]; + if (IDENTIFIER_IS_ALIAS(pike_frame->context.prog->identifiers[d]. + identifier_flags)) + continue; + if(pike_frame->context.prog->identifiers[d].run_time_type == T_MIXED) { struct svalue *s; @@ -1721,14 +1761,27 @@ void check_object(struct object *o) if(o == Pike_compiler->fake_object) return; - if(o->next && o->next->prev !=o) + if(o->next) { - describe(o); - fatal("Object check: o->next->prev != o\n"); + if (o->next == o) + { + describe(o); + fatal("Object check: o->next == o\n"); + } + if (o->next->prev !=o) + { + describe(o); + fatal("Object check: o->next->prev != o\n"); + } } - + if(o->prev) { + if (o->prev == o) + { + describe(o); + fatal("Object check: o->prev == o\n"); + } if(o->prev->next != o) { describe(o); diff --git a/src/program.c b/src/program.c index 7f46d485bc276a57d506d9de9290dd187b8dde91..f9fc22f3be978a148f4a5ebd40031f9b23235017 100644 --- a/src/program.c +++ b/src/program.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: program.c,v 1.346 2001/07/03 04:30:21 hubbe Exp $"); +RCSID("$Id: program.c,v 1.347 2001/07/03 17:01:48 grubba Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -2776,7 +2776,11 @@ int low_define_variable(struct pike_string *name, copy_shared_string(dummy.name, name); copy_pike_type(dummy.type, type); - dummy.identifier_flags = 0; + if (flags & ID_ALIAS) { + dummy.identifier_flags = IDENTIFIER_ALIAS; + } else { + dummy.identifier_flags = 0; + } dummy.run_time_type=run_time_type; dummy.func.offset=offset - Pike_compiler->new_program->inherits[0].storage_offset; #ifdef PROFILING @@ -2885,8 +2889,7 @@ int define_variable(struct pike_string *name, if(n==-1) yyerror("Pass2: Variable disappeared!"); else { - struct identifier *id; - id=ID_FROM_INT(Pike_compiler->new_program,n); + struct identifier *id=ID_FROM_INT(Pike_compiler->new_program,n); free_type(id->type); copy_pike_type(id->type, type); return n; @@ -2920,10 +2923,21 @@ int define_variable(struct pike_string *name, if(!(IDENTIFIERP(n)->id_flags & ID_INLINE) || Pike_compiler->compiler_pass!=1) { - if(!match_types(ID_FROM_INT(Pike_compiler->new_program, n)->type, type)) - my_yyerror("Illegal to redefine inherited variable " - "with different type."); - + int n2; + + if(ID_FROM_INT(Pike_compiler->new_program, n)->type != type && + !pike_types_le(type, + ID_FROM_INT(Pike_compiler->new_program, n)->type)) { + if (!match_types(ID_FROM_INT(Pike_compiler->new_program, n)->type, + type)) { + my_yyerror("Illegal to redefine inherited variable '%s' " + "with different type.", name->str); + return n; + } else { + yywarning("Redefining inherited variable '%s' " + "with different type.", name->str); + } + } if(!IDENTIFIER_IS_VARIABLE(ID_FROM_INT(Pike_compiler->new_program, n)-> @@ -2931,10 +2945,29 @@ int define_variable(struct pike_string *name, { my_yyerror("Illegal to redefine inherited variable " "with different type."); + return n; } - IDENTIFIERP(n)->id_flags = flags & ~ID_EXTERN; - return n; + if ((ID_FROM_INT(Pike_compiler->new_program, n)->run_time_type != + PIKE_T_MIXED) && + (ID_FROM_INT(Pike_compiler->new_program, n)->run_time_type != + compile_type_to_runtime_type(type))) { + my_yyerror("Illegal to redefine inherited variable " + "with different type."); + return n; + } + + /* Copy the variable reference, so that we can change the + * compile-time type. */ + n2 = low_define_variable(name, type, + (flags | ID_ALIAS) & ~ID_EXTERN, + ID_FROM_INT(Pike_compiler->new_program, n)-> + func.offset + + INHERIT_FROM_INT(Pike_compiler->new_program, + n)->storage_offset, + ID_FROM_INT(Pike_compiler->new_program, n)-> + run_time_type); + return n2; } } } diff --git a/src/program.h b/src/program.h index be2fb347a440d55075c340a325e29a087a3030d3..8d6a0c4b1e4afbdf09d90f641a2b6a9957ebf91e 100644 --- a/src/program.h +++ b/src/program.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: program.h,v 1.132 2001/07/01 22:29:40 mast Exp $ + * $Id: program.h,v 1.133 2001/07/03 17:01:48 grubba Exp $ */ #ifndef PROGRAM_H #define PROGRAM_H @@ -138,13 +138,15 @@ union idptr #define IDENTIFIER_PROTOTYPED 16 #define IDENTIFIER_SCOPED 32 /* This is used for local functions only */ #define IDENTIFIER_SCOPE_USED 64 /* contains scoped local functions */ +#define IDENTIFIER_ALIAS 128 /* This identifier is an alias. */ #define IDENTIFIER_IS_FUNCTION(X) ((X) & IDENTIFIER_FUNCTION) #define IDENTIFIER_IS_PIKE_FUNCTION(X) ((X) & IDENTIFIER_PIKE_FUNCTION) #define IDENTIFIER_IS_CONSTANT(X) ((X) & IDENTIFIER_CONSTANT) #define IDENTIFIER_IS_VARIABLE(X) (!((X) & (IDENTIFIER_FUNCTION | IDENTIFIER_CONSTANT))) +#define IDENTIFIER_IS_ALIAS(X) ((X) & IDENTIFIER_ALIAS) -#define IDENTIFIER_MASK 127 +#define IDENTIFIER_MASK 255 struct identifier { @@ -185,8 +187,9 @@ struct program_constant #define ID_OPTIONAL 0x100 /* Symbol is not required by the interface */ #define ID_EXTERN 0x200 /* Symbol is defined later */ #define ID_VARIANT 0x400 /* Function is overloaded by argument. */ +#define ID_ALIAS 0x800 /* Variable is an overloaded alias. */ -#define ID_MODIFIER_MASK 0x07ff +#define ID_MODIFIER_MASK 0x0fff #define ID_STRICT_TYPES 0x8000 /* #pragma strict_types */ #define ID_SAVE_PARENT 0x10000 /* pragma save_parent */