+
+/* Returns the case prototype that would result after deleting
+ all variables from D that are not in one of the
+ EXCLUDE_CLASSES and compacting the dictionary with
+ dict_compact().
+
+ The caller must unref the returned caseproto when it is no
+ longer needed. */
+struct caseproto *
+dict_get_compacted_proto (const struct dictionary *d,
+ unsigned int exclude_classes)
+{
+ struct caseproto *proto;
+ size_t i;
+
+ assert ((exclude_classes & ~((1u << DC_ORDINARY)
+ | (1u << DC_SYSTEM)
+ | (1u << DC_SCRATCH))) == 0);
+
+ proto = caseproto_create ();
+ for (i = 0; i < d->var_cnt; i++)
+ {
+ struct variable *v = d->var[i];
+ if (!(exclude_classes & (1u << var_get_dict_class (v))))
+ proto = caseproto_add_width (proto, var_get_width (v));
+ }
+ return proto;
+}