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.104 1999/12/18 14:59:38 mast Exp $"); + RCSID("$Id: pike_types.c,v 1.105 1999/12/19 14:56:37 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:2002:    /* FIXME: What if b also contains an AND? */    a++;    ret = low_pike_types_le(a, b, array_cnt);    if(ret) return ret;    a += type_length(a);    return low_pike_types_le(a, b, array_cnt);       case T_OR:    /* OK, if both of the parts are a subset */    a++; +  if (EXTRACT_UCHAR(a) == T_VOID) { +  /* Special case for T_VOID */ +  /* FIXME: Should probably be handled as T_ZERO. */ +  a += type_length(a); +  return low_pike_types_le(a, b, array_cnt); +  } else {    ret=low_pike_types_le(a, b, array_cnt);    if (!ret) return 0;    a+=type_length(a); -  +  if (EXTRACT_UCHAR(a) == T_VOID) { +  /* Special case for T_VOID */ +  /* FIXME: Should probably be handled as T_ZERO. */ +  return 1; +  } else {    return low_pike_types_le(a, b, array_cnt); -  +  } +  }       case T_NOT:    return !low_pike_types_le(a+1, b, array_cnt);       case T_ASSIGN:    ret=low_pike_types_le(a+2, b, array_cnt);    if(ret && EXTRACT_UCHAR(b)!=T_VOID)    {    int m=EXTRACT_UCHAR(a+1)-'0';    struct pike_string *tmp;
pike.git/src/pike_types.c:2676:    node *n)   {    struct pike_string *t;    clear_markers();    t=low_index_type(type->str,index_type->str,n);    if(!t) copy_shared_string(t,mixed_type_string);    return t;   }       + static struct pike_string *low_array_value_type(char *arr_t) + { +  struct pike_string *res = NULL; +  struct pike_string *sub_t; +  +  while (EXTRACT_UCHAR(arr_t) == T_OR) { +  arr_t++; +  sub_t = low_array_value_type(arr_t); +  arr_t += type_length(arr_t); +  if (sub_t) { +  if (res) { +  struct pike_string *new = or_pike_types(res, sub_t, 1); +  free_string(res); +  free_string(sub_t); +  res = new; +  } else { +  res = sub_t; +  } +  } +  } +  if (EXTRACT_UCHAR(arr_t) != T_ARRAY) +  return res; +  arr_t++; +  sub_t = make_shared_binary_string(arr_t, type_length(arr_t)); +  if (res) { +  struct pike_string *new = or_pike_types(res, sub_t, 1); +  free_string(res); +  free_string(sub_t); +  return new; +  } +  return sub_t; + } +  + struct pike_string *array_value_type(struct pike_string *array_type) + { +  struct pike_string *t = low_array_value_type(array_type->str); +  if (!t) copy_shared_string(t, mixed_type_string); +  return t; + } +  +    #ifdef DEBUG_MALLOC   #define low_key_type(X,Y) ((struct pike_string *)debug_malloc_touch(debug_low_key_type((X),(Y))))   #else   #define low_key_type debug_low_key_type   #endif      /* FIXME, add the index */   static struct pike_string *debug_low_key_type(char *t, node *n)   {    switch(EXTRACT_UCHAR(t++))
pike.git/src/pike_types.c:2940:    clear_markers();    type_stack_mark();    max_correct_args=0;       if(low_get_return_type(type->str,args->str))    {    if (lex.pragmas & ID_STRICT_TYPES) {    if (!strict_check_call(type->str, args->str)) {    struct pike_string *type_t = describe_type(type);    -  if (!low_pike_types_le(type->str, tFunction, 0)) { +  if (!low_pike_types_le(type->str, tFuncV(tNone,tZero,tMix), 0)) {    yywarning("Calling non-function value.");    yywarning("Type called: %s", type_t->str);    } else {    struct pike_string *arg_t = describe_type(args);    yywarning("Arguments not strictly compatible.");    yywarning("Expected: %s", type_t->str);    yywarning("Got : %s", arg_t->str);    free_string(arg_t);    }