pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: pike_types.c,v 1.275 2007/04/01 18:23:55 grubba Exp $ + || $Id: pike_types.c,v 1.276 2007/04/03 16:48:13 grubba Exp $   */      #include "global.h"   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"   #include "stralloc.h"   #include "stuff.h"   #include "array.h"   #include "program.h"
pike.git/src/pike_types.c:4782: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "%*sChecking argument type ", indent*2+2, "");    simple_describe_type(arg_type);    fprintf(stderr, " against function type ");    simple_describe_type(fun_type);    fprintf(stderr, ".\n");    }   #endif /* PIKE_DEBUG */    if (!low_pike_types_le(arg_type, fun_type->car, 0, 0) && -  ((flags & CALL_STRICT) || -  !low_match_types(arg_type, fun_type->car, NO_SHORTCUTS))) { +  !low_match_types(arg_type, fun_type->car, NO_SHORTCUTS)) {    /* No match. */   #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "%*sNo match.\n", indent*2+2, "");    }   #endif /* PIKE_DEBUG */    res = NULL;    if (tmp) free_type(tmp);    break;    }
pike.git/src/pike_types.c:4905:    /* First split the argument type into basic types. */    switch(arg_type->type) {    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    arg_type = arg_type->cdr;    goto loop;       case T_OR:    if (!(tmp = low_new_check_call(fun_type, arg_type->car, flags))) { +  if (flags & CALL_STRICT) { +  return NULL; +  }    arg_type = arg_type->cdr;    goto loop;    }    if (!(tmp2 = low_new_check_call(fun_type, arg_type->cdr, flags))) { -  +  if (flags & CALL_STRICT) { +  return NULL; +  }    return tmp;    }    res = or_pike_types(tmp, tmp2, 1);    free_type(tmp);    free_type(tmp2);    return res;       case T_AND:    if (!(tmp = low_new_check_call(fun_type, arg_type->car, flags))) {    return NULL;    }    if (!(tmp2 = low_new_check_call(fun_type, arg_type->cdr, flags))) {    free_type(tmp);    return NULL;    }    res = and_pike_types(tmp, tmp2);    free_type(tmp);    free_type(tmp2);    return res; -  +  +  case T_VOID: +  /* Promote void arguments to zero. */ +  arg_type = zero_type_string; +  break;    }       if (!(tmp = lower_new_check_call(fun_type, arg_type, flags   #ifdef PIKE_TYPE_DEBUG    , 0   #endif    ))) {    return NULL;    }    return tmp;
pike.git/src/pike_types.c:5317:       return res;   }      /* NOTE: fun_type loses a reference. */   struct pike_type *new_check_call(struct pike_string *fun_name,    struct pike_type *fun_type,    node *args, INT32 *argno)   {    struct pike_type *tmp = NULL; +  struct pike_type *res = NULL;       debug_malloc_touch(fun_type);       while (args && (args->token == F_ARG_LIST) && fun_type) {    fun_type = new_check_call(fun_name, fun_type, CAR(args), argno);    debug_malloc_touch(fun_type);    args = CDR(args);    }       if (!args || !fun_type) {
pike.git/src/pike_types.c:5343: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, " Checking argument #%d... ", *argno);    simple_describe_type(args->type);    fprintf(stderr, "\n fun_type: ");    simple_describe_type(fun_type);    }   #endif /* PIKE_DEBUG */       if (args->token == F_PUSH_ARRAY) { -  struct pike_type *res = NULL; +     struct pike_type *prev = fun_type;    int cnt = 256;    /* This token can expand to anything between zero and MAX_ARGS args. */      #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "\n The argument is a splice operator.\n");    }   #endif /* PIKE_DEBUG */   
pike.git/src/pike_types.c:5394:    free_type(prev);    prev = fun_type;    }    free_type(prev);    if (fun_type) {    /* Max args reached or stable type. */    free_type(fun_type);    } else {    /* The splice values are invalid for later arguments. */    if (cnt == 256) { -  yywarning("The splice operator argument must be an empty array."); -  } else { -  yywarning("The splice operator argument has a max length of %d.", -  256-cnt); +  yywarning("In argument %d to %S: The @-operator argument must be an empty array.", +  *argno, fun_name); +  } else if (lex.pragmas & ID_STRICT_TYPES) { +  yywarning("In argument %d to %S: The @-operator argument has a max length of %d.", +  *argno, fun_name, 256-cnt);    }    }      #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "\n result: "); -  simple_describe_type(fun_type); +  simple_describe_type(res);    fprintf(stderr, " OK.\n");    }   #endif /* PIKE_DEBUG */       return res; -  } else if ((tmp = low_new_check_call(fun_type, args->type, 0))) { +  } else if ((res = low_new_check_call(fun_type, args->type, 0))) {    /* OK. */   #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, " OK.\n");    }   #endif /* PIKE_DEBUG */ -  +  if (lex.pragmas & ID_STRICT_TYPES) { +  if (!(tmp = low_new_check_call(fun_type, args->type, CALL_STRICT))) { +  yywarning("Type mismatch in argument %d to %S.", +  *argno, fun_name); +  if ((tmp = get_first_arg_type(fun_type, 0))) { +  yytype_error(NULL, tmp, args->type, YYTE_IS_WARNING); +  free_type(tmp); +  } else { +  yytype_error(NULL, NULL, args->type, YYTE_IS_WARNING); +  } +  } else { +  free_type(tmp); +  } +  }    free_type(fun_type); -  return tmp; +  return res;    }       if ((tmp = get_first_arg_type(fun_type, 0))) {    struct pike_type *tmp2;      #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, " Bad argument.\n");    }   #endif /* PIKE_DEBUG */