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.268 2007/03/28 15:34:15 grubba Exp $ + || $Id: pike_types.c,v 1.269 2007/03/29 15:53:55 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:4552:      /* Check whether arg_type may be used as the type of the first argument    * in a call to fun_type.    *    * The first argument has no OR or AND nodes.    *    * Returns NULL on failure.    *    * Returns continuation function type on success.    */ - static struct pike_type *lower_new_check_call(struct pike_type *arg_type, -  struct pike_type *fun_type, + static struct pike_type *lower_new_check_call(struct pike_type *fun_type, +  struct pike_type *arg_type,    INT32 flags   #ifdef PIKE_TYPE_DEBUG    , INT32 indent   #define CHECK_CALL_ARGS , indent+1   #else   #define CHECK_CALL_ARGS   #endif /* PIKE_TYPE_DEBUG */    )   {    struct pike_type *res = NULL;    struct pike_type *tmp;    struct pike_type *tmp2;    INT32 array_cnt = 0;      #ifdef PIKE_TYPE_DEBUG    if (l_flag>2) {    fprintf(stderr, "%*slower_new_check_call(", indent*2, ""); -  simple_describe_type(arg_type); -  fprintf(stderr, ", "); +     simple_describe_type(fun_type); -  +  fprintf(stderr, ", "); +  simple_describe_type(arg_type);    fprintf(stderr, ", 0x%04x)...\n", flags);    }   #endif /* PIKE_TYPE_DEBUG */       loop:    /* Count the number of array levels. */    while(fun_type->type == PIKE_T_ARRAY) {    array_cnt++;    fun_type = fun_type->car;    }       switch(fun_type->type) {    case T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    fun_type = fun_type->cdr;    goto loop;       case T_OR: -  res = lower_new_check_call(arg_type, fun_type->car, flags CHECK_CALL_ARGS); +  res = lower_new_check_call(fun_type->car, arg_type, flags CHECK_CALL_ARGS);    if (!res) { -  res = lower_new_check_call(arg_type, fun_type->cdr, flags CHECK_CALL_ARGS); +  res = lower_new_check_call(fun_type->cdr, arg_type, flags CHECK_CALL_ARGS);    break;    } -  tmp = lower_new_check_call(arg_type, fun_type->cdr, flags CHECK_CALL_ARGS); +  tmp = lower_new_check_call(fun_type->cdr, arg_type, flags CHECK_CALL_ARGS);    if (!tmp) break;    res = or_pike_types(tmp2 = res, tmp, 1);    free_type(tmp);    free_type(tmp2);    break;       case T_AND: -  res = lower_new_check_call(arg_type, fun_type->car, flags CHECK_CALL_ARGS); +  res = lower_new_check_call(fun_type->car, arg_type, flags CHECK_CALL_ARGS);    if (!res) break; -  tmp = lower_new_check_call(arg_type, fun_type->cdr, flags CHECK_CALL_ARGS); +  tmp = lower_new_check_call(fun_type->cdr, arg_type, flags CHECK_CALL_ARGS);    if (!tmp) {    free_type(res);    res = NULL;    break;    }    if ((res->type == T_NOT) || (tmp->type == T_NOT)) {    /* Special cases for NOT, since and_pike_types()    * doesn't seem to handle it reliably.    */    type_stack_mark();
pike.git/src/pike_types.c:4652:    /* Both sides are inverted. Pop both. */    arg_type = arg_type->car;    fun_type = fun_type->car;    goto loop;    } else {    /* Move the inversion to the argument type. */    type_stack_mark();    push_finished_type(arg_type);    push_type(T_NOT);    arg_type = pop_unfinished_type(); -  res = lower_new_check_call(arg_type, fun_type->car, flags CHECK_CALL_ARGS); +  res = lower_new_check_call(fun_type->car, arg_type, flags CHECK_CALL_ARGS);    free_type(arg_type);    if (res) {    /* Move the inversion back to the function type. */    if (res->type == T_NOT) {    tmp = res->car;    free_type(res);    res = tmp;    } else {    type_stack_mark();    if ((res == fun_type->car) &&
pike.git/src/pike_types.c:4708:    * Failed to lookup program id. function(mixed|void...:obj)    * Program does not have a create(). function(:obj)    */       /* No create() -- No arguments. */    return NULL;    } else {    fun_type = zzap_function_return(tmp, CDR_TO_INT(fun_type->car));    free_type(tmp);    } -  res = lower_new_check_call(arg_type, fun_type, flags CHECK_CALL_ARGS); +  res = lower_new_check_call(fun_type, arg_type, flags CHECK_CALL_ARGS);    free_type(fun_type);    break;       case PIKE_T_OBJECT:    fun_type = low_object_lfun_type(fun_type, LFUN_CALL);    if (fun_type) goto loop;       /* FIXME: Multiple cases:    * Untyped object. mixed    * Failed to lookup program id. mixed
pike.git/src/pike_types.c:4848:    return res;   }      /* Check whether arg_type may be used as the type of the first argument    * in a call to fun_type.    *    * Returns NULL on failure.    *    * Returns continuation function type on success.    */ - struct pike_type *low_new_check_call(struct pike_type *arg_type, -  struct pike_type *fun_type, + struct pike_type *low_new_check_call(struct pike_type *fun_type, +  struct pike_type *arg_type,    INT32 flags)   {    struct pike_type *tmp;    struct pike_type *tmp2;    struct pike_type *res;       /* FIXME: In strict mode we need to differentiate between    * two different kinds of OR:    * * Complex types, eg    * function(int:int)|function(float:float)
pike.git/src/pike_types.c:4886:    clear_markers();    /* 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(arg_type->car, fun_type, flags))) { +  if (!(tmp = low_new_check_call(fun_type, arg_type->car, flags))) {    arg_type = arg_type->cdr;    goto loop;    } -  if (!(tmp2 = low_new_check_call(arg_type->cdr, fun_type, flags))) { +  if (!(tmp2 = low_new_check_call(fun_type, arg_type->cdr, flags))) {    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(arg_type->car, fun_type, flags))) { +  if (!(tmp = low_new_check_call(fun_type, arg_type->car, flags))) {    return NULL;    } -  if (!(tmp2 = low_new_check_call(arg_type->cdr, fun_type, flags))) { +  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;    }    -  if (!(tmp = lower_new_check_call(arg_type, fun_type, flags +  if (!(tmp = lower_new_check_call(fun_type, arg_type, flags   #ifdef PIKE_TYPE_DEBUG    , 0   #endif    ))) {    return NULL;    }    return tmp;   }      /* Return the return type for the function type fun_type, if