Branch: Tag:

1998-01-25

1998-01-25 08:28:45 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

jumbopatch! (DEBUG_MALLOC + parent feature fix)

Rev: src/ChangeLog:1.130
Rev: src/acconfig.h:1.15
Rev: src/array.c:1.22
Rev: src/array.h:1.6
Rev: src/builtin_functions.c:1.62
Rev: src/builtin_functions.h:1.6
Rev: src/cpp.c:1.14
Rev: src/dmalloc.h:1.1
Rev: src/docode.c:1.25
Rev: src/dynamic_buffer.c:1.6
Rev: src/dynamic_buffer.h:1.4
Rev: src/error.c:1.10
Rev: src/error.h:1.9
Rev: src/fdlib.c:1.9
Rev: src/gc.c:1.27
Rev: src/global.h:1.13
Rev: src/interpret.c:1.61
Rev: src/language.yacc:1.54
Rev: src/las.c:1.43
Rev: src/las.h:1.11
Rev: src/lex.c:1.40
Rev: src/lex.h:1.9
Rev: src/main.c:1.35
Rev: src/main.h:1.4
Rev: src/mapping.c:1.27
Rev: src/mapping.h:1.7
Rev: src/module.c:1.7
Rev: src/modules/Image/colortable.c:1.36
Rev: src/modules/Image/encodings/gif.c:1.30
Rev: src/modules/Image/encodings/png.c:1.2
Rev: src/modules/Image/encodings/pnm.c:1.12
Rev: src/modules/Image/encodings/x.c:1.5
Rev: src/modules/Yp/yp.c:1.10
Rev: src/modules/files/efuns.c:1.44
Rev: src/modules/files/file.c:1.69
Rev: src/modules/files/socket.c:1.25
Rev: src/modules/files/socktest.pike:1.7
Rev: src/modules/spider/accesseddb.c:1.13
Rev: src/modules/spider/dumudp.c:1.32
Rev: src/modules/spider/spider.c:1.51
Rev: src/modules/system/system.c:1.39
Rev: src/multiset.c:1.9
Rev: src/object.c:1.33
Rev: src/peep.c:1.17
Rev: src/pike_memory.c:1.4
Rev: src/pike_memory.h:1.2
Rev: src/pike_types.c:1.29
Rev: src/pike_types.h:1.7
Rev: src/program.c:1.54
Rev: src/program.h:1.27
Rev: src/stralloc.c:1.24
Rev: src/stralloc.h:1.12
Rev: src/testsuite.in:1.68
Rev: src/threads.c:1.53

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: program.c,v 1.53 1998/01/22 00:51:04 grubba Exp $"); + RCSID("$Id: program.c,v 1.54 1998/01/25 08:25:14 hubbe Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
185:    while(--e>=0)    {    push_svalue(modules+e); -  push_string(ident); -  ident->refs++; +  ref_push_string(ident);    f_index(2);       if(!IS_UNDEFINED(sp-1))
250:    h=id & (ID_TO_PROGRAM_CACHE_SIZE-1);       if((p=id_to_program_cache[h])) -  if(p->id==id) return p; +  if(p->id==id) +  return p;       if(id)    {
258:    {    if(id==p->id)    { -  if(id_to_program_cache[h]) -  free_program(id_to_program_cache[h]); -  +     id_to_program_cache[h]=p; -  p->refs++; +     return p;    }    }
434:    i.inherit_level=0;    i.parent=0;    i.parent_identifier=0; +  i.parent_offset=1;    i.name=0;    add_to_inherits(i);    }
728:    if(init_node)    {    union idptr tmp; -  struct pike_string *s; -  s=make_shared_string("__INIT"); +     dooptcode(s,    mknode(F_ARG_LIST,    init_node,mknode(F_RETURN,mkintnode(0),0)),    function_type_string,    0); -  free_string(s); +     init_node=0;    }    -  +  free_string(s); +     pop_compiler_frame(); /* Pop __INIT local variables */       exit_type_stack();
894:   /*    * make this program inherit another program    */ - void do_inherit(struct svalue *prog, + void low_inherit(struct program *p, +  struct object *parent, +  int parent_identifier, +  int parent_offset,    INT32 flags,    struct pike_string *name)   {
902:    struct inherit inherit;    struct pike_string *s;    -  struct program *p=program_from_svalue(prog); +     -  +     if(!p)    {    yyerror("Illegal program pointer.");
925:    inherit.inherit_level ++;    if(!e)    { -  if(prog->type == T_FUNCTION) +  if(parent)    { -  inherit.parent=prog->u.object; -  inherit.parent_identifier=prog->subtype; +  inherit.parent=parent; +  inherit.parent_identifier=parent_identifier; +  inherit.parent_offset=0; +  }else{ +  inherit.parent_offset+=parent_offset;    }    }    if(inherit.parent) inherit.parent->refs++;
989:    }   }    + void do_inherit(struct svalue *s, +  INT32 flags, +  struct pike_string *name) + { +  struct program *p=program_from_svalue(s); +  low_inherit(p, +  s->type == T_FUNCTION ? s->u.object : 0, +  s->subtype, +  0, +  flags, +  name); + } +  + void compiler_do_inherit(node *n, +  INT32 flags, +  struct pike_string *name) + { +  switch(n->token) +  { +  case F_EXTERNAL: +  { +  struct identifier *i; +  struct program *p=parent_compilation(n->u.integer.a); +  INT32 numid=n->u.integer.b; +  +  if(!p) +  { +  yyerror("Failed to resolv external constant.\n"); +  return; +  } +  +  i=ID_FROM_INT(p, numid); +  +  if(IDENTIFIER_IS_CONSTANT(i->identifier_flags)) +  { +  struct svalue *s=PROG_FROM_INT(new_program, numid)->constants + i->func.offset; +  if(s->type != T_PROGRAM) +  { +  yyerror("Inherit identifier is not a program"); +  return; +  }else{ +  p=s->u.program; +  } +  }else{ +  yyerror("Inherit identifier is not a constant program"); +  return; +  } +  +  low_inherit(p, +  0, +  0, +  n->u.integer.a, +  flags, +  name); +  break; +  } +  +  default: +  resolv_program(n); +  do_inherit(sp-1, flags, name); +  pop_stack(); +  } + } +  +    void simple_do_inherit(struct pike_string *s,    INT32 flags,    struct pike_string *name)
1092:    struct pike_string *type,    INT32 flags)   { -  int n; +  int n, run_time_type;      #ifdef DEBUG    if(name!=debug_findstring(name))
1126:    if(PROG_FROM_INT(new_program, n) == new_program)    my_yyerror("Variable '%s' defined twice.",name->str);    +  if(!(IDENTIFIERP(n)->id_flags & ID_INLINE)) +  {    if(ID_FROM_INT(new_program, n)->type != type)    my_yyerror("Illegal to redefine inherited variable with different type.");       if(ID_FROM_INT(new_program, n)->identifier_flags != flags)    my_yyerror("Illegal to redefine inherited variable with different type."); -  +  return n; +  } +  }    -  } else { -  int run_time_type=compile_type_to_runtime_type(type); +  run_time_type=compile_type_to_runtime_type(type);       switch(run_time_type)    {
1149:    run_time_type);       -  } -  +     return n;   }   
1240:    if(PROG_FROM_INT(new_program, n) == new_program)    my_yyerror("Identifier '%s' defined twice.",name->str);    +  if(!(IDENTIFIERP(n)->id_flags & ID_INLINE)) +  { +  /* override */    new_program->identifier_references[n]=ref; -  } else { +  +  return n; +  } +  }    n=new_program->num_identifier_references;    add_to_identifier_references(ref); -  } +        return n;   }
1355:       i=isidentifier(name);    -  +     if(i >= 0)    {    /* already defined */
1383:    my_yyerror("Illegal to redefine 'nomask' function %s.",name->str);    }    +  if(!(ref.id_flags & ID_INLINE)) +  {    /* We modify the old definition if it is in this program */    if(ref.inherit_offset==0)    {
1413:    ref.inherit_offset = 0;    ref.id_flags = flags;    new_program->identifier_references[i]=ref; -  }else{ -  /* define it */ +  return i; +  } +  }    -  +  /* define a new function */ +     copy_shared_string(fun.name, name);    copy_shared_string(fun.type, type);   
1441:       i=new_program->num_identifier_references;    add_to_identifier_references(ref); -  } +     return i;   }   
1746:    if(p && !num_parse_error)    {    low_start_new_program(p,0,0); +  free_program(p); +  p=0;    compiler_pass=2;    lex.pos=prog->str;    yyparse(); /* Parse da program again */
1819:      void cleanup_program(void)   { - #ifdef FIND_FUNCTION_HASHSIZE +     int e; -  + #ifdef FIND_FUNCTION_HASHSIZE    for(e=0;e<FIND_FUNCTION_HASHSIZE;e++)    {    if(cache[e].name)
1830: Inside #if defined(FIND_FUNCTION_HASHSIZE)
   }    }   #endif +    }      #ifdef GC2