Skip to content
Snippets Groups Projects

#244 CIF to CIF eliminate component definition/instantiation crashes for CompInstWrapType

Merged #244 CIF to CIF eliminate component definition/instantiation crashes for CompInstWrapType
All threads resolved!
All threads resolved!
Files
7
@@ -581,10 +581,24 @@ public class ElimComponentDefInst extends CifWalker implements CifToCifTransform
// reference a component instantiation.
refObj = ((ComponentType)childRef).getComponent();
} else if (childRef instanceof ComponentDefType) {
// Assume that 'wrap' is a component instantiation 'x1' for component definition 'X'. Then, since we are
// eliminating 'X' and 'x1', 'X' does not contain any component definitions. As such, 'childRef' can not be
// a component definition reference.
throw new RuntimeException("Invalid comp def type.");
// Assume that 'wrap' (say 'x1.C') consists of a component instantiation 'x1' for component definition 'X'
// and a reference to component definition 'C'. Then, since we are eliminating 'X' and 'x1', 'X' does no
// longer contain that component definition ('C'). As such, we won't find that definition in the
// instantiated component ('x1'). Every instantiation that has this type ('C') must have been instantiated
// already. Only component parameters (say 'p') can still have this type ('C'). Note there may be multiple
// 'via' instantiation wraps (e.g., 'r.y.x1.C'). Eventually the parameter ('p') and thus this type will get
// replaced by an actual argument. Hence, we won't have to eliminate this component definition type ('C').
EObject parent = wrap.eContainer();
while (parent instanceof CompInstWrapType) {
parent = ((CompInstWrapType)parent).eContainer();
}
Assert.check(parent instanceof ComponentParameter);
// We remove the wrap to properly indicate that the instantiation ('x1') has been removed. Otherwise we may
// get trouble when the parent wrap ('y') gets removed, as it then references a component instantiation type
// ('x1').
EMFHelper.updateParentContainment(wrap, childRef);
return;
} else if (childRef instanceof CompInstWrapType) {
// Assume that 'wrap' is a component instantiation 'x1' for component definition 'X'. Then, since we are
// eliminating 'X' and 'x1', 'X' does not contain any component instantiations. As such, 'childRef' can not
@@ -615,6 +629,9 @@ public class ElimComponentDefInst extends CifWalker implements CifToCifTransform
// This component reference can not reference a component instantiation. See above.
Component c = (Component)newRefObj;
((ComponentType)childRef).setComponent(c);
} else if (childRef instanceof ComponentDefType) {
// Already handled. See above.
throw new RuntimeException("Should never get here...");
} else if (childRef instanceof CompInstWrapType) {
// Can't happen. See above.
throw new RuntimeException("Should never get here...");
Loading