pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.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: interpret.c,v 1.374 2006/03/15 09:03:38 grubba Exp $ + || $Id: interpret.c,v 1.375 2006/03/17 17:55:45 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "object.h"   #include "program.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "pike_error.h"
pike.git/src/interpret.c:2380:    if (use_dummy_reference) {    Pike_compiler->new_program->num_identifier_references--;    o->prog->flags = p_flags;    }       POP_PIKE_FRAME();       return ret;   }    - PMOD_EXPORT void safe_apply_low2(struct object *o,int fun,int args, int handle_errors) + PMOD_EXPORT void safe_apply_low2(struct object *o, int fun, int args, +  char *fun_name)   {    JMP_BUF recovery;       free_svalue(& throw_value);    throw_value.type=T_INT;    if(SETJMP_SP(recovery, args))    {    if(handle_errors) call_handle_error();    push_int(0);    }else{ -  +  if (fun >= 0) {    apply_low(o,fun,args); -  +  } else if (handle_errors) { +  Pike_error("Cannot call unknown function \"%s\".\n", handle_errors); +  } else { +  pop_n_elems(args); +  push_int(0);    } -  +  }    UNSETJMP(recovery);   }    - PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args) + PMOD_EXPORT void safe_apply_low(struct object *o, int fun, int args)   { -  safe_apply_low2(o, fun, args, 1); +  safe_apply_low2(o, fun, args, "Unknown function.");   }    - PMOD_EXPORT void safe_apply(struct object *o, const char *fun ,INT32 args) + PMOD_EXPORT void safe_apply(struct object *o, const char *fun, INT32 args)   {    int id;   #ifdef PIKE_DEBUG    if(!o->prog) Pike_fatal("Apply safe on destructed object.\n");   #endif    id = find_identifier(fun, o->prog); -  if (id >= 0) -  safe_apply_low2(o, id, args, 1); -  else { -  char buf[4096]; -  /* FIXME: Ought to use string_buffer_vsprintf(). */ -  SNPRINTF(buf, sizeof (buf), "Cannot call unknown function \"%s\".\n", fun); -  push_error (buf); -  free_svalue (&throw_value); -  move_svalue (&throw_value, --Pike_sp); -  call_handle_error(); -  push_int (0); +  safe_apply_low2(o, id, args, fun);   } - } +       /* Returns nonzero if the function was called in some handler. */   PMOD_EXPORT int low_unsafe_apply_handler(const char *fun,    struct object *handler,    struct object *compat,    INT32 args)   {    int i;   #if 0    fprintf(stderr, "low_unsafe_apply_handler(\"%s\", 0x%08p, 0x%08p, %d)\n",
pike.git/src/interpret.c:2464:    struct object *compat,    INT32 args)   {    int i;   #if 0    fprintf(stderr, "low_safe_apply_handler(\"%s\", 0x%08p, 0x%08p, %d)\n",    fun, handler, compat, args);   #endif /* 0 */    if (handler && handler->prog &&    (i = find_identifier(fun, handler->prog)) != -1) { -  safe_apply_low2(handler, i, args, 1); +  safe_apply_low2(handler, i, args, fun);    } else if (compat && compat->prog &&    (i = find_identifier(fun, compat->prog)) != -1) { -  safe_apply_low2(compat, i, args, 1); +  safe_apply_low2(compat, i, args, fun);    } else {    struct object *master_obj = master();    if ((i = find_identifier(fun, master_obj->prog)) != -1) -  safe_apply_low2(master_obj, i, args, 1); +  safe_apply_low2(master_obj, i, args, fun);    else {    pop_n_elems(args);    push_undefined();    }    }   }      /* NOTE: Returns 1 if result on stack, 0 otherwise. */   PMOD_EXPORT int safe_apply_handler(const char *fun,    struct object *handler,