Skip to content

Commit

Permalink
should solve lip6#55
Browse files Browse the repository at this point in the history
but the whole maven thing is broken right now due to equinox components
badly deployed in 2022/06 eclipse simrel
(see eclipse-equinox/equinox.bundles#54 among
others)
  • Loading branch information
yanntm committed Jun 16, 2022
1 parent 3dcd6ef commit fecb910
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions fr.lip6.move.gal/src/fr/lip6/move/gal/instantiate/Simplifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ static int replaceConstantRefs(Set<Variable> constvars,
Map<ArrayPrefix, Set<Integer>> constantArrs,
List<EObject> todel, EObject t) {
int totalexpr =0;
List<VariableReference> revisit = new ArrayList<>();
for (TreeIterator<EObject> it = t.eAllContents() ; it.hasNext() ; ) {
EObject obj = it.next();

Expand Down Expand Up @@ -855,9 +856,28 @@ static int replaceConstantRefs(Set<Variable> constvars,
totalexpr++;
}
it.prune();
} else {
revisit.add(va);
}
}
}

Collections.reverse(revisit);
for (VariableReference va : revisit) {
if ( va.getIndex() instanceof Constant ) {
int index = ((Constant) va.getIndex()).getValue();
Set<Integer> cstIndexes = constantArrs.get(va.getRef());
if (cstIndexes != null && cstIndexes.contains(index) ) {
if (((ArrayPrefix) va.getRef()).getValues().size() > index) {
EcoreUtil.replace(va, EcoreUtil.copy(((ArrayPrefix) va.getRef()).getValues().get(index)));
} else {
EcoreUtil.replace(va, GF2.constant(0));
}
totalexpr++;
}
}
}

return totalexpr;
}

Expand Down

0 comments on commit fecb910

Please sign in to comment.