pike.git / src / las.c

version» Context lines:

pike.git/src/las.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: las.c,v 1.317 2002/12/10 16:53:28 mast Exp $ + || $Id: las.c,v 1.318 2002/12/20 15:13:20 grubba Exp $   */      #include "global.h" - RCSID("$Id: las.c,v 1.317 2002/12/10 16:53:28 mast Exp $"); + RCSID("$Id: las.c,v 1.318 2002/12/20 15:13:20 grubba Exp $");      #include "language.h"   #include "interpret.h"   #include "las.h"   #include "array.h"   #include "object.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "lex.h"   #include "pike_types.h"
pike.git/src/las.c:2942: Inside #if defined(PIKE_DEBUG)
   }    } else {    if (l_flag > 2) {    fprintf(stderr, "kept\n");    }   #endif /* PIKE_DEBUG */    }    }    break;    +  case F_ARROW: +  case F_INDEX: +  p->ext_flags |= VAR_USED; +  if(car_is_node(n)) find_used_variables(CAR(n),p,noblock,0); +  if(cdr_is_node(n)) find_used_variables(CDR(n),p,noblock,0); +  break; +     case F_ASSIGN:    find_used_variables(CAR(n),p,noblock,0);    find_used_variables(CDR(n),p,noblock,1);    break;       case '?':    find_used_variables(CAR(n),p,noblock,0);    a=copy_vars(p);    find_used_variables(CADR(n),a,noblock,0);    find_used_variables(CDDR(n),p,noblock,0);
pike.git/src/las.c:3057:    p->ext_flags = VAR_USED;    }    break;       case F_AUTO_MAP_MARKER:    find_written_vars(CAR(n), p, lvalue);    break;       case F_INDEX:    case F_ARROW: -  find_written_vars(CAR(n), p, lvalue); +  if (lvalue) +  p->ext_flags = VAR_USED; +  find_written_vars(CAR(n), p, 0);    find_written_vars(CDR(n), p, 0);    break;       case F_INC:    case F_DEC:    case F_POST_INC:    case F_POST_DEC:    find_written_vars(CAR(n), p, 1);    break;   
pike.git/src/las.c:3151:    aa.ext_flags = 0;    bb.ext_flags = 0;    aa.locals = NULL;    bb.locals = NULL;    aa.externals = NULL;    bb.externals = NULL;       SET_ONERROR(free_aa, free_vars, &aa);    SET_ONERROR(free_bb, free_vars, &bb);    +  /* A depends on B if A uses stuff that is written to by B. */ +     find_used_variables(a, &aa, 0, 0);    find_written_vars(b, &bb, 0);       UNSET_ONERROR(free_bb);    UNSET_ONERROR(free_aa);       if(aa.err || bb.err) {    free_vars(&aa);    free_vars(&bb);    return 1;    }    -  +  /* If A has external dependencies due to indexing, we won't +  * investigate further. +  */ +  if (aa.ext_flags == VAR_USED) return 1; +  +  /* Check for overlap in locals. */    {    struct scope_info *aaa = aa.locals;    struct scope_info *bbb = bb.locals;       while (aaa) {    while (bbb && (bbb->scope_id < aaa->scope_id)) {    bbb = bbb->next;    }    if (!bbb) break;    if (bbb->scope_id == aaa->scope_id) {
pike.git/src/las.c:3187:    free_vars(&bb);    return 1;    }    }    }    aaa = aaa->next;    }    }       if (bb.ext_flags == VAR_USED) { +  /* B has side effects. +  * +  * A is dependant if A uses any externals at all. +  */ +     /* No need to look closer at b */    struct scope_info *aaa = aa.externals;       /* FIXME: Probably only needed to check if aaa is NULL or not. */       while (aaa) {    for (e = 0; e < MAX_VAR; e++) {    if (aaa->vars[e] == VAR_USED) {    free_vars(&aa);    free_vars(&bb);    return 1;    }    }    aaa = aaa->next;    }    } else { -  +  /* Otherwise check for overlaps. */    struct scope_info *aaa = aa.externals;    struct scope_info *bbb = bb.externals;       while (aaa) {    while (bbb && (bbb->scope_id < aaa->scope_id)) {    bbb = bbb->next;    }    if (!bbb) break;    if (bbb->scope_id == aaa->scope_id) {    for (e = 0; e < MAX_VAR; e++) {