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.481 2003/02/15 16:02:05 grubba Exp $ + || $Id: program.c,v 1.482 2003/02/20 14:55:12 grubba Exp $   */      #include "global.h" - RCSID("$Id: program.c,v 1.481 2003/02/15 16:02:05 grubba Exp $"); + RCSID("$Id: program.c,v 1.482 2003/02/20 14:55:12 grubba 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:1455:    size+=p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0]);   #include "program_areas.h"       p->total_size=size + sizeof(struct program);       p->flags |= PROGRAM_OPTIMIZED;    make_program_executable(p);   }      /* internal function to make the index-table */ - int program_function_index_compare(const void *a,const void *b) + static ptrdiff_t program_identifier_index_compare(int a, int b, +  const struct program *p)   { -  return -  DO_NOT_WARN((int)my_order_strcmp(ID_FROM_INT(Pike_compiler->new_program, -  *(unsigned short *)a)->name, -  ID_FROM_INT(Pike_compiler->new_program, -  *(unsigned short *)b)->name)); +  ptrdiff_t val_a = ((char *)(ID_FROM_INT(p, a)->name))-(char *)0; +  ptrdiff_t val_b = ((char *)(ID_FROM_INT(p, b)->name))-(char *)0; +  +  return val_a - val_b;   }    -  + #define CMP(X,Y) program_identifier_index_compare(*(X), *(Y), prog) + #define EXTRA_ARGS , struct program *prog + #define XARGS , prog + #define ID fsort_program_identifier_index + #define TYPE unsigned short + #include "fsort_template.h" + #undef TYPE + #undef ID + #undef XARGS + #undef EXTRA_ARGS + #undef CMP +    #ifdef PIKE_DEBUG   struct pike_string *find_program_name(struct program *p, INT32 *line)   {    ptrdiff_t pos;    INT32 l;    if(!line) line=&l;      #ifdef DEBUG_MALLOC    {    char *tmp=dmalloc_find_name(p);
pike.git/src/program.c:1593:    IDENTIFIER_IS_PIKE_FUNCTION(fun->identifier_flags)) {    if (!fun->name->size_shift && fun->name->len < 900) {    my_yyerror("Missing definition for local function %s().",    fun->name->str);    } else {    yyerror("Missing definition for local function.");    }    }    add_to_identifier_index(i);    } -  fsort((void *)p->identifier_index, -  p->num_identifier_index, -  sizeof(unsigned short),(fsortfun)program_function_index_compare); +  fsort_program_identifier_index(p->identifier_index, +  p->identifier_index + +  p->num_identifier_index - 1, +  p);          /* Yes, it is supposed to start at 1 /Hubbe */    for(i=1;i<NUM_LFUNS;i++) {    p->lfuns[i] = low_find_lfun(p, i);    }       p->flags |= PROGRAM_FIXED;       if(Pike_compiler->check_final)
pike.git/src/program.c:2536: Inside #if defined(PIKE_DEBUG)
   }    variable_positions[offset+q]=e;    }    }    }       for(e=0;e<p->num_identifier_index;e++)    {    if(p->identifier_index[e] > p->num_identifier_references)    Pike_fatal("Program->identifier_indexes[%ld] is wrong\n",(long)e); +  if (e && (program_identifier_index_compare(p->identifier_index[e-1], +  p->identifier_index[e], +  p) > 0)) { +  Pike_fatal("Program->identifier_index[%ld] > " +  "Program->identifier_index[%ld]\n", +  (long)(e-1), (long)e);    } -  +  }      }   #endif      /* Note: This function is misnamed, since it's run after both passes. /mast */   /* finish-states:    *    * 0: First pass.    * 1: Last pass.    * 2: Called from decode_value().
pike.git/src/program.c:4547:    */   int low_find_shared_string_identifier(struct pike_string *name,    struct program *prog)   {    int max,min,tst;    struct identifier *fun;       if(prog->flags & PROGRAM_FIXED)    {    unsigned short *funindex = prog->identifier_index; +  ptrdiff_t val_n = ((char *)name) - (char *)0;      #ifdef PIKE_DEBUG    if(!funindex)    Pike_fatal("No funindex in fixed program\n");   #endif       max = prog->num_identifier_index;    min = 0;    while(max != min)    { -  +  ptrdiff_t val_t; +     tst=(max + min) >> 1;    fun = ID_FROM_INT(prog, funindex[tst]);    if(is_same_string(fun->name,name)) return funindex[tst]; -  if(my_order_strcmp(fun->name, name) > 0) -  max=tst; -  else -  min=tst+1; +  val_t = ((char *)fun->name) - (char *)0; +  if ((val_n - val_t) < 0) { +  max = tst; +  } else { +  min = tst+1;    } -  +  }    }else{    return really_low_find_shared_string_identifier(name,prog,0);    }    return -1;   }      #ifdef FIND_FUNCTION_HASHSIZE   #if FIND_FUNCTION_HASHSIZE == 0   #undef FIND_FUNCTION_HASHSIZE   #endif