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.326 2008/05/04 16:49:07 grubba Exp $ + || $Id: pike_types.c,v 1.327 2008/05/06 15:28:26 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:3161: 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;    + #ifdef PIKE_DEBUG    fatal_check_c_stack(1024); -  + #endif       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);
pike.git/src/pike_types.c:3616:    case T_ARRAY:    case T_STRING:    if(!low_match_types(a->car, b->car,    flags & ~(A_EXACT|B_EXACT))) return 0;       case T_FLOAT:    case T_ZERO:    case T_VOID:    case T_MIXED:    break; -  + #ifdef PIKE_DEBUG    default:    Pike_fatal("Error in type string.\n"); -  + #endif    }    return ret;   }      /*    * Check the partial ordering relation.    *    * mixed    *    * int float string program function object
pike.git/src/pike_types.c:4303:    break;       case T_INT:    {    INT32 amin = CAR_TO_INT(a);    INT32 amax = CDR_TO_INT(a);       INT32 bmin = CAR_TO_INT(b);    INT32 bmax = CDR_TO_INT(b);    +  /* Handle implicit zero... */ +  if (amin == 1) amin = 0; +  if (bmin == 1) bmin = 0; +  if (amax == -1) amax = 0; +  if (bmax == -1) bmax = 0; +     if(amin < bmin || amax > bmax) return 0;    break;    }          case T_TYPE:    case T_PROGRAM:    case T_MULTISET:    case T_ARRAY:    case T_STRING:
pike.git/src/pike_types.c:4324:    b = b->car;    array_cnt = 0;    goto recurse;       case T_FLOAT:    case T_ZERO:    case T_VOID:    case T_MIXED:    break;    + #ifdef PIKE_DEBUG    default:    Pike_fatal("Error in type string.\n"); -  + #endif    }    return 1;   }      /*    * Check the function parameters.    * Note: The difference between this function, and pike_types_le()    * is the more lenient check for T_OR, and the handling of T_ARRAY.    */   int strict_check_call(struct pike_type *fun_type,
pike.git/src/pike_types.c:7213:    push_reverse_type(T_FUNCTION);   }      static void low_make_pike_type(unsigned char *type_string,    unsigned char **cont)   {    unsigned INT32 type;    struct pike_type *tmp;       switch(type = *type_string) { + #ifdef PIKE_DEBUG    case T_SCOPE:    Pike_fatal("Not supported yet.\n"); -  + #endif    case T_ASSIGN:    if ((type_string[1] < '0') || (type_string[1] > '9')) {    Pike_fatal("low_make_pike_type(): Bad marker: %d\n", type_string[1]);    }    low_make_pike_type(type_string+2, cont);    push_assign_type(type_string[1]);    break;    case T_OR:    case T_AND:    /* Order independant */
pike.git/src/pike_types.c:7339:    if(!type_string[bytes+5] && !type_string[bytes+4] &&    !type_string[bytes+3] && !type_string[bytes+2])    break;    break;    case 6:    for(bytes=0; ; bytes+=4)    if(!type_string[bytes+2] && !type_string[bytes+3] &&    !type_string[bytes+4] && !type_string[bytes+5])    break;    break; + #ifdef PIKE_DEBUG    default: /* will not happen? */    bytes=0;    Pike_fatal("unexpected case in make_pike_type (%d)\n",    type_string[1]); -  + #endif    }    str = begin_wide_shared_string(bytes>>size_shift, size_shift);    MEMCPY(str->str, type_string+2, bytes);    if (size_shift &&   #if (PIKE_BYTEORDER == 1234)    /* Little endian */    !(type_string[1] & 0x04)   #else /* PIKE_BYTEORDER != 1234 */    /* Big endian */    (type_string[1] & 0x04)
pike.git/src/pike_types.c:7383:    }    low_make_pike_type(type_string + 2 + bytes + (1<<size_shift), cont);    if (type_string[0] == PIKE_T_NAME) {    push_type_name(str = end_shared_string(str));    } else {    push_type_attribute(str = end_shared_string(str));    }    free_string(str);    break;    } + #ifdef PIKE_DEBUG    default:    Pike_fatal("compile_type_string(): Error in type string %d.\n", type);    /* NOT_REACHED */    break; -  + #endif    }   }      /* Make a pike-type from a serialized (old-style) type. */   struct pike_type *debug_make_pike_type(const char *serialized_type)   {    unsigned char *dummy;    type_stack_mark();    low_make_pike_type((unsigned char *)serialized_type, &dummy);   #if 1
pike.git/src/pike_types.c:7460:    goto again;       case T_PROGRAM:    case T_TYPE:    case T_INT:    case T_FLOAT:    case T_STRING:    case PIKE_T_ZERO:    case T_VOID:    return 1; + #ifdef PIKE_DEBUG    default:    Pike_fatal("pike_type_allow_premature_toss: Unknown type (code: %d)\n",    type->type);    /* NOT_REACHED */    return 0; -  + #endif    }   }      static void low_type_to_string(struct pike_type *t)   {    recurse:    switch(t->type) {    case T_ARRAY:    case T_MULTISET:    case T_TYPE: