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.502 2003/05/16 14:08:38 grubba Exp $ + || $Id: program.c,v 1.503 2003/06/03 18:02:28 mast Exp $   */      #include "global.h" - RCSID("$Id: program.c,v 1.502 2003/05/16 14:08:38 grubba Exp $"); + RCSID("$Id: program.c,v 1.503 2003/06/03 18:02:28 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:1597:   {    INT32 i,e,t;    struct program *p=Pike_compiler->new_program;       if(p->flags & PROGRAM_FIXED) return;   #ifdef PIKE_DEBUG    if(p->flags & PROGRAM_OPTIMIZED)    Pike_fatal("Cannot fixate optimized program\n");   #endif    +  /* Fixup identifier overrides. */ +  for (i = 0; i < p->num_identifier_references; i++) { +  struct reference *ref = p->identifier_references + i; +  if (ref->id_flags & ID_HIDDEN) continue; +  if (ref->inherit_offset != 0) continue; +  override_identifier (ref, ID_FROM_PTR (p, ref)->name); +  } +     /* Ok, sort for binsearch */    for(e=i=0;i<(int)p->num_identifier_references;i++)    {    struct reference *funp;    struct identifier *fun;    funp=p->identifier_references+i;    if(funp->id_flags & (ID_HIDDEN|ID_STATIC)) continue;    fun=ID_FROM_PTR(p, funp);    if(funp->id_flags & ID_INHERITED)    {
pike.git/src/program.c:1785:       DOUBLELINK(first_program, p);    GETTIMEOFDAY(& p->timestamp);    return p;   }      /*    * Start building a new program    */   void low_start_new_program(struct program *p, +  int pass,    struct pike_string *name,    int flags,    int *idp)   { -  int e,id=0; +  int id=0;    struct svalue tmp;      #if 0   #ifdef SHARED_NODES    if (!node_hash.table) {    node_hash.table = malloc(sizeof(node *)*32831);    if (!node_hash.table) {    Pike_fatal("Out of memory!\n");    }    MEMSET(node_hash.table, 0, sizeof(node *)*32831);
pike.git/src/program.c:1830: Inside #if 0
  #if 0    fprintf(stderr,"Compiling class %s, depth=%d\n",name->str,compilation_depth);    }else{    fprintf(stderr,"Compiling file %s, depth=%d\n",    lex.current_file ? lex.current_file->str : "-",    compilation_depth);   #endif    }    if(compilation_depth >= 1)    add_ref(p->parent = Pike_compiler->new_program); -  e=1; +     }else{    tmp.u.program=p;    add_ref(p);    if(name)    {    struct identifier *i;    id=isidentifier(name);    if (id < 0)    Pike_fatal("Program constant disappeared in second pass.\n");    i=ID_FROM_INT(Pike_compiler->new_program, id);    free_type(i->type);    i->type=get_type_of_svalue(&tmp);    } -  e=2; +     }    p->flags &=~ PROGRAM_VIRGIN;    Pike_compiler->parent_identifier=id;    if(idp) *idp=id;       CDFPRINTF((stderr, "th(%ld) %p low_start_new_program() %s "    "pass=%d: threads_disabled:%d, compilation_depth:%d\n",    (long)th_self(), p, name ? name->str : "-",    Pike_compiler->compiler_pass,    threads_disabled, compilation_depth));       init_type_stack();      #define PUSH   #include "compilation.h"    -  Pike_compiler->compiler_pass=e; +  Pike_compiler->compiler_pass = pass;       Pike_compiler->num_used_modules=0;       if(p && (p->flags & PROGRAM_FINISHED))    {    yyerror("Pass2: Program already done");    p=0;    }       Pike_compiler->malloc_size_program = ALLOC_STRUCT(program);
pike.git/src/program.c:2047:       lex.current_file = make_shared_string(f);    lex.current_line = line;    }       CDFPRINTF((stderr,    "th(%ld) start_new_program(%d, %s): "    "threads_disabled:%d, compilation_depth:%d\n",    (long)th_self(), line, file, threads_disabled, compilation_depth));    -  low_start_new_program(0,0,0,0); +  low_start_new_program(0,1,0,0,0);    store_linenumber(line,lex.current_file);    debug_malloc_name(Pike_compiler->new_program, file, line);       free_string(lex.current_file);    lex.current_file = save_file;    lex.current_line = save_line;   }         static void exit_program_struct(struct program *p)
pike.git/src/program.c:2334: Inside #if defined(PIKE_DEBUG)
   if (IDENTIFIER_IS_PIKE_FUNCTION(ID_FROM_PTR(p,ref)->identifier_flags)) {    INT32 line;    struct program *inh_p = INHERIT_FROM_PTR(p,ref)->prog;    struct pike_string *file =    get_line (ID_FROM_PTR(p,ref)->func.offset + inh_p->program, inh_p, &line);    if (!file->size_shift)    fprintf (stderr, "%*s %s:%d\n",    indent, "", file->str, line);    }    } +     fprintf(stderr, "\n" -  +  "%*sIdentifier index table:\n" +  "%*s ####: Index\n", +  indent, "", indent, ""); +  for (d = 0; d < p->num_identifier_index; d++) { +  fprintf(stderr, "%*s %4d: %5d\n", +  indent, "", +  d, p->identifier_index[d]); +  } +  +  fprintf(stderr, "\n"    "%*sInherit table:\n"    "%*s ####: Level id_level offset ref_offset\n",    indent, "", indent, "");    for (d=0; d < p->num_inherits; d++) {    struct inherit *inh = p->inherits + d;       fprintf(stderr, "%*s %4d: %5d %8d %6d"/* %10d*/"\n",    indent, "",    d, inh->inherit_level, inh->identifier_level,    inh->storage_offset /*, inh->identifier_ref_offset*/);
pike.git/src/program.c:2358: Inside #if defined(PIKE_DEBUG)
   "%*s ####: Flags Offset Type Name\n",    indent, "", indent, "");    for (d=0; d < p->num_identifiers; d++) {    struct identifier *id = p->identifiers + d;       fprintf(stderr, "%*s %4d: %5x %6d %4d \"%s\"\n",    indent, "",    d, id->identifier_flags, id->func.offset,    id->run_time_type, id->name->str);    } +     fprintf(stderr, "\n"    "%*sVariable table:\n"    "%*s ####: Index\n",    indent, "", indent, "");    for (d = 0; d < p->num_variable_index; d++) {    fprintf(stderr, "%*s %4d: %5d\n",    indent, "",    d, p->variable_index[d]);    }    fprintf(stderr, "\n"
pike.git/src/program.c:2407: Inside #if defined(PIKE_DEBUG)
   fprintf(stderr, "%*s Filename: \"%s\"\n", indent, "", file);    } else {    fprintf(stderr, "%*s Filename: len:%d, shift:%d\n", indent, "", len, shift);    }    }    off += get_small_number(&cnt);    line += get_small_number(&cnt);    fprintf(stderr, "%*s %8d:%8d\n", indent, "", off, line);    }    } +     fprintf(stderr, "\n");   }      void check_program(struct program *p)   {    INT32 size;    unsigned INT32 checksum, e;    int variable_positions[1024];       if(p->flags & PROGRAM_AVOID_CHECK) return;
pike.git/src/program.c:4989:    add_to_linenumbers(a);    }else{    add_to_linenumbers(-128);    add_to_linenumbers(a>>24);    add_to_linenumbers(a>>16);    add_to_linenumbers(a>>8);    add_to_linenumbers(a);    }   #ifdef PIKE_DEBUG    { -  unsigned char *tmp = Pike_compiler->new_program->linenumbers + start; -  INT32 res = get_small_number((char **)&tmp); +  char *tmp = Pike_compiler->new_program->linenumbers + start; +  INT32 res = get_small_number(&tmp);    if (a != res) {    tmp = Pike_compiler->new_program->linenumbers + start;    fprintf(stderr, "0x%p: %02x %02x %02x %02x %02x\n", -  tmp, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4]); +  tmp, (unsigned char) tmp[0], (unsigned char) tmp[1], +  (unsigned char) tmp[2], (unsigned char) tmp[3], (unsigned char) tmp[4]);    Pike_fatal("insert_small_number failed: %d (0x%08x) != %d (0x%08x)\n",    a, a, res, res);    }    }   #endif /* PIKE_DEBUG */   }      static void ext_insert_small_number (char **ptr, INT32 a)   {    if(a>-127 && a<127)
pike.git/src/program.c:5890:    yyerror("Placeholder object is not a null_program clone!");    return 0;    }    debug_malloc_touch(c->placeholder);       if(c->target && !(c->target->flags & PROGRAM_VIRGIN)) {    yyerror("Placeholder program is not virgin!");    return 0;    }    -  low_start_new_program(c->target,0,0,0); +  low_start_new_program(c->target,1,0,0,0);    c->supporter.prog = Pike_compiler->new_program;       CDFPRINTF((stderr,    "th(%ld) %p run_pass1() start: "    "threads_disabled:%d, compilation_depth:%d\n",    (long)th_self(), Pike_compiler->new_program,    threads_disabled, compilation_depth));    -  Pike_compiler->compiler_pass=1; +     run_init2(c);       if(c->placeholder)    {    if(c->placeholder->prog != null_program)    {    yyerror("Placeholder argument is not a null_program clone!");    c->placeholder=0;    debug_malloc_touch(c->placeholder);    }else{
pike.git/src/program.c:5970:    verify_supporters();    return ret;   }      void run_pass2(struct compilation *c)   {    debug_malloc_touch(c);    debug_malloc_touch(c->placeholder);       run_init(c); -  low_start_new_program(c->p,0,0,0); +  low_start_new_program(c->p,2,0,0,0);    free_program(c->p);    c->p=0;    -  Pike_compiler->compiler_pass=2; -  +     run_init2(c);       CDFPRINTF((stderr,    "th(%ld) %p run_pass2() start: "    "threads_disabled:%d, compilation_depth:%d\n",    (long)th_self(), Pike_compiler->new_program,    threads_disabled, compilation_depth));       verify_supporters();   
pike.git/src/program.c:7026:    if(f->type != T_FUNCTION) return 0;    if(f->subtype == FUNCTION_BUILTIN) return 0;    if(!f->u.object->prog) return 0;    return low_program_from_function(f->u.object->prog, f->subtype);   }      PMOD_EXPORT struct program *program_from_svalue(const struct svalue *s)   {    switch(s->type)    { + #if 0    case T_OBJECT:    {    struct program *p = s->u.object->prog;    int call_fun;       if (!p) return 0;      #if 0    if ((call_fun = FIND_LFUN(p, LFUN_CALL)) >= 0) {    /* Get the program from the return type. */
pike.git/src/program.c:7047: Inside #if 0
   /* FIXME: do it. */    return 0;    }   #endif    push_svalue(s);    f_object_program(1);    p=program_from_svalue(Pike_sp-1);    pop_stack();    return p; /* We trust that there is a reference somewhere... */    } + #endif       case T_FUNCTION:    return program_from_function(s);    case T_PROGRAM:    return s->u.program;    default:    return 0;    }   }