pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.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: pike_types.c,v 1.276 2007/04/03 16:48:13 grubba Exp $ + || $Id: pike_types.c,v 1.277 2007/04/05 11:36:47 grubba Exp $   */      #include "global.h"   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"   #include "stralloc.h"   #include "stuff.h"   #include "array.h"   #include "program.h"
pike.git/src/pike_types.c:1666: Inside #if defined(PIKE_DEBUG)
   case T_NOT: fprintf(stderr, "not"); break;    case T_VOID: fprintf(stderr, "void"); break;    case T_ZERO: fprintf(stderr, "zero"); break;    case T_MIXED: fprintf(stderr, "mixed"); break;       default: fprintf(stderr, "%d",EXTRACT_UCHAR(a+e)); break;    }    }    fprintf(stderr, "\n");   } + #endif      void simple_describe_type(struct pike_type *s)   {    if (s) {    /* fprintf(stderr, "[[[%p]]]", s); */    switch(s->type) {    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    fprintf(stderr, "%d", s->type-'0');    break;
pike.git/src/pike_types.c:1836: Inside #if defined(PIKE_DEBUG) and #if defined(DEBUG_MALLOC)
   for (t = pike_type_hash[index]; t; t = t->next) {    if (t->refs) {    fprintf(stderr, "Type at 0x%p: ", t);    simple_describe_type(t);    fprintf(stderr, " (refs:%ld)\n", (long)t->refs);    }    }    }   }   #endif /* DEBUG_MALLOC */ - #endif +       static void low_describe_type(struct pike_type *t)   {    char buffer[100];       check_c_stack(1024);    /**** FIXME: ****/    switch(t->type)    {    case '0': case '1': case '2': case '3': case '4':
pike.git/src/pike_types.c:2614: Inside #if defined(PIKE_TYPE_DEBUG)
     static struct pike_type *low_match_types2(struct pike_type *a,    struct pike_type *b,    int flags)   #endif   {    int correct_args;    struct pike_type *ret;    if(a == b) return a;    +  fatal_check_c_stack(1024); +     switch(a->type)    {    case T_AND:    ret = low_match_types(a->car, b, flags);    if(!ret) return 0;    return low_match_types(a->cdr, b, flags);       case T_OR:    ret = low_match_types(a->car, b, flags);    if(ret && !(flags & NO_SHORTCUTS)) return ret;
pike.git/src/pike_types.c:2695:   #endif    }    return ret;       case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    {    int m = a->type - '0';    if(a_markers[m])    { +  struct pike_type *t = a_markers[m]; +  struct pike_type *res;   #ifdef PIKE_DEBUG    if(a_markers[m]->type == a->type)    Pike_fatal("Cyclic type!\n");    if(a_markers[m]->type == T_OR &&    a_markers[m]->car->type == a->type)    Pike_fatal("Cyclic type!\n");   #endif -  return low_match_types(a_markers[m], b, flags); +  a_markers[m] = NULL; +  res = low_match_types(t, b, flags); +  a_markers[m] = t; +  return res;    }    else    return low_match_types(mixed_type_string, b, flags);    }    }       switch(b->type)    {    case T_AND:    ret = low_match_types(a, b->car, flags);
pike.git/src/pike_types.c:2783:   #endif    }    return ret;       case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    {    int m = b->type - '0';    if(b_markers[m])    { +  struct pike_type *t = b_markers[m]; +  struct pike_type *res;   #ifdef PIKE_DEBUG    if(b_markers[m]->type == b->type)    Pike_fatal("Cyclic type!\n");   #endif -  return low_match_types(a, b_markers[m], flags); +  b_markers[m] = NULL; +  res = low_match_types(a, b_markers[m], flags); +  b_markers[m] = t; +  return res;    }    else    return low_match_types(a, mixed_type_string, flags);    }    }       /* 'mixed' matches anything */       if((a->type == T_ZERO || a->type == T_MIXED) &&    !(flags & (A_EXACT|B_EXACT)) &&
pike.git/src/pike_types.c:4992:    case T_ASSIGN:    case PIKE_T_NAME:    fun_type = fun_type->cdr;    goto loop;       case PIKE_T_RING:    fun_type = fun_type->car;    goto loop;       case T_OR: -  if (!(res = new_get_return_type(fun_type->car, flags))) { +  if (!(res = new_get_return_type(fun_type->car, flags)) || +  (res == void_type_string)) { +  /* Promote void to zero in return value in case there are others. */ +  if (res) { +  free_type(res); +  res = NULL; +  }    fun_type = fun_type->cdr;    goto loop;    } -  if (!(tmp = new_get_return_type(fun_type->cdr, flags))) { +  if (!(tmp = new_get_return_type(fun_type->cdr, flags)) || +  (tmp == void_type_string)) { +  /* Promote void to zero in return value. */ +  if (tmp) { +  free_type(tmp); +  }    break;    }    res = or_pike_types(tmp2 = res, tmp, 1);    free_type(tmp2);    free_type(tmp);    break;    case T_AND:    if (!(res = new_get_return_type(fun_type->car, flags))) {    break;    }