pike.git / src / opcodes.c

version» Context lines:

pike.git/src/opcodes.c:15:   #include "opcodes.h"   #include "object.h"   #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"    - RCSID("$Id: opcodes.c,v 1.21 1998/04/26 11:44:24 hubbe Exp $"); + RCSID("$Id: opcodes.c,v 1.22 1998/05/06 13:27:40 grubba Exp $");      void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind)   {    INT32 i;    switch(what->type)    {    case T_ARRAY:    simple_array_index_no_free(to,what->u.array,ind);    break;   
pike.git/src/opcodes.c:185:    switch(sp[-1].type)    {    case T_INT:    sprintf(buf,"%ld",(long)sp[-1].u.integer);    break;       case T_FLOAT:    sprintf(buf,"%f",(double)sp[-1].u.float_number);    break;    +  case T_ARRAY: +  { +  int i; +  struct array *a = sp[-1].u.array; +  struct pike_string *s; +  +  for(i = a->size; i--; ) { +  if (a->item[i].type != T_INT) { +  error("cast: Item %d is not an integer.\n", i); +  } +  if ((a->item[i].u.integer < 0) || +  (a->item[i].u.integer > 255)) { +  error("cast: Wide strings are not supported yet.\n" +  "Index %d is %d, and is out of range 0 .. 255.\n", +  i, a->item[i].u.integer); +  } +  } +  s = begin_shared_string(a->size); +  for(i = a->size; i--; ) { +  s->str[i] = a->item[i].u.integer; +  } +  s = end_shared_string(s); +  pop_stack(); +  push_string(s); +  return; +  } +  break; +     default:    error("Cannot cast to string.\n");    }       sp[-1].type=T_STRING;    sp[-1].u.string=make_shared_string(buf);    break;    }       case T_OBJECT: