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.92 1999/09/22 18:39:10 grubba Exp $"); + RCSID("$Id: las.c,v 1.93 1999/10/23 06:51:26 hubbe 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:22:   #include "error.h"   #include "docode.h"   #include "main.h"   #include "pike_memory.h"   #include "operators.h"   #include "callback.h"   #include "pike_macros.h"   #include "peep.h"   #include "builtin_functions.h"   #include "cyclic.h" + #include "block_alloc.h"      #define LASDEBUG      int lasdebug=0;      static node *eval(node *);   static void optimize(node *n);      node *init_node = 0;   int num_parse_error;
pike.git/src/las.c:189:    {    if(b && a!=b) return mixed_type_string;    return a;    }    return b;   }         #define NODES 256    - struct node_chunk - { -  struct node_chunk *next; -  node nodes[NODES]; - }; + #undef BLOCK_ALLOC_NEXT + #define BLOCK_ALLOC_NEXT u.node.a    - static struct node_chunk *node_chunks=0; - static node *free_nodes=0; + BLOCK_ALLOC(node_s, NODES);    -  + #undef BLOCK_ALLOC_NEXT + #define BLOCK_ALLOC_NEXT next +    void free_all_nodes(void)   {    if(!compiler_frame)    {    node *tmp; -  struct node_chunk *tmp2; +  struct node_s_block *tmp2;    int e=0;      #ifndef PIKE_DEBUG    if(cumulative_parse_error)    {   #endif    -  for(tmp2=node_chunks;tmp2;tmp2=tmp2->next) e+=NODES; -  for(tmp=free_nodes;tmp;tmp=CAR(tmp)) e--; +  for(tmp2=node_s_blocks;tmp2;tmp2=tmp2->next) e+=NODES; +  for(tmp=free_node_ss;tmp;tmp=CAR(tmp)) e--;    if(e)    {    int e2=e; -  for(tmp2=node_chunks;tmp2;tmp2=tmp2->next) +  for(tmp2=node_s_blocks;tmp2;tmp2=tmp2->next)    {    for(e=0;e<NODES;e++)    { -  for(tmp=free_nodes;tmp;tmp=CAR(tmp)) -  if(tmp==tmp2->nodes+e) +  for(tmp=free_node_ss;tmp;tmp=CAR(tmp)) +  if(tmp==tmp2->x+e)    break;       if(!tmp)    { -  tmp=tmp2->nodes+e; +  tmp=tmp2->x+e;   #ifdef PIKE_DEBUG    if(!cumulative_parse_error)    {    fprintf(stderr,"Free node at %p, (%s:%d) (token=%d).\n",tmp, tmp->current_file->str, tmp->line_number, tmp->token); -  +  +  debug_malloc_dump_references(tmp); +     if(tmp->token==F_CONSTANT)    print_tree(tmp);    }    else   #endif    {    /* Free the node and be happy */    /* Make sure we don't free any nodes twice */    if(car_is_node(tmp)) CAR(tmp)=0;    if(cdr_is_node(tmp)) CDR(tmp)=0;
pike.git/src/las.c:255:    }    }   #ifdef PIKE_DEBUG    if(!cumulative_parse_error)    fatal("Failed to free %d nodes when compiling!\n",e2);   #endif    }   #ifndef PIKE_DEBUG    }   #endif -  while(node_chunks) -  { -  tmp2=node_chunks; -  node_chunks=tmp2->next; -  free((char *)tmp2); -  } -  free_nodes=0; +  free_all_node_s_blocks();    cumulative_parse_error=0;    }   }      void free_node(node *n)   {    if(!n) return;   #ifdef PIKE_DEBUG    if(l_flag>9)    print_tree(n);
pike.git/src/las.c:294:    default:    if(car_is_node(n)) free_node(CAR(n));    if(cdr_is_node(n)) free_node(CDR(n));    }    n->token=USHRT_MAX;    if(n->type) free_string(n->type);    if(n->name) free_string(n->name);   #ifdef PIKE_DEBUG    if(n->current_file) free_string(n->current_file);   #endif -  CAR(n)=free_nodes; -  free_nodes=n; +  really_free_node_s(n);   }         /* here starts routines to make nodes */   static node *mkemptynode(void)   { -  node *res; -  if(!free_nodes) -  { -  int e; -  struct node_chunk *tmp=ALLOC_STRUCT(node_chunk); -  tmp->next=node_chunks; -  node_chunks=tmp; -  -  for(e=0;e<NODES-1;e++) -  CAR(tmp->nodes+e)=tmp->nodes+e+1; -  CAR(tmp->nodes+e)=0; -  free_nodes=tmp->nodes; -  } -  res=free_nodes; -  free_nodes=CAR(res); +  node *res=alloc_node_s();    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;    res->parent=0;