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.55 1999/04/13 20:10:09 hubbe Exp $"); + RCSID("$Id: pike_types.c,v 1.56 1999/06/03 01:39:36 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:1689:    * return -1-n if the function can take number of arguments    * >= n (varargs)    */   int count_arguments(struct pike_string *s)   {    check_type_string(s);       return low_count_arguments(s->str);   }    +  + static int low_minimum_arguments(char *q) + { +  int num; +  +  switch(EXTRACT_UCHAR(q++)) +  { +  case T_OR: +  case T_AND: +  return MAXIMUM(low_count_arguments(q), +  low_count_arguments(q+type_length(q))); +  +  default: return 0; +  +  case T_FUNCTION: +  num=0; +  while(EXTRACT_UCHAR(q)!=T_MANY) +  { +  if(low_match_types(void_type_string->str, q, B_EXACT)) +  return num; +  +  num++; +  q+=type_length(q); +  } +  return num; +  } + } +  + /* Count the minimum number of arguments for a funciton type. +  */ + int minimum_arguments(struct pike_string *s) + { +  int ret; +  check_type_string(s); +  +  ret=low_minimum_arguments(s->str); +  + #if 0 +  fprintf(stderr,"minimum_arguments("); +  simple_describe_type(s); +  fprintf(stderr," ) -> %d\n",ret); + #endif +  +  return ret; + } +    struct pike_string *check_call(struct pike_string *args,    struct pike_string *type)   {    check_type_string(args);    check_type_string(type);    clear_markers();    type_stack_mark();    max_correct_args=0;       if(low_get_return_type(type->str,args->str))