Branch: Tag:

2011-10-28

2011-10-28 13:04:55 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Atomic megapatch: Use svalue accessor macros everywhere.

1644:   void debug_describe_svalue(struct svalue *s)   {    fprintf(stderr,"Svalue at %p is:\n",s); -  switch(s->type) +  switch(TYPEOF(*s))    {    case T_INT:    fprintf(stderr," %"PRINTPIKEINT"d (subtype %d)\n",s->u.integer, -  s->subtype); +  SUBTYPEOF(*s));    return;       case T_FLOAT:
1656:    return;       case T_FUNCTION: -  if(s->subtype == FUNCTION_BUILTIN) +  if(SUBTYPEOF(*s) == FUNCTION_BUILTIN)    {    fprintf(stderr," Builtin function: %s\n",s->u.efun->name->str);    }else{
1666:    if(p)    {    fprintf(stderr," Function in destructed object: %s\n", -  ID_FROM_INT(p,s->subtype)->name->str); +  ID_FROM_INT(p, SUBTYPEOF(*s))->name->str);    }else{    fprintf(stderr," Function in destructed object.\n");    }    }else{    fprintf(stderr," Function name: %s\n", -  ID_FROM_INT(s->u.object->prog,s->subtype)->name->str); +  ID_FROM_INT(s->u.object->prog, SUBTYPEOF(*s))->name->str);    }    }    } -  describe_something(s->u.refs,s->type,0,1,0,0); +  describe_something(s->u.refs, TYPEOF(*s), 0, 1, 0, 0);   }      void gc_watch(void *a)
4804:       object_index_no_free2 (&val, o, 0, &pike_cycle_depth_str);    -  if (val.type != T_INT) { +  if (TYPEOF(val) != T_INT) {    int i = find_shared_string_identifier (pike_cycle_depth_str.u.string, p);    INT32 line;    struct pike_string *file = get_identifier_line (p, i, &line);
4816:    return -1;    }    -  if (val.subtype == NUMBER_UNDEFINED) +  if (SUBTYPEOF(val) == NUMBER_UNDEFINED)    return -1;       if (val.u.integer > (unsigned INT16) -1)
5380:    mc_block_pike_cycle_depth = 0;    mc_block_strings = 0;    -  if (Pike_sp[-args].type == T_MAPPING) { +  if (TYPEOF(Pike_sp[-args]) == T_MAPPING) {    struct mapping *opts = Pike_sp[-args].u.mapping;    struct pike_string *ind;    struct svalue *val;       MAKE_CONST_STRING (ind, "lookahead");    if ((val = low_mapping_string_lookup (opts, ind))) { -  if (val->type != T_INT) +  if (TYPEOF(*val) != T_INT)    SIMPLE_ARG_ERROR ("count_memory", 1,    "\"lookahead\" must be an integer.");    mc_lookahead =
5415:       MAKE_CONST_STRING (ind, "block_strings");    if ((val = low_mapping_string_lookup (opts, ind))) { -  if (val->type != T_INT) +  if (TYPEOF(*val) != T_INT)    SIMPLE_ARG_ERROR ("count_memory", 1,    "\"block_strings\" must be an integer.");    mc_block_strings = val->u.integer > 0 ? 1 : val->u.integer < 0 ? -1 : 0;
5439:    }       else { -  if (Pike_sp[-args].type != T_INT) +  if (TYPEOF(Pike_sp[-args]) != T_INT)    SIMPLE_ARG_TYPE_ERROR ("count_memory", 1, "int|mapping(string:int)");    mc_lookahead =    Pike_sp[-args].u.integer > (unsigned INT16) -1 ? (unsigned INT16) -1 :
5449:       init_mc_marker_hash();    -  if (pike_cycle_depth_str.type == PIKE_T_FREE) { -  pike_cycle_depth_str.type = T_STRING; +  if (TYPEOF(pike_cycle_depth_str) == PIKE_T_FREE) { +  SET_SVAL_TYPE(pike_cycle_depth_str, T_STRING);    MAKE_CONST_STRING (pike_cycle_depth_str.u.string, "pike_cycle_depth");    }   
5476:    for (i = -args + 1; i < 0; i++) {    struct svalue *s = Pike_sp + i;    -  if (s->type == T_INT) +  if (TYPEOF(*s) == T_INT)    continue;    -  else if (s->type > MAX_REF_TYPE) { +  else if (TYPEOF(*s) > MAX_REF_TYPE) {    exit_mc_marker_hash();    free (mc_work_queue + 1);    mc_work_queue = NULL;
5489:    }       else { -  if (s->type == T_FUNCTION) { +  if (TYPEOF(*s) == T_FUNCTION) {    struct svalue s2;    if (!(s2.u.program = program_from_function (s))) {    exit_mc_marker_hash();
5500:    "array|multiset|mapping|object|program|string|type|int");    }    add_ref (s2.u.program); -  s2.type = T_PROGRAM; +  SET_SVAL_TYPE(s2, T_PROGRAM);    free_svalue (s);    move_svalue (s, &s2);    }
5511:       else {    struct mc_marker *m = -  my_make_mc_marker (s->u.ptr, visit_fn_from_type[s->type], NULL); +  my_make_mc_marker (s->u.ptr, visit_fn_from_type[TYPEOF(*s)], NULL);    m->flags |= MC_FLAG_INTERNAL; -  if (!mc_block_pike_cycle_depth && s->type == T_OBJECT) { +  if (!mc_block_pike_cycle_depth && TYPEOF(*s) == T_OBJECT) {    int cycle_depth = mc_cycle_depth_from_obj (s->u.object); -  if (throw_value.type != PIKE_T_FREE) { +  if (TYPEOF(throw_value) != PIKE_T_FREE) {    exit_mc_marker_hash();    free (mc_work_queue + 1);    mc_work_queue = NULL;
5594:    if (type <= MAX_TYPE) {    count_internal++;    if (collect_internal) { -  Pike_sp->type = type; -  Pike_sp->subtype = 0; -  Pike_sp->u.ptr = mc_ref_from->thing; +  SET_SVAL(*Pike_sp, type, 0, ptr, mc_ref_from->thing);    add_ref ((struct ref_dummy *) mc_ref_from->thing);    dmalloc_touch_svalue (Pike_sp);    Pike_sp++;
5640:    }    }    -  if (throw_value.type != PIKE_T_FREE) { +  if (TYPEOF(throw_value) != PIKE_T_FREE) {    exit_mc_marker_hash();    free (mc_work_queue + 1);    mc_work_queue = NULL;
5798:    mapping_string_insert (Pike_sp[-args].u.mapping, ind, Pike_sp - 1);    }    -  if (Pike_sp[-args].type == T_MAPPING) { +  if (TYPEOF(Pike_sp[-args]) == T_MAPPING) {    struct mapping *opts = Pike_sp[-args].u.mapping;    struct pike_string *ind;    struct svalue *val;
5835:    assert (!(m->flags & MC_FLAG_INTERNAL));    assert (m->flags & MC_FLAG_LA_VISITED);    if (type <= MAX_TYPE) { -  Pike_sp->type = type; -  Pike_sp->subtype = 0; -  Pike_sp->u.ptr = m->thing; +  SET_SVAL(*Pike_sp, type, 0, ptr, m->thing);    add_ref ((struct ref_dummy *) m->thing);    dmalloc_touch_svalue (Pike_sp);    Pike_sp++;
5863:    assert (!(m->flags & MC_FLAG_INTERNAL));    assert (m->flags & MC_FLAG_LA_VISITED);    if (type <= MAX_TYPE) { -  Pike_sp->type = type; -  Pike_sp->subtype = 0; -  Pike_sp->u.ptr = m->thing; +  SET_SVAL(*Pike_sp, type, 0, ptr, m->thing);    add_ref ((struct ref_dummy *) m->thing);    dmalloc_touch_svalue (Pike_sp);    Pike_sp++;