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.321 2008/04/14 10:14:41 grubba Exp $ + || $Id: pike_types.c,v 1.322 2008/04/25 13:45:22 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:5869:    */       type_stack_mark();    push_finished_type(fun_type->car);    push_type(T_MIXED);    push_type(T_VOID);    push_type(T_OR);    push_type(T_MANY);    fun_type = pop_unfinished_type();    } else { -  fun_type = zzap_function_return(tmp, CDR_TO_INT(fun_type->car)); +  fun_type = zzap_function_return(tmp, fun_type->car);    }    res = lower_new_check_call(fun_type, arg_type, flags, sval 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:
pike.git/src/pike_types.c:6219:    /* Doesn't match. */    break;    case PIKE_T_PROGRAM:    tmp = low_object_lfun_type(fun_type->car, LFUN_CREATE);    if (!tmp) {    /* No create(). */    add_ref(fun_type->car);    res = fun_type->car;    break;    } else { -  fun_type = zzap_function_return(tmp, CDR_TO_INT(fun_type->car)); +  fun_type = zzap_function_return(tmp, fun_type->car);    }    res = new_get_return_type(fun_type, flags);    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.    * Failed to lookup program id.
pike.git/src/pike_types.c:6717:    }   #endif /* PIKE_DEBUG */    my_yyerror("Too many arguments to %S (expected %d arguments).",    fun_name, *argno - 1);    yytype_error(NULL, NULL, args->type, 0);    }    free_type(fun_type);    return NULL;   }    - struct pike_type *zzap_function_return(struct pike_type *a, INT32 id) + struct pike_type *zzap_function_return(struct pike_type *a, +  struct pike_type *fun_ret)   {    struct pike_type *ret = NULL;    switch(a->type)    {    case T_SCOPE: -  ret = zzap_function_return(a->cdr, id); +  ret = zzap_function_return(a->cdr, fun_ret);    if (!ret) return NULL;    type_stack_mark();    push_finished_type(ret);    free_type(ret);    push_scope_type(CAR_TO_INT(a));    return pop_unfinished_type();       case T_OR:    {    struct pike_type *ar, *br; -  ar = zzap_function_return(a->car, id); -  br = zzap_function_return(a->cdr, id); +  ar = zzap_function_return(a->car, fun_ret); +  br = zzap_function_return(a->cdr, fun_ret);    if(ar && br) ret = or_pike_types(ar, br, 0);    if(ar) free_type(ar);    if(br) free_type(br);    return ret;    }       case T_FUNCTION:    case T_MANY:    {    int nargs=0;    type_stack_mark();       while(a->type == T_FUNCTION)    {    push_finished_type(a->car);    nargs++;    a = a->cdr;    }    push_finished_type(a->car); -  push_object_type(1, id); +  push_finished_type(fun_ret);    push_reverse_type(T_MANY);    while(nargs-- > 0) {    push_reverse_type(T_FUNCTION);    }    return pop_unfinished_type();    }       case T_ARRAY: -  return zzap_function_return(a->car, id); +  return zzap_function_return(a->car, fun_ret);       case PIKE_T_NAME: -  return zzap_function_return(a->cdr, id); +  return zzap_function_return(a->cdr, fun_ret);       case PIKE_T_ATTRIBUTE:    {    struct pike_type *res; -  if ((res = zzap_function_return(a->cdr, id))) { +  if ((res = zzap_function_return(a->cdr, fun_ret))) {    type_stack_mark();    push_finished_type(res);    push_type_attribute((struct pike_string *)a->car);    free_type(res);    res = pop_unfinished_type();    }    return res;    }       case T_MIXED:    /* I wonder when this occurrs, but apparently it does... */    /* FIXME: */    type_stack_mark(); -  push_object_type(1, id); +  push_finished_type(fun_ret);    push_type(T_VOID);    push_type(T_MIXED);    push_type(T_OR);    push_type(T_MANY);    return pop_unfinished_type();    }   /* This error is bogus /Hubbe    Pike_fatal("zzap_function_return() called with unexpected value: %d\n",    EXTRACT_UCHAR(a));   */
pike.git/src/pike_types.c:6923:    return pop_unfinished_type();    }else{    copy_pike_type(ret, zero_type_string);    return ret;    }       case T_PROGRAM:    {    /* FIXME: An alternative would be to push program(object(1,p->id)). */    struct pike_type *a; -  struct pike_string *tmp; +  struct pike_type *ret_type;    int id;    -  +  type_stack_mark(); +  push_object_type(1, s->u.program->id); +  ret_type = pop_unfinished_type(); +     if(s->u.program->identifiers)    {    id=FIND_LFUN(s->u.program,LFUN_CREATE);    if(id>=0)    {    a = ID_FROM_INT(s->u.program, id)->type; -  if((a = zzap_function_return(a, s->u.program->id))) +  if((a = zzap_function_return(a, ret_type))) { +  free_type(ret_type);    return a; -  tmp=describe_type(ID_FROM_INT(s->u.program, id)->type); -  /* yywarning("Failed to zzap function return for type: %s.", tmp->str);*/ +  } + #if 0 +  { +  struct pike_string *tmp = +  describe_type(ID_FROM_INT(s->u.program, id)->type); +  yywarning("Failed to zzap function return for type: %s.", tmp->str);    free_string(tmp);    } -  + #endif /* 0 */ +  }    if (!(s->u.program->flags & PROGRAM_PASS_1_DONE)) {    /* We haven't added all identifiers in s->u.program yet,    * so we might find a create() later.    */ -  if((a = zzap_function_return(function_type_string, s->u.program->id))) +  if((a = zzap_function_return(function_type_string, ret_type))) { +  free_type(ret_type);    return a;    } -  +  }    } else { -  if((a = zzap_function_return(function_type_string, s->u.program->id))) +  if((a = zzap_function_return(function_type_string, ret_type))) { +  free_type(ret_type);    return a;    } -  +  }       type_stack_mark(); -  push_object_type(1, s->u.program->id); +  push_finished_type(ret_type);    push_type(T_VOID);    push_type(T_MANY); -  +  free_type(ret_type);    return pop_unfinished_type();    }       case T_TYPE:    type_stack_mark();    push_finished_type(s->u.type);    push_type(T_TYPE);    return pop_unfinished_type();       case T_STRING: