+ struct enum_range_to_quark *rtoq;
+
+ rtoq = g_new(struct enum_range_to_quark, 1);
+ cds_list_add(&rtoq->node, &enum_declaration->table.range_to_quark);
+ rtoq->range.start._signed = start;
+ rtoq->range.end._signed = end;
+ rtoq->quark = q;
+}
+
+static
+void enum_unsigned_insert_range_to_quark(struct declaration_enum *enum_declaration,
+ uint64_t start, uint64_t end, GQuark q)
+{
+ struct enum_range_to_quark *rtoq;
+
+ rtoq = g_new(struct enum_range_to_quark, 1);
+ cds_list_add(&rtoq->node, &enum_declaration->table.range_to_quark);
+ rtoq->range.start._unsigned = start;
+ rtoq->range.end._unsigned = end;
+ rtoq->quark = q;
+}
+
+void enum_signed_insert(struct declaration_enum *enum_declaration,
+ int64_t start, int64_t end, GQuark q)
+{
+ GArray *array;
+ struct enum_range *range;
+
+ if (start == end) {
+ enum_signed_insert_value_to_quark_set(enum_declaration, start, q);
+ } else {
+ if (start > end) {
+ uint64_t tmp;
+
+ tmp = start;
+ start = end;
+ end = tmp;
+ }
+ enum_signed_insert_range_to_quark(enum_declaration, start, end, q);
+ }
+
+ array = g_hash_table_lookup(enum_declaration->table.quark_to_range_set,
+ (gconstpointer) (unsigned long) q);
+ if (!array) {
+ array = g_array_sized_new(FALSE, TRUE,
+ sizeof(struct enum_range), 1);
+ g_hash_table_insert(enum_declaration->table.quark_to_range_set,
+ (gpointer) (unsigned long) q,
+ array);
+ }
+ g_array_set_size(array, array->len + 1);
+ range = &g_array_index(array, struct enum_range, array->len - 1);
+ range->start._signed = start;
+ range->end._signed = end;