pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:449:       if (TYPEOF(Pike_sp[-1]) == T_OBJECT && !Pike_sp[-1].u.object->prog) {    /* Casting a destructed object should be like casting a zero. */    pop_stack();    push_int (0);    }       if(TYPEOF(Pike_sp[-1]) == T_OBJECT)    {    struct object *o = Pike_sp[-1].u.object; -  int f = FIND_LFUN(o->prog->inherits[SUBTYPEOF(Pike_sp[-1])].prog, LFUN_CAST); -  if(f == -1) { +  int f = FIND_LFUN(o->prog->inherits[SUBTYPEOF(Pike_sp[-1])].prog, +  LFUN_CAST); +  if(f >= 0) { +  push_static_text(get_name_of_type(run_time_type)); +  apply_low(o, f, 1); +  +  if (!IS_UNDEFINED(Pike_sp-1)) { +  stack_pop_keep_top(); +  +  goto check_cast; +  } +  +  pop_stack(); +  } +     if (run_time_type == T_MAPPING) {    stack_dup();    f_indices(1);    stack_swap();    f_values(1);    f_mkmapping(2);    goto emulated_type_ok;    } -  if (run_time_type != T_PROGRAM) { -  Pike_error("No cast method in object.\n"); -  } -  f_object_program(1); -  return; -  } -  push_static_text(get_name_of_type(type->type)); -  apply_low(o, f, 1); +        if (run_time_type == T_PROGRAM) { -  if (IS_UNDEFINED(Pike_sp-1)) { -  pop_stack(); +     f_object_program(1);    return;    } -  } +     -  stack_pop_keep_top(); -  -  if(TYPEOF(Pike_sp[-1]) == T_INT && -  SUBTYPEOF(Pike_sp[-1]) == NUMBER_UNDEFINED) +  if (f >= 0) {    Pike_error("Cannot cast this object to %s.\n", -  get_name_of_type(type->type)); +  get_name_of_type(run_time_type)); +  } else { +  Pike_error("No cast method in object.\n"); +  }       } else       switch(run_time_type)    {    default:    Pike_error("Cannot perform cast to that type.\n");    break;       case T_MULTISET:
pike.git/src/operators.c:708:    return;    }       default:    Pike_error("Cannot cast %s to a program.\n",    get_name_of_type(TYPEOF(Pike_sp[-1])));    }    }    }    +  check_cast:    if(run_time_type != TYPEOF(Pike_sp[-1]))    {    switch(TYPEOF(Pike_sp[-1])) {    case T_OBJECT:    if(Pike_sp[-1].u.object->prog)    {    struct object *o = Pike_sp[-1].u.object;    int f = FIND_LFUN(o->prog->inherits[SUBTYPEOF(Pike_sp[-1])].prog,    LFUN__IS_TYPE);    if( f != -1)