pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.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: pike_types.c,v 1.172 2001/03/29 20:19:16 grubba Exp $"); + RCSID("$Id: pike_types.c,v 1.173 2001/03/31 01:12:47 grubba Exp $");   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"   #include "stralloc.h"   #include "stuff.h"   #include "array.h"   #include "program.h"   #include "constants.h"   #include "object.h"   #include "multiset.h"
pike.git/src/pike_types.c:497:    fatal("Type mark stack underflow\n");       TYPE_STACK_DEBUG("pop_stack_mark");       return Pike_compiler->type_stackp - *Pike_compiler->pike_type_mark_stackp;   }      void type_stack_pop_to_mark(void)   {    pop_stack_mark(); -  while(Pike_compiler->type_stackp > *Pike_compiler->pike_type_mark_stackp) -  pop_type_stack(); +  while(Pike_compiler->type_stackp > *Pike_compiler->pike_type_mark_stackp) { +  free_type(*(Pike_compiler->type_stackp--)); +  }       TYPE_STACK_DEBUG("type_stack_pop_to_mark");   }      struct pike_type *debug_peek_type_stack(void)   {    return *(Pike_compiler->type_stackp);   }      void debug_push_int_type(INT32 min, INT32 max)
pike.git/src/pike_types.c:645:    case '9':    /* Marker. */    *(++Pike_compiler->type_stackp) = mk_type(type, NULL, NULL, PT_SET_MARKER);    break;    }       TYPE_STACK_DEBUG("push_type");   }      /* Pop one level of types. This is the inverse of push_type() */ - void debug_pop_type_stack(void) + void debug_pop_type_stack(unsigned INT16 expected)   {    struct pike_type *top;    if(Pike_compiler->type_stackp<type_stack)    fatal("Type stack underflow\n");       top = *(Pike_compiler->type_stackp--); -  + #ifdef PIKE_DEBUG +  if ((top->type != expected) && (top->type != PIKE_T_NAME)) { +  fatal("Unexpected type on stack: %d (expected %d)\n", top->type, expected); +  } + #endif /* PIKE_DEBUG */ +  /* OPTIMIZE: It looks like this function is always called with +  * expected == T_ARRAY. +  */    switch(top->type) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    /* Both car & cdr. */    push_finished_type(top->cdr);
pike.git/src/pike_types.c:700:    case '5':    case '6':    case '7':    case '8':    case '9':    /* Leaf */    break;    case PIKE_T_NAME:    /* Pop the name and recurse. */    push_finished_type(top->cdr); -  pop_type_stack(); +  pop_type_stack(expected);    break;    default:    Pike_error("pop_type_stack(): Unhandled node type: %d\n", top->type);    }    free_type(top);       TYPE_STACK_DEBUG("pop_type_stack");   }      void debug_push_reverse_type(unsigned INT16 type)
pike.git/src/pike_types.c:4580:      ptrdiff_t pop_stack_mark(void)   {    Pike_compiler->pike_type_mark_stackp--;    if(Pike_compiler->pike_type_mark_stackp<pike_type_mark_stack)    fatal("Type mark stack underflow\n");       return Pike_compiler->type_stackp - *Pike_compiler->pike_type_mark_stackp;   }    - void debug_pop_type_stack(void) + void debug_pop_type_stack(unsigned INT16 expected)   { -  + #ifdef PIKE_DEBUG +  if (Pike_compiler->type_stackp[0] != expected) { +  fatal("Unexpected type node: %d (expected: %d)\n", +  Pike_compiler->type_stackp[0], expected); +  } + #endif /* PIKE_DEBUG */    Pike_compiler->type_stackp--;    if(Pike_compiler->type_stackp<type_stack)    fatal("Type stack underflow\n");   }         void type_stack_pop_to_mark(void)   {    Pike_compiler->type_stackp-=pop_stack_mark();   #ifdef PIKE_DEBUG