- if (const Type *TheTy = D->castType()) {
- SC_DEBUG(" Inserted type: " << TheTy->getDescription() << endl);
+ if (const Type *TheTy = dyn_cast<const Type>(D)) {
+
+ // Insert the current type before any subtypes. This is important because
+ // recursive types elements are inserted in a bottom up order. Changing
+ // this here can break things. For example:
+ //
+ // global { \2 * } { { \2 }* null }
+ //
+ int ResultSlot;
+ if ((ResultSlot = getValSlot(TheTy)) == -1) {
+ ResultSlot = doInsertVal(TheTy);
+ SC_DEBUG(" Inserted type: " << TheTy->getDescription() << " slot=" <<
+ ResultSlot << endl);
+ }