pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:13:   #include "interpret.h"   #include "language.h"   #include "error.h"   #include "pike_types.h"   #include "fsort.h"   #include "builtin_functions.h"   #include "pike_memory.h"   #include "gc.h"   #include "main.h"   #include "security.h" + #include "stuff.h"    - RCSID("$Id: array.c,v 1.53 1999/08/21 23:21:06 noring Exp $"); + RCSID("$Id: array.c,v 1.54 1999/09/16 23:56:08 hubbe Exp $");      struct array empty_array=   {    1, /* Never free */   #ifdef PIKE_SECURITY    0,   #endif    &empty_array, /* Next */    &empty_array, /* previous (circular) */    0, /* Size = 0 */
pike.git/src/array.c:1342:    return merge_array_without_order(a, b, PIKE_ARRAY_OP_AND);    }else{    return allocate_array_no_init(0,0);    }   }      int check_that_array_is_constant(struct array *a)   {    array_fix_type_field(a);    if(a->type_field & (BIT_FUNCTION | BIT_OBJECT)) +  { +  int e; +  for(e=0;e<a->size;e++) +  { +  switch(ITEM(a)[e].type) +  { +  case T_FUNCTION: +  if(ITEM(a)[e].subtype == FUNCTION_BUILTIN) continue; +  /* Fall through */ +  case T_OBJECT: +  if(ITEM(a)[e].u.object -> next == ITEM(a)[e].u.object) +  { +  /* This is a fake object used during the +  * compilation! +  */    return 0; -  +  } +  } +  } +  }    return 1;   }      node *make_node_from_array(struct array *a)   {    struct svalue s;    INT32 e;       array_fix_type_field(a); -  +  if(!a->size) +  return mkefuncallnode("aggregate",0); +     if(a->type_field == BIT_INT)    {    for(e=0; e<a->size; e++)    if(ITEM(a)[e].u.integer != 0)    break;    if(e == a->size)    {    return mkefuncallnode("allocate",mkintnode(a->size));    }    } -  +  if(!is_more_than_one_bit(a->type_field)) +  { +  e=0; +  switch(a->type_field) +  { +  case BIT_INT: +  for(e=1; e<a->size; e++) +  if(ITEM(a)[e].u.integer != ITEM(a)[0].u.integer) +  break; +  if(e==a->size && ITEM(a)[0].u.integer==0) +  return mkefuncallnode("allocate",mkintnode(a->size)); +  break; +  +  case BIT_STRING: +  case BIT_PROGRAM: +  case BIT_OBJECT: +  for(e=1; e<a->size; e++) +  if(ITEM(a)[e].u.refs != ITEM(a)[0].u.refs) +  break; +  break; +  +  case BIT_FUNCTION: +  for(e=1; e<a->size; e++) +  if(ITEM(a)[e].u.object != ITEM(a)[0].u.object || +  ITEM(a)[e].subtype != ITEM(a)[0].subtype) +  break; +  break; +  } +  if(e == a->size) +  return mkefuncallnode("allocate",mknode(F_ARG_LIST, +  mkintnode(a->size), +  mksvaluenode(ITEM(a)))); +  } +     if(check_that_array_is_constant(a))    {    s.type=T_ARRAY;    s.subtype=0;    s.u.array=a;    return mkconstantsvaluenode(&s);    }else{    node *ret=0;    for(e=0; e<a->size; e++)    ret=mknode(F_ARG_LIST,ret,mksvaluenode(ITEM(a)+e));