pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:8767:    case T_OBJECT:    /* if arr->cast :    try map((array)arr,fun,@extra);    try map((mapping)arr,fun,@extra);    try map((multiset)arr,fun,@extra); */       mysp=Pike_sp+3-args;       {    struct object *o = mysp[-3].u.object; -  int f = FIND_LFUN(o->prog->inherits[SUBTYPEOF(mysp[-3])].prog, +  INT16 osub = SUBTYPEOF(mysp[-3]); +  int f = FIND_LFUN(o->prog->inherits[osub].prog,    LFUN_CAST);       if( f!=-1 )    {       ref_push_string(literal_array_string);    apply_low(o, f, 1);       if (TYPEOF(Pike_sp[-1]) == T_ARRAY)    {
pike.git/src/builtin_functions.c:8810:    if (TYPEOF(Pike_sp[-1]) == T_MULTISET)    {    free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_map(args);    return;    }    pop_stack();    } -  } +        /* if arr->_sizeof && arr->`[]    array ret; ret[i]=arr[i];    ret=map(ret,fun,@extra); */    -  /* class myarray { int a0=1,a1=2; int `[](int what) { return ::`[]("a"+what); } int _sizeof() { return 2; } } -  map(myarray(),lambda(int in){ werror("in=%d\n",in); }); */ +  f = FIND_LFUN(o->prog->inherits[osub].prog, +  LFUN_INDEX) | +  FIND_LFUN(o->prog->inherits[osub].prog, +  LFUN__SIZEOF);    -  push_svalue(mysp-3); -  push_constant_text("`[]"); -  f_arrow(2); -  if (!UNSAFE_IS_ZERO(Pike_sp-1)) +  if( f != -1 )    { -  +  struct svalue tmp; +  TYPEOF(tmp) = PIKE_T_INT; +  SUBTYPEOF(tmp) = 0;    n=pike_sizeof(mysp-3);    push_array(d=allocate_array(n));    types = 0; -  stack_swap(); +     for (i=0; i<n; i++)    { -  stack_dup(); /* `[] */ -  push_int(i); -  f_call_function(2); -  stack_pop_to_no_free (ITEM(d) + i); -  types |= 1 << TYPEOF(*ITEM(d)); +  tmp.u.integer = i; +  object_index_no_free(ITEM(d)+i, o, osub, &tmp ); +  types |= 1 << TYPEOF(ITEM(d)[i]);    }    d->type_field = types; -  pop_stack(); +     free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_map(args);    return;    } -  pop_stack(); +  }       SIMPLE_BAD_ARG_ERROR("map",1,    "object that works in map");       default:    SIMPLE_BAD_ARG_ERROR("map",1,    "array|mapping|program|function|"    "multiset|string|object");    }