pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.c:352:    * multiset[index] : { multiset, index }    * object[index] : { object, index } (external object indexing)    * local variable : { svalue pointer (T_SVALUE_PTR), nothing (T_VOID) }    * global variable : { object, identifier index (T_OBJ_INDEX) } (internal object indexing)    * lvalue array: { T_ARRAY_LVALUE, array with lvalue pairs }    */      void lvalue_to_svalue_no_free(struct svalue *to,struct svalue *lval)   {   #ifdef PIKE_SECURITY -  if(lval->type <= MAX_COMPLEX) +  if(TYPEOF(*lval) <= MAX_COMPLEX)    if(!CHECK_DATA_SECURITY(lval->u.array, SECURITY_BIT_INDEX))    Pike_error("Index permission denied.\n");   #endif -  switch(lval->type) +  switch(TYPEOF(*lval))    {    case T_ARRAY_LVALUE:    {    INT32 e;    struct array *a;    TYPE_FIELD types = 0;    ONERROR err;    a=allocate_array(lval[1].u.array->size>>1);    SET_ONERROR(err, do_free_array, a);    for(e=0;e<a->size;e++) {    lvalue_to_svalue_no_free(ITEM(a)+e, ITEM(lval[1].u.array)+(e<<1)); -  types |= 1 << ITEM(a)[e].type; +  types |= 1 << TYPEOF(ITEM(a)[e]);    }    a->type_field = types; -  to->type = T_ARRAY; -  to->u.array=a; +  SET_SVAL(*to, T_ARRAY, 0, array, a);    UNSET_ONERROR(err);    break;    }       case T_SVALUE_PTR:    dmalloc_touch_svalue(lval->u.lval);    assign_svalue_no_free(to, lval->u.lval);    break;       case T_OBJECT:    /* FIXME: Object subtypes! */ -  if (lval[1].type == T_OBJ_INDEX) +  if (TYPEOF(lval[1]) == T_OBJ_INDEX)    low_object_index_no_free (to, lval->u.object, lval[1].u.identifier);    else -  object_index_no_free(to, lval->u.object, lval->subtype, lval+1); +  object_index_no_free(to, lval->u.object, SUBTYPEOF(*lval), lval+1);    break;       case T_ARRAY:    simple_array_index_no_free(to, lval->u.array, lval+1);    break;       case T_MAPPING:    mapping_index_no_free(to, lval->u.mapping, lval+1);    break;       case T_MULTISET: -  to->type=T_INT; +     if(multiset_member(lval->u.multiset,lval+1))    { -  to->u.integer=1; -  to->subtype=NUMBER_NUMBER; +  SET_SVAL(*to, T_INT, NUMBER_NUMBER, integer, 1);    }else{ -  to->u.integer=0; -  to->subtype=NUMBER_UNDEFINED; +  SET_SVAL(*to, T_INT, NUMBER_UNDEFINED, integer, 0);    }    break;       default:    if(SAFE_IS_ZERO(lval))    index_error(0,0,0,lval,lval+1,"Indexing the NULL value.\n");    else    index_error(0,0,0,lval,lval+1,"Indexing a basic type.\n");    }   }      PMOD_EXPORT void assign_lvalue(struct svalue *lval,struct svalue *from)   {   #ifdef PIKE_SECURITY -  if(lval->type <= MAX_COMPLEX) +  if(TYPEOF(*lval) <= MAX_COMPLEX)    if(!CHECK_DATA_SECURITY(lval->u.array, SECURITY_BIT_SET_INDEX))    Pike_error("Assign index permission denied.\n");   #endif    -  switch(lval->type) +  switch(TYPEOF(*lval))    {    case T_ARRAY_LVALUE:    {    INT32 e; -  if(from->type != T_ARRAY) +  if(TYPEOF(*from) != T_ARRAY)    Pike_error("Trying to assign combined lvalue from non-array.\n");       if(from->u.array->size < (lval[1].u.array->size>>1))    Pike_error("Not enough values for multiple assign.\n");       if(from->u.array->size > (lval[1].u.array->size>>1))    Pike_error("Too many values for multiple assign.\n");       for(e=0;e<from->u.array->size;e++)    assign_lvalue(lval[1].u.array->item+(e<<1),from->u.array->item+e);
pike.git/src/interpret.c:453:    break;       case T_SVALUE_PTR:    dmalloc_touch_svalue(from);    dmalloc_touch_svalue(lval->u.lval);    assign_svalue(lval->u.lval,from);    break;       case T_OBJECT:    /* FIXME: Object subtypes! */ -  if (lval[1].type == T_OBJ_INDEX) +  if (TYPEOF(lval[1]) == T_OBJ_INDEX)    object_low_set_index (lval->u.object, lval[1].u.identifier, from);    else -  object_set_index(lval->u.object, lval->subtype, lval+1, from); +  object_set_index(lval->u.object, SUBTYPEOF(*lval), lval+1, from);    break;       case T_ARRAY:    simple_set_index(lval->u.array, lval+1, from);    break;       case T_MAPPING:    mapping_insert(lval->u.mapping, lval+1, from);    break;   
pike.git/src/interpret.c:491:      /* On error callback. lvalue is followed by value to assign. */   static void o_assign_lvalue(struct svalue *lvalue)   {    assign_lvalue(lvalue, lvalue+2);   }      union anything *get_pointer_if_this_type(struct svalue *lval, TYPE_T t)   {   #ifdef PIKE_SECURITY -  if(lval->type <= MAX_COMPLEX) +  if(TYPEOF(*lval) <= MAX_COMPLEX)    if(!CHECK_DATA_SECURITY(lval->u.array, SECURITY_BIT_SET_INDEX))    Pike_error("Assign index permission denied.\n");   #endif    -  switch(lval->type) +  switch(TYPEOF(*lval))    {    case T_ARRAY_LVALUE:    return 0;       case T_SVALUE_PTR:    dmalloc_touch_svalue(lval->u.lval); -  if(lval->u.lval->type == t) return & ( lval->u.lval->u ); +  if(TYPEOF(*(lval->u.lval)) == t) return & ( lval->u.lval->u );    return 0;       case T_OBJECT:    /* FIXME: What about object subtypes? */ -  return object_get_item_ptr(lval->u.object, lval->subtype, lval+1, t); +  return object_get_item_ptr(lval->u.object, SUBTYPEOF(*lval), lval+1, t);       case T_ARRAY:    return array_get_item_ptr(lval->u.array,lval+1,t);       case T_MAPPING:    return mapping_get_item_ptr(lval->u.mapping,lval+1,t);       case T_MULTISET: return 0;       default:
pike.git/src/interpret.c:924: Inside #if defined(_REENTRANT)
   backlog[backlogp].mark_stack = Pike_mark_sp - Pike_interpreter.mark_stack;   #ifdef _REENTRANT    backlog[backlogp].thread_state=Pike_interpreter.thread_state;   #endif      #ifdef _REENTRANT    CHECK_INTERPRETER_LOCK();    if(d_flag>1) DEBUG_CHECK_THREAD();   #endif    -  Pike_sp[0].type=99; /* an invalid type */ -  Pike_sp[1].type=99; -  Pike_sp[2].type=99; -  Pike_sp[3].type=99; +  SET_SVAL_TYPE(Pike_sp[0], 99); /* an invalid type */ +  SET_SVAL_TYPE(Pike_sp[1], 99); +  SET_SVAL_TYPE(Pike_sp[2], 99); +  SET_SVAL_TYPE(Pike_sp[3], 99);       if(Pike_sp<Pike_interpreter.evaluator_stack ||    Pike_mark_sp < Pike_interpreter.mark_stack || Pike_fp->locals>Pike_sp)    Pike_fatal("Stack error (generic) sp=%p/%p mark_sp=%p/%p locals=%p.\n",    Pike_sp,    Pike_interpreter.evaluator_stack,    Pike_mark_sp,    Pike_interpreter.mark_stack,    Pike_fp->locals);   
pike.git/src/interpret.c:1982:    if(!args)    PIKE_ERROR("`()", "Too few arguments (apply stack).\n", Pike_sp, 0);    args--;    arg1=(void *)(Pike_sp-args-1);       case APPLY_SVALUE:    case APPLY_SVALUE_STRICT:    apply_svalue:    {    struct svalue *s=(struct svalue *)arg1; -  switch(s->type) +  switch(TYPEOF(*s))    {    case T_INT:    if (!s->u.integer) {    PIKE_ERROR("0", "Attempt to call the NULL-value\n", Pike_sp, args);    } else {    Pike_error("Attempt to call the value %"PRINTPIKEINT"d\n",    s->u.integer);    }       case T_STRING:    if (s->u.string->len > 20) {    Pike_error("Attempt to call the string \"%20S\"...\n", s->u.string);    } else {    Pike_error("Attempt to call the string \"%S\"\n", s->u.string);    }    case T_MAPPING:    Pike_error("Attempt to call a mapping\n");    default:    Pike_error("Call to non-function value type:%s.\n", -  get_name_of_type(s->type)); +  get_name_of_type(TYPEOF(*s)));       case T_FUNCTION: -  if(s->subtype == FUNCTION_BUILTIN) +  if(SUBTYPEOF(*s) == FUNCTION_BUILTIN)    {   #ifdef PIKE_DEBUG    struct svalue *expected_stack = Pike_sp-args;   #endif    if(Pike_interpreter.trace_level>1)    {    dynamic_buffer save_buf;    init_buf(&save_buf);    if (s->u.efun->name->size_shift)    my_strcat ("[widestring function name]");
pike.git/src/interpret.c:2063: Inside #if defined(PIKE_DEBUG)
   Pike_fatal("Void function returned with a value on the stack: %S %d\n",    s->u.efun->name, s->u.efun->may_return_void);    }   #endif       break;    }else{    type=APPLY_SVALUE;    o=s->u.object;    if(o->prog == pike_trampoline_program && -  s->subtype == QUICK_FIND_LFUN(pike_trampoline_program, LFUN_CALL)) +  SUBTYPEOF(*s) == QUICK_FIND_LFUN(pike_trampoline_program, LFUN_CALL))    {    fun=((struct pike_trampoline *)(o->storage))->func;    scope=((struct pike_trampoline *)(o->storage))->frame;    o=scope->current_object;    goto apply_low_with_scope;    } -  fun=s->subtype; +  fun = SUBTYPEOF(*s);    goto apply_low;    }    break;       case T_ARRAY:    if(Pike_interpreter.trace_level)    {    dynamic_buffer save_buf;    init_buf(&save_buf);    safe_describe_svalue(s,0,0);
pike.git/src/interpret.c:2555:    }    else {    dynamic_buffer save_buf;    char *s;    fprintf (stderr, "There's no master to handle the error. Dumping it raw:\n");    init_buf(&save_buf);    safe_describe_svalue (Pike_sp - 1, 0, 0);    s=simple_free_buf(&save_buf);    fprintf(stderr,"%s\n",s);    free(s); -  if (Pike_sp[-1].type == PIKE_T_OBJECT && Pike_sp[-1].u.object->prog) { +  if (TYPEOF(Pike_sp[-1]) == PIKE_T_OBJECT && Pike_sp[-1].u.object->prog) {    int fun = find_identifier("backtrace", Pike_sp[-1].u.object->prog);    if (fun != -1) {    fprintf(stderr, "Attempting to extract the backtrace.\n");    safe_apply_low2(Pike_sp[-1].u.object, fun, 0, 0);    init_buf(&save_buf);    safe_describe_svalue(Pike_sp - 1, 0, 0);    pop_stack();    s=simple_free_buf(&save_buf);    fprintf(stderr,"%s\n",s);    free(s);
pike.git/src/interpret.c:2812:    fun, handler, compat, args);   #endif /* 0 */       free_svalue(& throw_value);    mark_free_svalue (&throw_value);       if (SETJMP_SP(recovery, args)) {    ret = 0;    } else {    if (low_unsafe_apply_handler (fun, handler, compat, args) && -  rettypes && !((1 << Pike_sp[-1].type) & rettypes)) { +  rettypes && !((1 << TYPEOF(Pike_sp[-1])) & rettypes)) {    if ((rettypes & BIT_ZERO) && SAFE_IS_ZERO (Pike_sp - 1)) {    pop_stack();    push_int(0);    }    else {    Pike_error("Invalid return value from %s: %O\n",    fun, Pike_sp-1);    }    }   
pike.git/src/interpret.c:2868:    int id = find_identifier(fun, o->prog);    if (id >= 0)    apply_low(o, id, args);    else    Pike_error ("Cannot call unknown function \"%s\".\n", fun);   }         PMOD_EXPORT void apply_svalue(struct svalue *s, INT32 args)   { -  if(s->type==T_INT) +  if(TYPEOF(*s) == T_INT)    {    pop_n_elems(args);    push_int(0);    }else{    ptrdiff_t expected_stack=Pike_sp-args+1 - Pike_interpreter.evaluator_stack;       strict_apply_svalue(s,args);    if(Pike_sp > (expected_stack + Pike_interpreter.evaluator_stack))    {    pop_n_elems(Pike_sp-(expected_stack + Pike_interpreter.evaluator_stack));
pike.git/src/interpret.c:2948: Inside #if defined(PIKE_DEBUG)
   PTRDIFF_T_TO_LONG(Pike_stack_size));       if(Pike_mark_sp > &(Pike_interpreter.mark_stack[Pike_stack_size]))    Pike_fatal("Mark stack overflow.\n");       if(Pike_mark_sp < Pike_interpreter.mark_stack)    Pike_fatal("Mark stack underflow.\n");       for(s=Pike_interpreter.evaluator_stack;s<Pike_sp;s++) {    /* NOTE: Freed svalues are allowed on the stack. */ -  if (s->type != PIKE_T_FREE) check_svalue(s); +  if (TYPEOF(*s) != PIKE_T_FREE) check_svalue(s);    }       s=Pike_interpreter.evaluator_stack;    for(m=Pike_interpreter.mark_stack;m<Pike_mark_sp;m++)    {    if(*m < s)    Pike_fatal("Mark stack failure.\n");       s=*m;    }
pike.git/src/interpret.c:3078:    args=f->num_args;    args = DO_NOT_WARN((INT32) MINIMUM(f->num_args, Pike_sp - f->locals));    if(of)    args = DO_NOT_WARN((INT32)MINIMUM(f->num_args,of->locals - f->locals));    args=MAXIMUM(args,0);    }       for (i = 0; i < args; i++) {    struct svalue *arg = f->locals + i;    -  switch (arg->type) { +  switch (TYPEOF(*arg)) {    case T_INT:    fprintf (stderr, "%ld", (long) arg->u.integer);    break;       case T_TYPE:    /* FIXME: */    fputs("type-value", stderr);    break;       case T_STRING: {
pike.git/src/interpret.c:3151:    }    }    fputc ('"', stderr);    if (i < arg->u.string->len)    fprintf (stderr, "+[%ld]", (long) (arg->u.string->len - i));    break;    }       case T_FUNCTION:    /* FIXME: Wide string identifiers. */ -  if(arg->subtype == FUNCTION_BUILTIN) +  if(SUBTYPEOF(*arg) == FUNCTION_BUILTIN)    fputs (arg->u.efun->name->str, stderr);    else if(arg->u.object->prog) -  fputs (safe_idname_from_int(arg->u.object->prog,arg->subtype), stderr); +  fputs (safe_idname_from_int(arg->u.object->prog, +  SUBTYPEOF(*arg)), stderr);    else    fputc ('0', stderr);    break;       case T_OBJECT: {    struct program *p = arg->u.object->prog;    if (p && p->num_linenumbers) {    file = low_get_program_line_plain (p, &line, 0);    fprintf (stderr, "object(%s:%d)", file, line);    }
pike.git/src/interpret.c:3198:       case T_MULTISET:    fprintf (stderr, "multiset[%ld]", (long) multiset_sizeof (arg->u.multiset));    break;       case T_MAPPING:    fprintf (stderr, "mapping[%ld]", (long) m_sizeof (arg->u.mapping));    break;       default: -  fprintf (stderr, "<Unknown %d>", arg->type); +  fprintf (stderr, "<Unknown %d>", TYPEOF(*arg));    }       if (i < args - 1) fputs (", ", stderr);    }    fputs (")\n", stderr);    }    else    fputs ("frame with no references\n", stderr);   }