pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:1:   /* -*- c -*- -  * $Id: builtin.cmod,v 1.74 2002/01/01 21:50:06 nilsson Exp $ +  * $Id: builtin.cmod,v 1.75 2002/01/04 13:44:16 grubba Exp $    */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "opcodes.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"
pike.git/src/builtin.cmod:1160:    for (f = i->frame_pointer; f; f = f->next) {    size++;    }       res = allocate_array_no_init(size, 0);    push_array(res);       for (f = i->frame_pointer; f && size; f = (of = f)->next) {    struct object *o = low_clone(backtrace_frame_program);    struct backtrace_frame_struct *bf; +  struct identifier *function = NULL;       call_c_initializers(o);       size--;       res->item[size].u.object = o;    res->item[size].type = PIKE_T_OBJECT;    res->item[size].subtype = 0;       bf = OBJ2_BACKTRACE_FRAME(o);
pike.git/src/builtin.cmod:1188:   #endif    );       }       if ((bf->fun.u.object = f->current_object) &&    (bf->fun.u.object->prog)) {    add_ref(bf->fun.u.object);    bf->fun.subtype = f->fun;    bf->fun.type = PIKE_T_FUNCTION; +  function = ID_FROM_INT(f->current_object->prog, f->fun);    } else {    bf->fun.u.integer = 0;    bf->fun.subtype = NUMBER_DESTRUCTED;    bf->fun.type = PIKE_T_INT;    }       if (f->locals) {    INT32 numargs = DO_NOT_WARN((INT32) MINIMUM(f->num_args,    i->stack_pointer - f->locals)); -  +  INT32 varargs = 0; +     if(of)    /* 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));       numargs = MAXIMUM(numargs, 0);    -  if (numargs) { -  bf->args = allocate_array_no_init(numargs, 0); +  /* Handle varargs... */ +  if (function && (function->identifier_flags & IDENTIFIER_VARARGS) && +  (f->locals + numargs < i->stack_pointer) && +  (f->locals[numargs].type == T_ARRAY)) { +  varargs = f->locals[numargs].u.array->size; +  } +  +  if (numargs + varargs) { +  bf->args = allocate_array_no_init(numargs + varargs, 0);    assign_svalues_no_free(bf->args->item, f->locals, numargs, BIT_MIXED); -  +  if (varargs) { +  assign_svalues_no_free(bf->args->item + numargs, +  f->locals[numargs].u.array->item, +  varargs, BIT_MIXED);    }    }    } -  +  }    /* NOTE: res has already been pushed on the stack. */   }      /*! @decl array(Pike.BacktraceFrame) backtrace()    *!    *! FIXME: This documentation is not up to date!    *!    *! Get a description of the current call stack.    *!    *! The description is returned as an array with one entry for each call