pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:1:   /* -*- c -*-   || 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: builtin.cmod,v 1.226 2008/11/02 19:57:58 grubba Exp $ + || $Id: builtin.cmod,v 1.227 2009/02/21 12:54:38 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin.cmod:943:    if (file) ext_store_program_line (prog, line, file);   #if 0    push_program (prog);    safe_pike_fprintf (stderr, "Creating empty program %O (%x)\n",    Pike_sp - 1, Pike_sp[-1].u.program);    Pike_sp--;   #endif    RETURN prog;   }    + /* Cut the string at the first NUL. */ + static struct pike_string *delambda(struct pike_string *str) + { +  PCHARP pcharp = MKPCHARP_STR(str); +  ptrdiff_t len = pcharp_strlen(pcharp); +  if (len == str->len) { +  /* Common case. */ +  add_ref(str); +  return str; +  } +  return make_shared_binary_pcharp(pcharp, len); + } +    /*! @decl string function_name(function f)    *!    *! Return the name of the function @[f].    *!    *! If @[f] is a global function defined in the runtime @expr{0@}    *! (zero) will be returned.    *!    *! @seealso    *! @[function_object()]    */
pike.git/src/builtin.cmod:1013:    if(func->subtype == FUNCTION_BUILTIN) break;    if(!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)    {    struct pike_trampoline *t;    t=((struct pike_trampoline *)func->u.object->storage);    -  /* FIXME: Adjust lambda names. */ -  +     if(t->frame->current_object->prog) -  REF_RETURN ID_FROM_INT(t->frame->current_object->prog, -  t->func)->name; +  RETURN delambda(ID_FROM_INT(t->frame->current_object->prog, +  t->func)->name);    }    -  /* FIXME: Adjust lambda names. */ -  -  REF_RETURN ID_FROM_INT(func->u.object->prog, func->subtype)->name; +  RETURN delambda(ID_FROM_INT(func->u.object->prog, func->subtype)->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@}