pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: program.c,v 1.778 2010/07/01 11:25:21 grubba Exp $ + || $Id$   */      #include "global.h"   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "lex.h"
pike.git/src/program.c:6455:    }    }    }    f_aggregate(n);    res = Pike_sp[-1].u.array;    add_ref(res);    pop_stack();    return(res);   }    - int program_index_no_free(struct svalue *to, struct svalue *what, -  struct svalue *ind) + int low_program_index_no_free(struct svalue *to, struct program *p, int e, +  struct object *parent, int parent_identifier)   { -  int e; -  struct pike_string *s; -  struct object *parent = NULL; -  struct svalue *sub = NULL; -  struct program *p; +     struct identifier *id; -  int parent_identifier = -1; -  -  if (what->type == T_PROGRAM) { -  p = what->u.program; -  } else if ((what->type == T_FUNCTION) && -  (what->subtype != FUNCTION_BUILTIN) && -  ((parent = what->u.object)->prog) && -  IDENTIFIER_IS_CONSTANT((id = ID_FROM_INT(parent->prog, -  what->subtype))->identifier_flags) && -  (id->func.offset != -1) && -  ((sub = &PROG_FROM_INT(parent->prog, what->subtype)->constants[id->func.offset].sval)->type == T_PROGRAM)) { -  p = sub->u.program; -  parent_identifier = what->subtype; -  } else { -  /* Not a program. */ -  return 0; -  } -  if (ind->type != T_STRING) { -  Pike_error("Can't index a program with a %s (expected string)\n", -  get_name_of_type(ind->type)); -  } -  s = ind->u.string; -  e=find_shared_string_identifier(s, p); -  if(e!=-1) -  { -  struct identifier *id; +     id=ID_FROM_INT(p, e);       if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {    struct external_variable_context loc;    struct object fake_object;    struct parent_info parent_info;    int refid;    -  if (!parent) goto fail; +  if (!parent) return 0;       parent_info.parent = parent;    parent_info.parent_identifier = parent_identifier;    fake_object.prog = p;    fake_object.refs = 1;    fake_object.next = fake_object.prev = NULL;    fake_object.storage = ((char *)&parent_info) - p->parent_info_storage;   #ifdef PIKE_DEBUG    fake_object.program_id = p->id;   #endif
pike.git/src/program.c:6528:    } while (IDENTIFIER_IS_ALIAS(id->identifier_flags));       if (fake_object.refs != 1) {    Pike_fatal("Lost track of fake object! refs: %d\n",    fake_object.refs);    }       if (loc.o != &fake_object) {    low_object_index_no_free(to, loc.o, refid);   #if 0 && defined (COMPILER_DEBUG) -  safe_pike_fprintf (stderr, "program_index_no_free1 %O->%S: %O\n", +  safe_pike_fprintf (stderr, "low_program_index_no_free1 %O->%S: %O\n",    what, s, to);   #endif    return 1;    }    }       if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) {    if (id->func.offset >= 0) {    struct program *p2 = PROG_FROM_INT(p, e);    struct svalue *val = &p2->constants[id->func.offset].sval;    assign_svalue_no_free(to, val);    } else {    /* Prototype constant. */    to->type = T_INT;    to->subtype = NUMBER_NUMBER;    to->u.integer = 0;    }   #if 0 && defined (COMPILER_DEBUG) -  safe_pike_fprintf (stderr, "program_index_no_free2 %O->%S: %O\n", +  safe_pike_fprintf (stderr, "low_program_index_no_free2 %O->%S: %O\n",    what, s, to);   #endif    return 1;    } -  +  return 0;   } -  fail: +     -  + int program_index_no_free(struct svalue *to, struct svalue *what, +  struct svalue *ind) + { +  int e; +  struct pike_string *s; +  struct object *parent = NULL; +  struct svalue *sub = NULL; +  struct program *p; +  struct identifier *id; +  int parent_identifier = -1; +  +  if (what->type == T_PROGRAM) { +  p = what->u.program; +  } else if ((what->type == T_FUNCTION) && +  (what->subtype != FUNCTION_BUILTIN) && +  ((parent = what->u.object)->prog) && +  IDENTIFIER_IS_CONSTANT((id = ID_FROM_INT(parent->prog, +  what->subtype))->identifier_flags) && +  (id->func.offset != -1) && +  ((sub = &PROG_FROM_INT(parent->prog, what->subtype)->constants[id->func.offset].sval)->type == T_PROGRAM)) { +  p = sub->u.program; +  parent_identifier = what->subtype; +  } else { +  /* Not a program. */ +  return 0; +  } +  if (ind->type != T_STRING) { +  Pike_error("Can't index a program with a %s (expected string)\n", +  get_name_of_type(ind->type)); +  } +  s = ind->u.string; +  e=find_shared_string_identifier(s, p); +  if(e!=-1) +  { +  if (low_program_index_no_free(to, p, e, parent, parent_identifier)) +  return 1; +  } +     to->type=T_INT;    to->subtype=NUMBER_UNDEFINED;    to->u.integer=0;    return 1;   }      /*    * Line number support routines, now also tells what file we are in.    *    * FIXME: Consider storing the filenames in strings (like what is now done