pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:1016:    *! The returned string is of the format @expr{"filename:linenumber"@}.    *!    *! If it cannot be determined where the program was defined, @expr{0@}    *! (zero) will be returned.    */   PMOD_EXPORT   PIKEFUN string program_defined(program p)    errname Program.defined;    optflags OPT_TRY_OPTIMIZE;   { -  INT32 line; +  INT_TYPE line;    struct pike_string *tmp = low_get_program_line(p, &line);       pop_n_elems(args);       if (tmp) {    push_string(tmp);    if(line >= 1)    {    push_constant_text(":");    push_int(line);
pike.git/src/builtin.cmod:1178:    *! (zero) will be returned.    *!    *! @seealso    *! @[function_object()]    */   PMOD_EXPORT   PIKEFUN string function_name(program|function func)    efun;    optflags OPT_TRY_OPTIMIZE;   { +  int f = -1; +  struct program *p = NULL; +     switch(TYPEOF(*func))    {    default:    SIMPLE_BAD_ARG_ERROR("function_name", 1, "function|program");    return; /* NOTREACHED */       case PIKE_T_PROGRAM:    { -  struct program *p=func->u.program; +  p = func->u.program;       if(p->parent)    {    int e;    p=p->parent;    /* search constants in parent for this    * program...    */       for(e = p->num_identifier_references; e--; )
pike.git/src/builtin.cmod:1223:    "Parent program info:\n",    func->u.program);    dump_program_tables(func->u.program->parent, 0);    }   #endif    }    break;    }       case PIKE_T_FUNCTION: -  if(SUBTYPEOF(*func) == FUNCTION_BUILTIN) break; -  if(!func->u.object->prog) +  if((f = SUBTYPEOF(*func)) == FUNCTION_BUILTIN) break; +  if(!(p = func->u.object->prog))    bad_arg_error("function_name", Pike_sp-args, args, 1,    "function", Pike_sp-args,    "Destructed object.\n"); -  if(func->u.object->prog == pike_trampoline_program) +  if(p == pike_trampoline_program)    {    struct pike_trampoline *t;    t=((struct pike_trampoline *)func->u.object->storage);    -  if(t->frame->current_object->prog) -  RETURN delambda(ID_FROM_INT(t->frame->current_object->prog, -  t->func)->name); +  if(t->frame->current_object->prog) { +  p = t->frame->current_object->prog; +  f = t->func;    } -  +  }    -  RETURN delambda(ID_FROM_INT(func->u.object->prog, -  SUBTYPEOF(*func))->name); + #ifdef PIKE_DEBUG +  if(f >= p->num_identifier_references) +  Pike_fatal("Function without reference.\n"); + #endif +  RETURN delambda(ID_FROM_INT(p, f)->name);    }    pop_n_elems(args);    push_int(0);   }      /*! @decl object function_object(function f)    *!    *! Return the object the function @[f] is in.    *!    *! If @[f] is a global function defined in the runtime @expr{0@}
pike.git/src/builtin.cmod:1693:    PIKEVAR array args;       /* These are cleared when filename and lineno have been initialized    * from them. */    PIKEVAR program prog flags ID_PROTECTED|ID_PRIVATE;    CVAR PIKE_OPCODE_T *pc;       /* These two are considered to be uninitialized from prog, pc and    * fun as long as lineno == -1. */    CVAR struct pike_string *filename; -  CVAR INT32 lineno; +  CVAR INT_TYPE lineno;       INIT    {    THIS->pc = NULL;    THIS->lineno = -1;    THIS->filename = NULL;    }       EXIT    gc_trivial;
pike.git/src/builtin.cmod:1827:   #endif    push_svalue(&THIS->_fun);    f_function_name(1);    push_text("(), ");    f_add(2);    } else {    free_svalue(&THIS->_fun);    SET_SVAL(THIS->_fun, PIKE_T_INT, NUMBER_DESTRUCTED, integer, 0);    push_text("destructed_function(), ");    } +  } else if (TYPEOF(THIS->_fun) == PIKE_T_PROGRAM) { +  /* FIXME: Use the master? */ +  push_text("program(), "); +  } else if (TYPEOF(THIS->_fun) == PIKE_T_STRING) { +  push_svalue(&THIS->_fun); +  push_text("(), "); +  f_add(2);    } else {    push_text("destructed_function(), ");    }       if (THIS->args) {    push_text("Args: ");    push_int(THIS->args->size);    f_add(2);    } else {    push_text("No args");
pike.git/src/builtin.cmod:2091:       SET_SVAL(res->item[size], PIKE_T_OBJECT, 0, object, o);       bf = OBJ2_BACKTRACE_FRAME(o);       if ((bf->prog = f->context->prog)) {    add_ref(bf->prog);    bf->pc = f->pc;    }    +  SET_SVAL(bf->_fun, PIKE_T_INT, NUMBER_DESTRUCTED, integer, 0); +     if (f->current_object && f->current_object->prog) { -  +  if (f->fun == FUNCTION_BUILTIN) { +  /* Unusual case. The frame is from call_c_initializers(), gc() +  * or similar. cf [bug 6156]. /grubba +  * +  * Masquerade as the program. +  * +  * FIXME: Ought to keep parent-pointers. +  */ +  SET_SVAL(bf->_fun, PIKE_T_PROGRAM, 0, +  program, f->current_object->prog); +  add_ref(f->current_object->prog); +  } else {    SET_SVAL(bf->_fun, PIKE_T_FUNCTION,    CHECK_IDREF_RANGE(f->fun, f->current_object->prog),    object, f->current_object);    add_ref(f->current_object); -  +  function = ID_FROM_INT(f->current_object->prog, f->fun);   #ifdef PIKE_DEBUG    add_ref(bf->oprog = bf->_fun.u.object->prog);   #endif -  function = ID_FROM_INT(f->current_object->prog, f->fun); -  } else { -  SET_SVAL(bf->_fun, PIKE_T_INT, NUMBER_DESTRUCTED, integer, 0); +     } -  +  }       if (f->locals) {    INT32 numargs = DO_NOT_WARN((INT32) MINIMUM(f->num_args,    stack_top - f->locals));    INT32 varargs = 0;       if(of && of->locals) {    /* f->num_args can be too large, so this is necessary for some    * reason. I don't know why. /mast */    numargs = DO_NOT_WARN((INT32)MINIMUM(f->num_args,of->locals - f->locals));
pike.git/src/builtin.cmod:4929:   GET_VAL (false)   GET_VAL (null)      /* Kludge needed for the static null objects in the oracle module. It    * ought to be fixed to use dynamic lookup of them instead. */   PMOD_EXPORT struct program *get_sql_null_prog(void)   {    return Null_program;   }    + PIKECLASS __Backtrace_Tester__ + { +  INIT { +  Pike_error("__Backtrace_Tester__\n"); +  } + } +    void init_builtin(void)   {    init_pike_list_node_blocks();    INIT   }      void exit_builtin(void)   {    if (val_module) free_object (val_module);    EXIT