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.98 1999/12/15 17:04:13 grubba Exp $"); + RCSID("$Id: pike_types.c,v 1.99 1999/12/15 19:42:09 hubbe 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:74:   struct pike_string *mapping_type_string;   struct pike_string *type_type_string;   struct pike_string *mixed_type_string;   struct pike_string *void_type_string;   struct pike_string *zero_type_string;   struct pike_string *any_type_string;   struct pike_string *weak_type_string; /* array|mapping|multiset|function */      static struct pike_string *a_markers[10],*b_markers[10];    + static struct program *implements_a; + static struct program *implements_b; +    static void clear_markers(void)   {    unsigned int e;    for(e=0;e<NELEM(a_markers);e++)    {    if(a_markers[e])    {    free_string(a_markers[e]);    a_markers[e]=0;    }
pike.git/src/pike_types.c:1868: Inside #if 0
     #if 0    /* FIXME: Temporary kludge.    * match_types() currently seems to need to be symetric.    */    if (!implements(ap,bp) && !implements(bp,ap))    return 0;   #else /* !1 */    if(EXTRACT_UCHAR(a+1))    { -  if(!implements(ap,bp)) +  if(!implements(implements_a=ap,implements_b=bp))    return 0;    }else{ -  if(!implements(bp,ap)) +  if(!implements(implements_a=bp,implements_b=ap))    return 0;    }   #endif /* 1 */    }       break;       case T_INT:    {    INT32 amin=extract_type_int(a+1);
pike.git/src/pike_types.c:2335:    }       {    struct program *ap = id_to_program(extract_type_int(a+2));    struct program *bp = id_to_program(extract_type_int(b+2));       if (!ap || !bp) {    /* Shouldn't happen... */    return 0;    } -  return implements(ap, bp); +  return implements(implements_a=ap, implements_b=bp);    }    break;       case T_INT:    {    INT32 amin=extract_type_int(a+1);    INT32 amax=extract_type_int(a+1+sizeof(INT32));       INT32 bmin=extract_type_int(b+1);    INT32 bmax=extract_type_int(b+1+sizeof(INT32));
pike.git/src/pike_types.c:3221:    return 1;       case T_OBJECT:    {    struct program *p=id_to_program(extract_type_int(type+1));    if(!p) return 1;    return FIND_LFUN(p, lfun)!=-1;    }    }   } +  +  + void yyexplain_nonmatching_types(struct pike_string *type_a, +  struct pike_string *type_b) + { +  implements_a=0; +  implements_b=0; +  +  match_types(type_a,type_b); +  +  if(!(implements_a && implements_b && +  type_a->str[0]==T_OBJECT && +  type_b->str[0]==T_OBJECT)) +  { +  struct pike_string *s1,*s2; +  s1=describe_type(type_a); +  s2=describe_type(type_b); +  my_yyerror("Expected: %s",s1->str); +  my_yyerror("Got : %s",s2->str); +  free_string(s1); +  free_string(s2); +  } +  +  if(implements_a && implements_b) +  yyexplain_not_implements(implements_a,implements_b); + }