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.174 2004/12/19 16:38:40 grubba Exp $ + || $Id: builtin.cmod,v 1.175 2004/12/21 20:46:09 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:78:    *! Same as sprintf("%t",x);    *!    *! @seealso    *! @[sprintf()]    */   PIKEFUN string basetype(mixed x)    efun;    optflags OPT_TRY_OPTIMIZE;   {    int t=x->type; -  if(x->type == T_OBJECT && x->u.object->prog) +  struct program *p; +  if(x->type == T_OBJECT && (p = x->u.object->prog))    { -  ptrdiff_t fun=FIND_LFUN(x->u.object->prog, LFUN__SPRINTF); +  ptrdiff_t fun = FIND_LFUN(p->inherits[x->subtype].prog, LFUN__SPRINTF);    if(fun != -1)    {    push_int('t');    f_aggregate_mapping(0); -  apply_low(x->u.object, fun, 2); +  apply_low(x->u.object, +  fun + p->inherits[x->subtype].identifier_level, 2);    if(Pike_sp[-1].type == T_STRING)    {    stack_swap();    pop_stack();    return;    } else if (UNSAFE_IS_ZERO(Pike_sp-1)) {    pop_n_elems(2);    push_constant_text("object");    return;    } else {
pike.git/src/builtin.cmod:139:    *! Same as sprintf("%c",x);    *!    *! @seealso    *! @[sprintf()]    */   PIKEFUN string int2char(int|object x)    efun;    optflags OPT_TRY_OPTIMIZE;   {    int c; -  if(x->type == T_OBJECT && x->u.object->prog) +  struct program *p; +  if(x->type == T_OBJECT && (p = x->u.object->prog))    { -  ptrdiff_t fun=FIND_LFUN(x->u.object->prog, LFUN__SPRINTF); +  ptrdiff_t fun = FIND_LFUN(p->inherits[x->subtype].prog, LFUN__SPRINTF);    if(fun != -1)    {    push_int('c');    f_aggregate_mapping(0); -  apply_low(x->u.object, fun, 2); +  apply_low(x->u.object, +  fun + p->inherits[x->subtype].identifier_level, 2);    if(Pike_sp[-1].type == T_STRING)    {    stack_swap();    pop_stack();    return;    }    Pike_error("Non-string returned from _sprintf()\n");    }    }    if(x->type != T_INT)
pike.git/src/builtin.cmod:192:    *! @[sprintf()]    */   PIKEFUN string int2hex(int|object x)    efun;    optflags OPT_TRY_OPTIMIZE;   {    INT_TYPE c;    unsigned INT_TYPE n;    int len;    struct pike_string *s; +  struct program *p;    -  if(x->type == T_OBJECT && x->u.object->prog) +  if(x->type == T_OBJECT && (p = x->u.object->prog))    { -  ptrdiff_t fun=FIND_LFUN(x->u.object->prog, LFUN__SPRINTF); +  ptrdiff_t fun = FIND_LFUN(p->inherits[x->subtype].prog, LFUN__SPRINTF);    if(fun != -1)    {    push_int('x');    f_aggregate_mapping(0); -  apply_low(x->u.object, fun, 2); +  apply_low(x->u.object, +  fun + p->inherits[x->subtype].identifier_level, 2);    if(Pike_sp[-1].type == T_STRING)    {    stack_swap();    pop_stack();    return;    }    Pike_error("Non-string returned from _sprintf()\n");    }    }    if(x->type != T_INT)
pike.git/src/builtin.cmod:797:   PIKEFUN mixed m_delete(object|mapping map, mixed index)    efun;    optflags OPT_SIDE_EFFECT;   {    /*FIXME: Should be    * type function(mapping(1=mixed:2=mixed),1:2)|    * function(object,mixed:mixed);    *    * or similar    */ +  struct program *p;    if( map->type == T_MAPPING )    {    struct svalue s;    map_delete_no_free(map->u.mapping, index, &s);    pop_n_elems(args);    *Pike_sp=s;    Pike_sp++;    dmalloc_touch_svalue(Pike_sp-1);    } -  else if (map->type == T_OBJECT && map->u.object->prog) +  else if (map->type == T_OBJECT && (p = map->u.object->prog))    { -  int id = FIND_LFUN(map->u.object->prog, LFUN__M_DELETE); +  int id = FIND_LFUN(p->inherits[map->subtype].prog, LFUN__M_DELETE);       if( id == -1 )    SIMPLE_BAD_ARG_ERROR("m_delete", 1, "object containing the _m_delete method");    -  apply_low( map->u.object, id, 1 ); +  apply_low(map->u.object, +  id + p->inherits[map->subtype].identifier_level, 1);    stack_swap();    pop_stack();    } else {    SIMPLE_BAD_ARG_ERROR("m_delete", 1, "object|mapping");    }   }      /*! @decl int get_weak_flag(array|mapping|multiset m)    *!    *! Returns the weak flag settings for @[m]. It's a combination of