mie: implemented array value type; restructure const value structures
there are now separate structs for all const types (int, string, etc), rather than a single mie_const union.
This commit is contained in:
@@ -51,6 +51,9 @@ static void mie_type_to_string(struct mie_type *type, char *out, size_t max)
|
||||
case MIE_TYPE_LABEL:
|
||||
snprintf(out, max, "label");
|
||||
break;
|
||||
case MIE_TYPE_ARRAY:
|
||||
snprintf(out, max, "array");
|
||||
break;
|
||||
case MIE_TYPE_SELECTOR:
|
||||
snprintf(out, max, "");
|
||||
break;
|
||||
@@ -150,23 +153,62 @@ static b_status write_operand_const(
|
||||
}
|
||||
|
||||
switch (c->c_type->t_id) {
|
||||
case MIE_TYPE_INT:
|
||||
write_string_f(converter, "#%" PRId64, c->c_v.v_int);
|
||||
case MIE_TYPE_INT: {
|
||||
struct mie_int *v = MIE_INT(c);
|
||||
write_string_f(converter, "#%" PRId64, v->i_value);
|
||||
break;
|
||||
}
|
||||
case MIE_TYPE_PTR:
|
||||
case MIE_TYPE_ID:
|
||||
write_string_f(converter, "%%%s", value->v_name.n_str);
|
||||
break;
|
||||
case MIE_TYPE_STR:
|
||||
case MIE_TYPE_ATOM:
|
||||
write_string_f(converter, "\"%s\"", c->c_v.v_str);
|
||||
case MIE_TYPE_STR: {
|
||||
struct mie_string *v = MIE_STRING(c);
|
||||
|
||||
write_string_f(converter, "\"%s\"", v->s_value);
|
||||
break;
|
||||
}
|
||||
case MIE_TYPE_ATOM: {
|
||||
struct mie_atom *v = MIE_ATOM(c);
|
||||
|
||||
write_string_f(converter, "\"%s\"", v->a_value);
|
||||
break;
|
||||
}
|
||||
case MIE_TYPE_SELECTOR: {
|
||||
struct mie_selector *v = MIE_SELECTOR(c);
|
||||
|
||||
write_string_f(converter, "\"%s\"", v->sel_value);
|
||||
break;
|
||||
}
|
||||
case MIE_TYPE_CLASS:
|
||||
write_string_f(converter, "@%s", value->v_name.n_str);
|
||||
break;
|
||||
case MIE_TYPE_SELECTOR:
|
||||
write_string_f(converter, "@%s", c->c_v.v_selector);
|
||||
case MIE_TYPE_ARRAY: {
|
||||
struct mie_array *array = MIE_ARRAY(value);
|
||||
b_list_iterator it;
|
||||
b_list_iterator_begin(array->a_values, &it);
|
||||
|
||||
write_char(converter, '{');
|
||||
while (b_list_iterator_is_valid(&it)) {
|
||||
if (it.i > 0) {
|
||||
write_char(converter, ',');
|
||||
}
|
||||
|
||||
write_string(converter, "\n ");
|
||||
|
||||
struct mie_value *child = it.item;
|
||||
write_operand_const(converter, child, F_INCLUDE_TYPE);
|
||||
|
||||
b_list_iterator_next(&it);
|
||||
}
|
||||
|
||||
if (!b_list_empty(array->a_values)) {
|
||||
write_char(converter, '\n');
|
||||
}
|
||||
|
||||
write_char(converter, '}');
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user