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.293 2007/04/21 20:08:26 grubba Exp $ + || $Id: pike_types.c,v 1.294 2007/04/25 15:43:07 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:5450:       case T_AND:    res = lower_new_check_call(fun_type->car, arg_type, flags, sval CHECK_CALL_ARGS);    if (!res) break;    tmp = lower_new_check_call(fun_type->cdr, arg_type, flags, sval 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. +  if (res == tmp) { +  /* Common case. */ +  free_type(tmp); +  break; +  } +  /* and_pike_types() doesn't handle and of functions +  * in the way we want here.    */    type_stack_mark(); -  if (res->type == tmp->type) { -  push_finished_type(tmp2 = and_pike_types(res->car, tmp->car)); -  free_type(res); -  free_type(tmp); -  free_type(tmp2); -  push_type(T_NOT); -  } else { -  push_finished_type(res); -  free_type(res); +     push_finished_type(tmp); -  free_type(tmp); +  push_finished_type(res);    push_type(T_AND); -  } -  res = pop_unfinished_type(); -  } else { -  res = and_pike_types(tmp2 = res, tmp); +     free_type(tmp); -  free_type(tmp2); -  } +  free_type(res); +  res = pop_unfinished_type();    break;       case T_NOT:    if (arg_type->type == T_NOT) {    /* Both sides are inverted. Pop both inversions. */    arg_type = arg_type->car;    fun_type = fun_type->car;    goto loop;    } else {    /* Move the inversion to the argument type. */
pike.git/src/pike_types.c:5632:    res = NULL;    if (tmp) free_type(tmp);    break;    }    }    type_stack_mark();    push_finished_type_with_markers(fun_type, b_markers, PT_FLAG_MARKER);    res = pop_unfinished_type();    if (tmp) free_type(tmp);    -  if ((tmp2->type == PIKE_T_ATTRIBUTE) && -  (Pike_compiler->compiler_pass == 2) && -  sval) { +  if ((Pike_compiler->compiler_pass == 2) && sval) { +  while (tmp2->type == PIKE_T_NAME) { +  tmp2 = tmp2->cdr; +  } +  +  if (tmp2->type == PIKE_T_ATTRIBUTE) {    /* Perform extra argument checking based on the attribute. */    /* FIXME: Support multiple attributes. */    ref_push_string((struct pike_string *)tmp2->car);    push_svalue(sval);    ref_push_type_value(tmp2->cdr);    ref_push_type_value(res);    if (safe_apply_handler("handle_attribute_constant", error_handler,    compat_handler, 4, 0)) {    if ((Pike_sp[-1].type == PIKE_T_TYPE)) {    type_stack_mark();    push_finished_type(Pike_sp[-1].u.type);    push_finished_type(res);    push_type(T_AND);    free_type(res);    res = pop_unfinished_type();    }    pop_stack();    }    } -  +  }   #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "%*sSuccess.\n", indent*2+2, "");    }   #endif /* PIKE_DEBUG */    break;    default:    /* Not a callable. */    break;    }
pike.git/src/pike_types.c:7282:    array_type_string = CONSTTYPE(tArray);    multiset_type_string = CONSTTYPE(tMultiset);    mapping_type_string = CONSTTYPE(tMapping);    function_type_string = CONSTTYPE(tFunction);    type_type_string = CONSTTYPE(tType(tMix));    void_type_string = CONSTTYPE(tVoid);    zero_type_string = CONSTTYPE(tZero);    any_type_string = CONSTTYPE(tOr(tVoid,tMix));    weak_type_string = CONSTTYPE(tOr4(tArray,tMultiset,tMapping,    tFuncV(tNone,tZero,tOr(tMix,tVoid)))); -  //add_ref(weak_type_string); /* LEAK */ +  /* add_ref(weak_type_string); /* LEAK */       builtin_attributes = allocate_mapping(20);       ADD_EFUN("__register_attribute_handler", f___register_attribute_handler,    tFunc(tSetvar(0, tStr)    tFunc(tVar(0) tMix tType(tMix) tType(tMix), tType(tMix)),    tVoid), 0);       ADD_EFUN("__handle_attribute_constant", f___handle_attribute_constant,    tFunc(tStr tMix tType(tMix) tType(tMix), tType(tMix)), 0);