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.87 1999/12/11 03:41:47 grubba Exp $"); + RCSID("$Id: pike_types.c,v 1.88 1999/12/11 19:24:38 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:31:      static void internal_parse_type(char **s);   static int type_length(char *t);   static int low_pike_types_le(char *a, char *b);      #define TWOT(X,Y) (((X) << 8)+(Y))   #define EXTRACT_TWOT(X,Y) TWOT(EXTRACT_UCHAR(X), EXTRACT_UCHAR(Y))      /*    * basic types are represented by just their value in a string -  * basic type are string, int, float, object and program +  * basic type are string, type, int, float, object and program    * arrays are coded like by the value T_ARRAY followed by the    * data type, if the type is not known it is T_MIXED, ie:    * T_ARRAY <data type>    * mappings are followed by two arguments, the first is the type    * for the indices, and the second is the type of the data, ie:    * T_MAPPING <indice type> <data type>    * multiset works similarly to arrays.    * functions are _very_ special:    * they are coded like this:    * T_FUNCTION <arg type> <arg type> ... <arg type> T_MANY <arg type> <return type>    * note that the type after T_MANY can be T_VOID    * T_MIXED matches anything except T_VOID    * T_UNKNOWN only matches T_MIXED and T_UNKNOWN    * objects are coded thus:    * T_OBJECT <0/1> <program_id>    * ^    * 0 means 'inherits'    * 1 means 'is' -  +  * Integers are encoded as: +  * T_INT <min> <max>    * Everything except T_VOID matches T_ZERO.    */      struct pike_string *string_type_string;   struct pike_string *int_type_string;   struct pike_string *float_type_string;   struct pike_string *function_type_string;   struct pike_string *object_type_string;   struct pike_string *program_type_string;   struct pike_string *array_type_string;
pike.git/src/pike_types.c:1416: Inside #if defined(PIKE_TYPE_DEBUG)
   init_buf();    for(e=0;e<indent;e++) my_strcat(" ");    my_strcat("low_match_types(");    low_describe_type(a);    if(type_length(a) + type_length(b) > 10)    {    my_strcat(",\n");    for(e=0;e<indent;e++) my_strcat(" ");    my_strcat(" ");    low_describe_type(b); +  my_strcat(",\n"); +  for(e=0;e<indent;e++) my_strcat(" "); +  my_strcat(" ");    }else{    my_strcat(", ");    low_describe_type(b); -  +  my_strcat(", ");    } -  +  if (flags) { +  int f = 0; +  if (flags & A_EXACT) { +  my_strcat("A_EXACT"); +  f = 1; +  } +  if (flags & B_EXACT) { +  if (f) { +  my_strcat(" | "); +  } +  my_strcat("B_EXACT"); +  f = 1; +  } +  if (flags & NO_MAX_ARGS) { +  if (f) { +  my_strcat(" | "); +  } +  my_strcat("NO_MAX_ARGS"); +  f = 1; +  } +  if (flags & NO_SHORTCUTS) { +  if (f) { +  my_strcat(" | "); +  } +  my_strcat("NO_SHORTCUTS"); +  f = 1; +  } +  } else { +  my_strcat("0"); +  }    my_strcat(");\n");    fprintf(stderr,"%s",(s=simple_free_buf()));    free(s);    indent++;       a=low_match_types2(a,b,flags);       indent--;    init_buf();    for(e=0;e<indent;e++) my_strcat(" ");
pike.git/src/pike_types.c:1619:    return low_match_types(a, b_markers[m]->str, flags);    }    else    return low_match_types(a, mixed_type_string->str, flags);    }    }       /* 'mixed' matches anything */       if(((EXTRACT_UCHAR(a) == T_ZERO || EXTRACT_UCHAR(a) == T_MIXED) && -  !(flags & A_EXACT) && +  !(flags & (A_EXACT|B_EXACT)) &&    EXTRACT_UCHAR(b) != T_VOID))    {   #if 1    switch(EXTRACT_UCHAR(b))    {    /* These types can contain sub-types */    case T_ARRAY:    low_match_types(array_type_string->str,b , flags);    break;    case T_MAPPING:
pike.git/src/pike_types.c:1644: Inside #if 1
   break;    case T_MULTISET:    low_match_types(multiset_type_string->str,b, flags);    break;    }   #endif    return a;    }       if((( EXTRACT_UCHAR(b) == T_ZERO || EXTRACT_UCHAR(b) == T_MIXED) && -  !(flags & B_EXACT) && +  !(flags & (A_EXACT|B_EXACT)) &&    EXTRACT_UCHAR(a) != T_VOID))    {   #if 1    switch(EXTRACT_UCHAR(a))    {    /* These types can contain sub-types */    case T_ARRAY:    low_match_types(a , array_type_string->str, flags);    break;    case T_MAPPING:
pike.git/src/pike_types.c:1680:    a = tInt0;    if (EXTRACT_UCHAR(b) == T_ZERO)    b = tInt0;       /* Special cases (tm) */    switch(EXTRACT_TWOT(a,b))    {    case TWOT(T_PROGRAM, T_FUNCTION):    case TWOT(T_FUNCTION, T_PROGRAM):    return a; +     case TWOT(T_OBJECT, T_FUNCTION):    {    struct pike_string *s;    if((s=low_object_lfun_type(a, LFUN_CALL))) -  return low_match_types(s->str,b,flags & ~(A_EXACT|B_EXACT)); +  return low_match_types(s->str,b,flags); +  if (flags & B_EXACT) { +  /* A function isn't an object */ +  return 0; +  }    return a;    }       case TWOT(T_FUNCTION, T_OBJECT):    {    struct pike_string *s;    if((s=low_object_lfun_type(b, LFUN_CALL))) -  return low_match_types(a,s->str,flags & ~(A_EXACT|B_EXACT)); +  return low_match_types(a,s->str,flags); +  if (flags & A_EXACT) { +  /* A function isn't an object */ +  return 0; +  }    return a;    }    }       if(EXTRACT_UCHAR(a) != EXTRACT_UCHAR(b)) return 0;       ret=a;    switch(EXTRACT_UCHAR(a))    {    case T_FUNCTION: