vec_safe_push (MODES (moif), em->moid);
}
- /* Next step is to see if equivalent modes the any of the modes in the moif
- DIM already exist in the compiler's mode list. In that case, replace the
- DIM moif's mode with the existing mode anywhere in the moif. */
- for (MOID_T *m : MODES (moif))
- {
- MOID_T *r = a68_search_equivalent_mode (m);
- if (r != NO_MOID)
- {
- a68_replace_equivalent_mode (MODES (moif), m, r);
-
- /* Update encoded_modes to reflect the replacement. */
- for (auto entry : encoded_modes)
- {
- struct encoded_mode *em = entry.second;
- if (em->moid == m)
- em->moid = r;
- }
- }
- }
-
*errstr = NULL;
*ppos = pos;
return true;
MOIF_T *moif = TOP_MOIF (&A68_JOB);
while (moif != NO_MOIF && strcmp (NAME (moif), module) != 0)
FORWARD (moif);
+
+ /* If we got a moif, we need to make sure that it doesn't introduce new modes
+ that are equivalent to any mode in the compiler's mode list. If it does,
+ we replace the mode everywhere in the moif. */
+
+ if (moif != NO_MOIF)
+ {
+ for (MOID_T *m : MODES (moif))
+ {
+ MOID_T *r = a68_search_equivalent_mode (m);
+ if (r != NO_MOID)
+ {
+ a68_replace_equivalent_mode (MODES (moif), m, r);
+
+ /* Update extracts to reflect the replacement. */
+ for (EXTRACT_T *e : INDICANTS (moif))
+ {
+ if (EXTRACT_MODE (e) == m)
+ EXTRACT_MODE (e) = r;
+ }
+
+ for (EXTRACT_T *e : IDENTIFIERS (moif))
+ {
+ if (EXTRACT_MODE (e) == m)
+ EXTRACT_MODE (e) = r;
+ }
+
+ for (EXTRACT_T *e : OPERATORS (moif))
+ {
+ if (EXTRACT_MODE (e) == m)
+ EXTRACT_MODE (e) = r;
+ }
+ }
+ }
+ }
+
return moif;
}
if (tag != NO_TAG)
MOIF (tag) = moif;
- /* First thing to do is to extract the revelations of publicized modules in
- this moif. This leads to recursive calls of this function. */
-
- for (EXTRACT_T *e : MODULES (moif))
- extract_revelation (q, EXTRACT_SYMBOL (e), NO_TAG);
-
/* Store all the modes from the MOIF in the moid list.
The front-end depends on being able to compare any two modes by pointer
{
MOID_T *r = a68_register_extra_mode (&TOP_MOID (&A68_JOB), m);
if (r != m)
- gcc_unreachable ();
+ {
+ printf ("r: %s\n", a68_moid_to_string (r, 80, NO_NODE, false));
+ printf ("m: %s\n", a68_moid_to_string (m, 80, NO_NODE, false));
+ gcc_unreachable ();
+ }
}
}
+ /* Second thing to do is to extract the revelations of publicized modules in
+ this moif. This leads to recursive calls of this function. Note that
+ this should be done _after_ the modes get added to the global list of
+ modes so mode deduplication in a68_open_packet in the recursive
+ extract_revelation calls is properly done. */
+
+ for (EXTRACT_T *e : MODULES (moif))
+ extract_revelation (q, EXTRACT_SYMBOL (e), NO_TAG);
+
/* Store mode indicants from the MOIF in the symbol table,
and also in the moid list. */
for (EXTRACT_T *e : INDICANTS (moif))