Skip to content
Snippets Groups Projects

reordering of components is allowed

Merged Johannes Mey requested to merge component-reordering into master
6 files
+ 41
10
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -62,12 +62,6 @@ aspect ComponentAnalysis {
eq Program.getChild().lookupComponent(TypeDecl td, String name)
= lookupComponentSyn(td, name);
syn Component Program.lookupComponentSyn(TypeDecl td, String name) {
// Check super type first to find duplicates (shadowing is not allowed)
if (td.hasSuper() && td.getSuper().decl() != null) {
Component c = lookupComponentSyn(td.getSuper().decl(), name);
if (c != null) return c;
}
for (Component c: td.getComponents()) {
if (c.name().equals(name)) {
return c;
@@ -84,6 +78,36 @@ aspect ComponentAnalysis {
return null;
}
syn boolean Component.isInvalidRedefinition() {
if (toTypeDecl() == null) return false;
TypeDecl td = toTypeDecl();
while (td.hasSuper() && td.getSuper().decl() != null) {
td = td.getSuper().decl();
Component c = lookupComponent(td, getID());
if (c != null && isTargetOfDirectedRelation()) return true;
if (c != null && !this.isEqual(c)) return true;
}
return false;
}
syn boolean Component.isEqual(Component c) = this.getClass() == c.getClass() && getTypeUse().isEqual(c.getTypeUse());
syn boolean TypeUse.isEqual(TypeUse u);
eq SimpleTypeUse.isEqual(TypeUse u) = u instanceof SimpleTypeUse && getID().equals(u.getID());
eq ParameterizedTypeUse.isEqual(TypeUse u) {
if (!getID().equals(u.getID())) return false;
if (!(u instanceof ParameterizedTypeUse)) return false;
ParameterizedTypeUse pu = (ParameterizedTypeUse) u;
if (getNumTypeUse() != pu.getNumTypeUse()) return false;
for (int i = 0; i < getNumTypeUse(); i++) {
if (!getTypeUse(i).isEqual(pu.getTypeUse(i))) return false;
}
return true;
}
syn RelationComponent RelationComponent.lookup(TypeDecl td, String name)
= !isTargetOfDirectedRelation() && toTypeDecl() == td && name().equals(name)
? this
Loading