pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1:   /*   || 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"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "language.h"   #include "lex.h"   #include "pike_macros.h"   #include "fsort.h"
pike.git/src/program.c:1466:    }    }    }    }    return 0;   }      /* 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)    */   void optimize_program(struct program *p)   {    size_t size=0;    char *data;       /* Already done (shouldn't happen, but who knows?) */    if(p->flags & PROGRAM_OPTIMIZED) return;
pike.git/src/program.c:2434: Inside #if defined(PIKE_DEBUG)
   fprintf(stderr, "%*s %4d: %5d\n",    indent, "",    d, p->variable_index[d]);    }    fprintf(stderr, "\n"    "%*sConstant table:\n"    "%*s ####: Type Name\n",    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?"\"":"");    }       fprintf(stderr, "\n"    "%*sLinenumber table:\n",    indent, "");    {    INT32 off = 0, line = 0;    char *cnt = p->linenumbers;   
pike.git/src/program.c:2512: Inside #if defined(PIKE_DEBUG)
   Pike_fatal("Program id is wrong.\n");       if(p->storage_needed < 0)    Pike_fatal("Program->storage_needed < 0.\n");       if(p->num_identifier_index > p->num_identifier_references)    Pike_fatal("Too many identifier index entries in program!\n");       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);    }       for(e=0;e<p->num_strings;e++)    check_string(p->strings[e]);       for(e=0;e<p->num_inherits;e++)    {    if(!p->inherits[e].prog)    {
pike.git/src/program.c:2766:       pop_compiler_frame(); /* Pop __INIT local variables */       if(Pike_compiler->num_parse_error > 0)    {    prog=0;    }else{    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)    {    if(Pike_compiler->new_program->flags & PROGRAM_USES_PARENT)    {    Pike_compiler->new_program->parent_info_storage =    add_xstorage(sizeof(struct parent_info),    ALIGNOF(struct parent_info),    0);
pike.git/src/program.c:2798:    if(Pike_compiler->num_parse_error)    {    free_program(prog);    prog=0;    }else{    optimize_program(Pike_compiler->new_program);    Pike_compiler->new_program->flags |= PROGRAM_FINISHED;    }    }    + #ifdef PIKE_DEBUG +  check_program(prog); +  if(l_flag) +  dump_program_desc(prog); + #endif    }      #ifdef PROGRAM_BUILD_DEBUG    fprintf (stderr, "%.*sfinishing program %d (pass=%d)\n",    compilation_depth, " ", Pike_compiler->new_program->id, Pike_compiler->compiler_pass);   #endif       toss_compilation_resources();      #if 0
pike.git/src/program.c:4037: Inside #if defined(PIKE_DEBUG)
   if(name!=debug_findstring(name))    Pike_fatal("define_constant on nonshared string.\n");   #endif       do {    if(/* c && */    c->type == T_FUNCTION &&    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,    flags,    id->identifier_flags | IDENTIFIER_ALIAS,    & id->func,    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.");       }while(0);       n = isidentifier(name);       if(Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE)    {