2003-08-20
2003-08-20 19:40:09 by Martin Stjernholm <mast@lysator.liu.se>
-
aa771bcac577787a987a51d7a066d9dbf85381d0
(62 lines)
(+27/-35)
[
Show
| Annotate
]
Branch: 7.9
Fixed constant references to programs in inherited programs. A little
more rtldebug checks.
Rev: src/program.c:1.518
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: program.c,v 1.517 2003/08/20 18:08:15 mast Exp $
+ || $Id: program.c,v 1.518 2003/08/20 19:40:09 mast Exp $
*/
#include "global.h"
- RCSID("$Id: program.c,v 1.517 2003/08/20 18:08:15 mast Exp $");
+ RCSID("$Id: program.c,v 1.518 2003/08/20 19:40:09 mast Exp $");
#include "program.h"
#include "object.h"
#include "dynamic_buffer.h"
1473:
/* Here starts routines which are used to build new programs */
/* Re-allocate all the memory in the program in one chunk. because:
- * 1) The individual blocks are munch bigger than they need to be
+ * 1) The individual blocks are much bigger than they need to be
* 2) cuts down on malloc overhead (maybe)
* 3) localizes memory access (decreases paging)
*/
2441: Inside #if defined(PIKE_DEBUG)
indent, "", indent, "");
for (d = 0; d < p->num_constants; d++) {
struct program_constant *c = p->constants + d;
- fprintf(stderr, "%*s %4d: %4d %s%s%s\n",
+ fprintf(stderr, "%*s %4d: %-15s %s%s%s\n",
indent, "",
- d, c->sval.type,
+ d, get_name_of_type (c->sval.type),
c->name?"\"":"",c->name?c->name->str:"NULL",c->name?"\"":"");
}
2519: Inside #if defined(PIKE_DEBUG)
for(e=0;e<p->num_constants;e++)
{
- check_svalue(& p->constants[e].sval);
+ struct svalue *s = & p->constants[e].sval;
+ check_svalue(s);
+ if (p->flags & PROGRAM_FINISHED && s->type == T_OBJECT &&
+ s->u.object->next == s->u.object)
+ Pike_fatal ("Got fake object in constant in finished program.\n");
if(p->constants[e].name) check_string(p->constants[e].name);
}
2773:
prog=Pike_compiler->new_program;
add_ref(prog);
- #ifdef PIKE_DEBUG
- check_program(prog);
- if(l_flag)
- dump_program_desc(prog);
- #endif
-
+
Pike_compiler->new_program->flags |= PROGRAM_PASS_1_DONE;
if(finish)
2805:
}
}
+ #ifdef PIKE_DEBUG
+ check_program(prog);
+ if(l_flag)
+ dump_program_desc(prog);
+ #endif
}
#ifdef PROGRAM_BUILD_DEBUG
4044:
c->subtype != FUNCTION_BUILTIN &&
c->u.object->prog)
{
- struct identifier *id=ID_FROM_INT(c->u.object->prog, c->subtype);
- if(c->u.object->prog == Pike_compiler->new_program &&
- !c->u.object->prog->identifier_references[c->subtype].inherit_offset)
+ struct reference *idref = PTR_FROM_INT(c->u.object->prog, c->subtype);
+ struct program *p = PROG_FROM_PTR(c->u.object->prog, idref);
+ struct identifier *id = p->identifiers + idref->identifier_offset;
+ if(c->u.object->prog == Pike_compiler->new_program) {
+ if(IDENTIFIER_IS_CONSTANT(id->identifier_flags) &&
+ id->func.offset != -1)
{
- if(IDENTIFIER_IS_FUNCTION(id->identifier_flags))
+ c=& p->constants[id->func.offset].sval;
+ }
+ else if (IDENTIFIER_IS_FUNCTION(id->identifier_flags) &&
+ !idref->inherit_offset)
{
return define_function(name,
id->type,
4058:
id->opt_flags);
}
- else if(IDENTIFIER_IS_CONSTANT(id->identifier_flags) &&
- id->func.offset != -1)
- {
- c=& Pike_compiler->new_program->constants[id->func.offset].sval;
+
}
}
- else
- {
- if(IDENTIFIER_IS_CONSTANT(id->identifier_flags) &&
- id->func.offset != -1 &&
- INHERIT_FROM_INT(c->u.object->prog, c->subtype)->prog->
- constants[id->func.offset].sval.type == T_PROGRAM)
- {
- /* In this one case we allow fake objects to enter the
- * mainstream...
- */
- break;
- }
- }
- }
+
if(/* c && */ !svalues_are_constant(c,1,BIT_MIXED,0))
yyerror("Constant values may not have references to this.");