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.115 1999/12/30 21:05:19 mast Exp $"); + RCSID("$Id: pike_types.c,v 1.116 1999/12/31 14:50:16 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:1949:       default:    fatal("error in type string.\n");    }    return ret;   }      /*    * Flags used by pike_types_le()    */ - #define LE_WEAK_ARGS 1 /* Perform weaker checking of funtion args. */ + #define LE_WEAK_OBJECTS 1 /* Perform weaker checking of objects. */         /*    * Check the partial ordering relation.    *    * mixed    *    * int float string program function object    *    * zero
pike.git/src/pike_types.c:2343:    if(EXTRACT_UCHAR(b)==T_MANY)    {    b_tmp=b+1;    }else{    b_tmp=b;    b+=type_length(b);    }       if (EXTRACT_UCHAR(a_tmp) != T_VOID) {    if (!low_pike_types_le(b_tmp, a_tmp, 0, flags)) { -  if (!(flags & LE_WEAK_ARGS) || -  !low_pike_types_le(a_tmp, b_tmp, 0, flags)) { +     return 0;    }    }    } -  } +     /* check the 'many' type */    a++;    b++;    if ((EXTRACT_UCHAR(a) != T_VOID) && (EXTRACT_UCHAR(b) != T_VOID)) {    if (!low_pike_types_le(b, a, 0, flags)) { -  if (!(flags & LE_WEAK_ARGS) || -  !low_pike_types_le(a, b, 0, flags)) { +     return 0;    }    } -  } +        a+=type_length(a);    b+=type_length(b);       /* check the returntype */    /* FIXME: Check array_cnt */    if ((EXTRACT_UCHAR(b) != T_VOID) && (EXTRACT_UCHAR(a) != T_VOID)) {    if(!low_pike_types_le(a, b, array_cnt, flags)) return 0;    }    return 1;
pike.git/src/pike_types.c:2400: Inside #if 0
   fprintf(stderr,"Type match2: ");    stupid_describe_type(b,type_length(b));    }   #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(0|1 x) <= object(0 y) iff x implements y +  * object(1 x) <= object(0 y) iff x implements y +  * Not WEAK_OBJECTS: +  * object(0 x) <= object(0 y) iff x implements y +  * WEAK_OBJECTS: +  * object(0 x) <= object(0 y) iff x is_compatible y    */       /* object(* 0) matches any object */    if(!extract_type_int(b+2))    return 1;       if(!extract_type_int(a+2))    return 0;       if ((EXTRACT_UCHAR(a+1) || !EXTRACT_UCHAR(b+1)) &&
pike.git/src/pike_types.c:2426:    }       {    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;    } +  if ((flags & LE_WEAK_OBJECTS) && (!EXTRACT_UCHAR(a+1))) { +  return is_compatible(implements_a=ap, implements_b=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);
pike.git/src/pike_types.c:2487:    return low_pike_types_le(fun_type, arg_type, 0, 0);   }      /*    * Check validity of soft-cast.    * Note: This uses a weaker check of function arguments, since    * people get confused otherwise.    */   int check_soft_cast(struct pike_string *to, struct pike_string *from)   { -  return low_pike_types_le(to->str, from->str, 0, LE_WEAK_ARGS); +  return low_pike_types_le(to->str, from->str, 0, LE_WEAK_OBJECTS);   }      /*    * Return the return type from a function call.    */   static int low_get_return_type(char *a,char *b)   {    int tmp;    switch(EXTRACT_UCHAR(a))    {