pike.git / src / opcodes.c

version» Context lines:

pike.git/src/opcodes.c:19:   #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"   #include "operators.h"    - RCSID("$Id: opcodes.c,v 1.93 2000/11/24 05:41:02 mast Exp $"); + RCSID("$Id: opcodes.c,v 1.94 2000/11/29 13:14:18 mirar 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:178:    default:    error("Cannot cast %s to multiset.\n",get_name_of_type(sp[-1].type));    }    break;       case T_MAPPING:    switch(sp[-1].type)    {    case T_ARRAY:    { -  f_transpose(1); -  sp--; -  dmalloc_touch_svalue(sp); -  push_array_items(sp->u.array); -  f_mkmapping(2); +  struct array *a=sp[-1].u.array; +  struct array *b; +  struct mapping *m; +  INT32 i; +  m=allocate_mapping(a->size); /* MAP_SLOTS(a->size) */ +  push_mapping(m); +  for (i=0; i<a->size; i++) +  { +  if (ITEM(a)[i].type!=T_ARRAY) +  error("Cast array to mapping: " +  "element %d is not an array\n", i); +  b=ITEM(a)[i].u.array; +  if (b->size!=2) +  error("Cast array to mapping: " +  "element %d is not an array of size 2\n", i); +  mapping_insert(m,ITEM(b)+0,ITEM(b)+1); +  } +  stack_swap(); +  pop_n_elems(1);    break;    }       default:    error("Cannot cast %s to mapping.\n",get_name_of_type(sp[-1].type));    }    break;       case T_ARRAY:    switch(sp[-1].type)