pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:8822:    /* 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); }); */       push_svalue(mysp-3);    push_constant_text("`[]");    f_arrow(2); -  push_svalue(mysp-3); -  push_constant_text("_sizeof"); -  f_arrow(2); -  if (!UNSAFE_IS_ZERO(Pike_sp-2)&&!UNSAFE_IS_ZERO(Pike_sp-1)) +  if (!UNSAFE_IS_ZERO(Pike_sp-1))    { -  f_call_function(1); -  if (TYPEOF(Pike_sp[-1]) != T_INT) -  SIMPLE_BAD_ARG_ERROR("map", 1, -  "object sizeof() returning integer"); -  n=Pike_sp[-1].u.integer; -  pop_stack(); +  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));    }    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(); -  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");    }