pike.git / src / opcodes.c

version» Context lines:

pike.git/src/opcodes.c:18:   #include "error.h"   #include "pike_types.h"   #include "pike_memory.h"   #include "fd_control.h"   #include "cyclic.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "security.h"   #include "bignum.h"    - RCSID("$Id: opcodes.c,v 1.53 1999/10/28 22:27:31 noring Exp $"); + RCSID("$Id: opcodes.c,v 1.54 1999/10/29 08:21:48 hubbe Exp $");      void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind)   {    INT32 i;      #ifdef PIKE_SECURITY    if(what->type <= MAX_COMPLEX)    if(!CHECK_DATA_SECURITY(what->u.array, SECURITY_BIT_INDEX))    error("Index permission denied.\n");   #endif
pike.git/src/opcodes.c:201:    case T_FLOAT:    i=(int)(sp[-1].u.float_number);   #ifdef AUTO_BIGNUM    if((i < 0 ? -i : i) < floor(fabs(sp[-1].u.float_number)))    {    /* Note: This includes the case when i = 0x80000000, i.e.    the absolute value is not computable. */    convert_stack_top_to_bignum();    return; /* FIXME: OK to return? Cast tests below indicates    we have to do this, at least for now... /Noring */ +  /* Yes, it is ok to return, it is actually an optimization :) +  * /Hubbe +  */    }    else   #endif /* AUTO_BIGNUM */    {    sp[-1].type=T_INT;    sp[-1].u.integer=i;    }    break;       case T_STRING:    /* This can be here independently of AUTO_BIGNUM. Besides,    we really want to reduce the number of number parsers    around here. :) /Noring */   #ifdef AUTO_BIGNUM    convert_stack_top_string_to_inumber(10);    return; /* FIXME: OK to return? Cast tests below indicates    we have to do this, at least for now... /Noring */ -  +  /* Yes, it is ok to return, it is actually an optimization :) +  * /Hubbe +  */   #else    i=STRTOL(sp[-1].u.string->str,0,10);    free_string(sp[-1].u.string);    sp[-1].type=T_INT;    sp[-1].u.integer=i;   #endif /* AUTO_BIGNUM */    break;       default:    error("Cannot cast %s to int.\n",get_name_of_type(sp[-1].type));
pike.git/src/opcodes.c:403:    }    }    return;       default:    error("Cannot cast %s to a program.\n",get_name_of_type(sp[-1].type));    }    }    }    - #ifdef PIKE_DEBUG +     if(run_time_type != sp[-1].type) -  fatal("Internal error: Cast failed (run_time_type = %d, sp[-1].type = %d.)\n",run_time_type,sp[-1].type); - #endif +  { +  if(sp[-1].type == T_OBJECT && sp[-1].u.object->prog) +  { +  int f=FIND_LFUN(sp[-1].u.object->prog, LFUN__IS_TYPE); +  if( f != -1) +  { +  push_text(get_name_of_type(run_time_type)); +  apply_low(sp[-2].u.object, f, 1); +  f=!IS_ZERO(sp-1); +  pop_stack(); +  if(f) goto emulated_type_ok; +  } +  } +  error("Cast failed, wanted %s, got %s\n", +  get_name_of_type(run_time_type), +  get_name_of_type(sp[-1].type)); +  }    -  +  emulated_type_ok: +     if (!type) return;       switch(run_time_type)    {    case T_ARRAY:    {    struct pike_string *itype;    INT32 run_time_itype;       push_string(itype=index_type(type,0));