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.153 2001/02/26 20:06:41 grubba Exp $"); + RCSID("$Id: pike_types.c,v 1.154 2001/02/27 01:05:15 mast 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:108:   }      #ifdef PIKE_DEBUG   void check_type_string(struct pike_type *s)   {    if(debug_findstring(s) != s)    fatal("Type string not shared.\n");       if(type_length(s->str) != s->len)    { -  stupid_describe_type(s->str,s->len); +  simple_describe_type(s);    fatal("Length of type is wrong. (should be %ld, is %ld)\n",    PTRDIFF_T_TO_LONG(type_length(s->str)),    PTRDIFF_T_TO_LONG(s->len));    }   }   #endif      void init_types(void)   {    string_type_string = CONSTTYPE(tString);
pike.git/src/pike_types.c:776:       return ret;   }      #ifdef PIKE_DEBUG   void stupid_describe_type(char *a, ptrdiff_t len)   {    ptrdiff_t e;    for(e=0;e<len;e++)    { -  if(e) printf(" "); +  if(e) fputs(" ", stderr);    switch(EXTRACT_UCHAR(a+e))    {    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9': -  printf("%c",EXTRACT_UCHAR(a+e)); +  fprintf(stderr, "%c",EXTRACT_UCHAR(a+e));    break;    -  case T_SCOPE: printf("scope"); break; -  case T_TUPLE: printf("tuple"); break; -  case T_ASSIGN: printf("="); break; +  case T_SCOPE: fputs("scope", stderr); break; +  case T_TUPLE: fputs("tuple", stderr); break; +  case T_ASSIGN: fputs("=", stderr); break;    case T_INT:    {    INT32 min=extract_type_int(a+e+1);    INT32 max=extract_type_int(a+e+1+sizeof(INT32)); -  printf("int"); +  fprintf(stderr, "int");    if(min!=MIN_INT32 || max!=MAX_INT32) -  printf("(%ld..%ld)",(long)min,(long)max); +  fprintf(stderr, "(%ld..%ld)",(long)min,(long)max);    e+=sizeof(INT32)*2;    break;    } -  case T_FLOAT: printf("float"); break; -  case T_STRING: printf("string"); break; -  case T_TYPE: printf("type"); break; -  case T_PROGRAM: printf("program"); break; +  case T_FLOAT: fputs("float", stderr); break; +  case T_STRING: fputs("string", stderr); break; +  case T_TYPE: fputs("type", stderr); break; +  case T_PROGRAM: fputs("program", stderr); break;    case T_OBJECT: -  printf("object(%s %ld)", +  fprintf(stderr, "object(%s %ld)",    EXTRACT_UCHAR(a+e+1)?"is":"implements",    (long)extract_type_int(a+e+2));    e+=sizeof(INT32)+1;    break; -  case T_FUNCTION: printf("function"); break; -  case T_ARRAY: printf("array"); break; -  case T_MAPPING: printf("mapping"); break; -  case T_MULTISET: printf("multiset"); break; +  case T_FUNCTION: fputs("function", stderr); break; +  case T_ARRAY: fputs("array", stderr); break; +  case T_MAPPING: fputs("mapping", stderr); break; +  case T_MULTISET: fputs("multiset", stderr); break;    -  case PIKE_T_UNKNOWN: printf("unknown"); break; -  case T_MANY: printf("many"); break; -  case T_OR: printf("or"); break; -  case T_AND: printf("and"); break; -  case T_NOT: printf("not"); break; -  case T_VOID: printf("void"); break; -  case T_ZERO: printf("zero"); break; -  case T_MIXED: printf("mixed"); break; +  case PIKE_T_UNKNOWN: fputs("unknown", stderr); break; +  case T_MANY: fputs("many", stderr); break; +  case T_OR: fputs("or", stderr); break; +  case T_AND: fputs("and", stderr); break; +  case T_NOT: fputs("not", stderr); break; +  case T_VOID: fputs("void", stderr); break; +  case T_ZERO: fputs("zero", stderr); break; +  case T_MIXED: fputs("mixed", stderr); break;    -  default: printf("%d",EXTRACT_UCHAR(a+e)); break; +  default: fprintf(stderr, "%d",EXTRACT_UCHAR(a+e)); break;    }    } -  printf("\n"); +    }      void simple_describe_type(struct pike_type *s)   {    stupid_describe_type(s->str,s->len); -  +  fputs("\n", stderr);   }   #endif      static char *low_describe_type(char *t)   {    switch(EXTRACT_UCHAR(t++))    {    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    my_putchar(EXTRACT_UCHAR(t-1));
pike.git/src/pike_types.c:1894:    if(!low_match_types(a+type_length(a),b+type_length(b),    flags & ~(A_EXACT|B_EXACT))) return 0;    break;       case T_OBJECT:   #if 0    if(extract_type_int(a+2) || extract_type_int(b+2))    {    fprintf(stderr,"Type match1: ");    stupid_describe_type(a,type_length(a)); -  fprintf(stderr,"Type match2: "); +  fprintf(stderr,"\nType match2: ");    stupid_describe_type(b,type_length(b)); -  +  fputc('\n', stderr);    }   #endif       /* object(* 0) matches any object */    if(!extract_type_int(a+2) || !extract_type_int(b+2)) break;       /* object(x *) =? object(x *) */    if(EXTRACT_UCHAR(a+1) == EXTRACT_UCHAR(b+1))    {    /* x? */
pike.git/src/pike_types.c:2414:    */    if(!low_pike_types_le(++a, ++b, 0, flags)) return 0;    return low_pike_types_le(a+type_length(a), b+type_length(b), 0, flags);       case T_OBJECT:   #if 0    if(extract_type_int(a+2) || extract_type_int(b+2))    {    fprintf(stderr,"Type match1: ");    stupid_describe_type(a,type_length(a)); -  fprintf(stderr,"Type match2: "); +  fprintf(stderr,"\nType match2: ");    stupid_describe_type(b,type_length(b)); -  +  fputc('\n', stderr);    }   #endif       /*    * object(0|1 x) <= object(0|1 0)    * object(0|1 0) <=! object(0|1 !0)    * object(1 x) <= object(0|1 x)    * object(1 x) <= object(1 y) iff x == y    * object(1 x) <= object(0 y) iff x implements y    * Not WEAK_OBJECTS: