pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: las.c,v 1.211 2000/09/13 12:13:57 grubba Exp $"); + RCSID("$Id: las.c,v 1.212 2000/09/13 12:28:18 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:3391:    }    }    if (old_type) {    free_string(old_type);    }   #ifdef PIKE_DEBUG    check_type_string(n->type);   #endif /* PIKE_DEBUG */   }    - /* FIXME: Ought to use parent pointer to avoid recursion. */ +    static void zapp_try_optimize(node *n)   { -  +  node *parent; +  node *orig_n = n; +     if(!n) return; -  n->node_info &=~ OPT_TRY_OPTIMIZE; -  n->tree_info &=~ OPT_TRY_OPTIMIZE; +     -  fatal_check_c_stack(16384); +  parent = n->parent; +  n->parent = NULL;    -  if(car_is_node(n)) zapp_try_optimize(CAR(n)); -  if(cdr_is_node(n)) zapp_try_optimize(CDR(n)); +  while(1) { +  n->node_info &= ~OPT_TRY_OPTIMIZE; +  n->tree_info &= ~OPT_TRY_OPTIMIZE; +  +  if (car_is_node(n)) { +  CAR(n)->parent = n; +  n = CAR(n); +  continue;    } -  +  if (cdr_is_node(n)) { +  CDR(n)->parent = n; +  n = CDR(n); +  continue; +  } +  while (n->parent && +  (!cdr_is_node(n->parent) || (CDR(n->parent) == n))) { +  n = n->parent; +  } +  if (n->parent && cdr_is_node(n->parent)) { +  CDR(n->parent)->parent = n->parent; +  n = CDR(n->parent); +  continue; +  } +  break; +  } + #ifdef PIKE_DEBUG +  if (n != orig_n) { +  fatal("zzap_try_optimize() lost track of parent.\n"); +  } + #endif /* PIKE_DEBUG */ +  n->parent = parent; + }      #if defined(SHARED_NODES) && !defined(IN_TPIKE)   /* FIXME: Ought to use parent pointer to avoid recursion. */   static void find_usage(node *n, unsigned char *usage,    unsigned char *switch_u,    const unsigned char *cont_u,    const unsigned char *break_u,    const unsigned char *catch_u)   {    if (!n)