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.319 2002/12/20 15:25:20 grubba Exp $ + || $Id: las.c,v 1.320 2002/12/25 18:18:01 grubba Exp $   */      #include "global.h" - RCSID("$Id: las.c,v 1.319 2002/12/20 15:25:20 grubba Exp $"); + RCSID("$Id: las.c,v 1.320 2002/12/25 18:18:01 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:29:   #include "pike_macros.h"   #include "peep.h"   #include "builtin_functions.h"   #include "cyclic.h"   #include "block_alloc.h"   #include "opcodes.h"   #include "pikecode.h"      #define LASDEBUG    + /* Define this if you want the optimizer to be paranoid about aliasing +  * effects to to indexing. +  */ + /* #define PARANOID_INDEXING */ +    int lasdebug=0;      static node *eval(node *);   static void optimize(node *n);   static node *localopt(node *n);      int cumulative_parse_error=0;   extern char *get_type_name(int);      #define MAX_GLOBAL 2048
pike.git/src/las.c:842:    }   #endif /* PIKE_DEBUG && SHARED_NODES */    return n;   }      /* here starts routines to make nodes */   static node *debug_mkemptynode(void)   {    node *res=alloc_node_s();    - #ifdef SHARED_NODES + #if defined(SHARED_NODES) || defined(__CHECKER__)    MEMSET(res, 0, sizeof(node)); -  + #ifdef SHARED_NODES    res->hash = 0;    res->refs = 1;   #endif /* SHARED_NODES */ -  + #endif /* SHARED_NODES || __CHECKER__ */       res->token=0;    res->line_number=lex.current_line;   #ifdef PIKE_DEBUG    copy_shared_string(res->current_file, lex.current_file);   #endif    res->type=0;    res->name=0;    res->node_info=0;    res->tree_info=0;
pike.git/src/las.c:2860:    new = (struct scope_info *)xalloc(sizeof(struct scope_info));    MEMSET(new, VAR_UNUSED, sizeof(struct scope_info));    new->next = *a;    new->scope_id = scope_id;    *a = new;    return new->vars + num;   }      /* FIXME: Ought to use parent pointer to avoid recursion. */   /* Find the variables that are used in the tree n. */ + /* noblock: Don't mark unused variables that are written to as blocked. +  * overwrite: n is an lvalue that is overwritten. +  */   static int find_used_variables(node *n,    struct used_vars *p,    int noblock,    int overwrite)   {    struct used_vars *a;    char *q;       if(!n) return 0;   
pike.git/src/las.c:2944: Inside #if defined(PIKE_DEBUG)
   if (l_flag > 2) {    fprintf(stderr, "kept\n");    }   #endif /* PIKE_DEBUG */    }    }    break;       case F_ARROW:    case F_INDEX: + #ifdef PARANOID_INDEXING +  /* Be paranoid, and assume aliasing. */    p->ext_flags = VAR_USED; -  + #endif /* PARANOID_INDEXING */    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 '?':
pike.git/src/las.c:3064:    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: + #ifdef PARANOID_INDEXING +  /* Be paranoid and assume aliasing. */    if (lvalue)    p->ext_flags = VAR_USED;    find_written_vars(CAR(n), p, 0); -  + #else /* !PARAONID_INDEXING */ +  /* Propagate the change to the indexed value. +  * Note: This is sensitive to aliasing effects. +  */ +  find_written_vars(CAR(n), p, lvalue); + #endif /* PARANOID_INDEXING */    find_written_vars(CDR(n), p, 0);    break;    -  +  case F_SOFT_CAST: +  find_written_vars(CAR(n), p, lvalue); +  break; +     case F_INC:    case F_DEC:    case F_POST_INC:    case F_POST_DEC:    find_written_vars(CAR(n), p, 1);    break;       case F_ASSIGN:    find_written_vars(CAR(n), p, 0);    find_written_vars(CDR(n), p, 1);