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.357 2008/09/12 13:30:44 grubba Exp $ + || $Id: pike_types.c,v 1.358 2008/09/12 15:21:41 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:5542:    if (tmp == soft_type) return tmp;    tmp2 = soft_cast(soft_type, orig_type->cdr, flags);    if (tmp2 == soft_type) {    res = tmp2;    tmp2 = NULL;    } else {    res = or_pike_types(tmp, tmp2, 1);    }    break;    case T_AND: -  /* FIXME: Make stricter analogous to OR above. */ -  res = and_pike_types(tmp = soft_cast(soft_type, orig_type->car, flags), -  tmp2 = soft_cast(soft_type, orig_type->cdr, flags)); +  /* Note: We need to handle T_NOT here. */ +  if (orig_type->car->type != T_NOT) { +  tmp = soft_cast(soft_type, orig_type->car, flags); +  if (!tmp) return NULL; +  if (tmp == orig_type->car) { +  /* The original type is stricter than the soft type. */ +  free_type(tmp); +  add_ref(orig_type); +  return orig_type; +  } +  } +  if (orig_type->cdr->type != T_NOT) { +  tmp2 = soft_cast(soft_type, orig_type->cdr, flags); +  if (!tmp2) { +  if (tmp) free_type(tmp); +  return NULL; +  } +  if (tmp2 == orig_type->cdr) { +  /* The original type is stricter than the soft type. */ +  if (tmp) free_type(tmp); +  free_type(tmp2); +  add_ref(orig_type); +  return orig_type; +  } +  } +  res = and_pike_types(tmp?tmp:orig_type->car, tmp2?tmp2:orig_type->cdr);    break;    case T_SCOPE:    if ((res = soft_cast(soft_type, orig_type->cdr, flags))) {    type_stack_mark();    push_finished_type(res);    push_scope_type(CAR_TO_INT(orig_type));    free_type(res);    res = pop_unfinished_type();    }    return res;
pike.git/src/pike_types.c:5724:    tmp2 = NULL;    while(array_cnt--) push_type(T_ARRAY);    push_reverse_type(T_MANY);    while(loop_cnt--) push_reverse_type(T_FUNCTION);    res = pop_unfinished_type();    break;    }    function_cast_fail:    type_stack_pop_to_mark();    break; +  case T_NOT: /* FIXME. */    default:    if (soft_type->type != orig_type->type) break;    switch(soft_type->type) {    case T_MAPPING:    type_stack_mark();    if ((tmp = soft_cast(soft_type->car, orig_type->car,    flags ^ SOFT_WEAKER))) {    push_finished_type(tmp);    } else {    push_finished_type(zero_type_string);