[m-dev.] New type_layout traversal code
Fergus Henderson
fjh at cs.mu.oz.au
Fri Feb 21 03:54:31 AEDT 1997
Oliver Hutchison, you wrote:
>
> process_float :
> /* XXX : this wont work for boxed floats! */
> return data_word;
Try
#ifdef BOXED_FLOAT
if (in_range(data_value)) {
return float_to_word(word_to_float(data_word));
}
#endif
return data_word;
> process_simple :
> /* If the argument vector is in range, copy the
> ** arguments.
> **/
> if (in_range(data_value)) {
> int i;
> Word arity = ((Word *)entry_value)[
> TYPELAYOUT_SIMPLE_ARITY_OFFSET];
> Word * type_info_vector = ((Word *) entry_value) +
> TYPELAYOUT_SIMPLE_ARGS_OFFSET;
>
> /* allocate space for new args. */
> incr_saved_hp(new_data, arity);
>
> /* copy arguments */
> for (i = 0; i < arity; i++) {
> bool allocated;
> Word * new_type_info = make_type_info(type_info,
> (Word *) type_info_vector[i], &allocated);
> field(0, new_data, i) =
> deep_copy(((Word *) data_value)[i],
> new_type_info, lower_limit,
> upper_limit);
> if (allocated) {
> free(new_type_info);
> }
> }
> /* tag this pointer */
> new_data = (Word) mkword(data_tag, new_data);
> } else {
> new_data = data_word;
> }
> return new_data;
> process_complicated :
> if (in_range(data_value)) {
> Word secondary_tag = ((Word *) data_value)[0];
> Word new_entry_value = ((Word *) entry_value)[secondary_tag +
> TYPELAYOUT_COMPLIC_ENTRY_OFFSET];
> Word new_entry_tag = tag(entry_value);
> Word new_entry_body = body(new_entry_value, new_entry_tag);
> Word new_data_value = (Word) ((Word *) data_value)[1];
> data_value = new_data_value;
> entry_value = new_entry_body;
> goto process_simple;
> } else {
> return data_word;
> }
That is a particularly awful kind of goto, because
there is no indication at the label that it is the target
of more than one goto, or that "process_simple" is in fact
used for processing complicated tags.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list