/* LoopAssigns -- Automatically generated by TreeBuilder (2024-10-27T16:47Z) */ package de.uni_freiburg.informatik.ultimate.model.acsl.ast; import java.util.List; import java.util.Arrays; import java.util.ArrayList; import de.uni_freiburg.informatik.ultimate.model.acsl.ACSLNode; /** * Represents a loop assigns which is a special form of a loop statement. */ public class LoopAssigns extends LoopStatement { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(LoopAssigns.class); /** * The locations of this loop assigns. */ Expression[] locations; /** * The constructor taking initial values. * @param locations the locations of this loop assigns. */ public LoopAssigns(Expression[] locations) { super(); this.locations = locations; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid LoopAssigns: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("LoopAssigns").append('['); if (locations == null) { sb.append("null"); } else { sb.append('['); for(int i1 = 0; i1 < locations.length; i1++) { if (i1 > 0) sb.append(','); sb.append(locations[i1]); } sb.append(']'); } return sb.append(']').toString(); } /** * Gets the locations of this loop assigns. * @return the locations of this loop assigns. */ public Expression[] getLocations() { return locations; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); if(locations!=null){ children.addAll(Arrays.asList(locations)); } return children; } public void accept(ACSLVisitor visitor) { if (visitor.visit((LoopStatement)this)) { //visit parent types higher up if necessary } else { return; } if (visitor.visit(this)) { if(locations!=null){ for (Expression elem : locations) { elem.accept(visitor); } } } } public LoopStatement accept(ACSLTransformer visitor) { LoopStatement node = visitor.transform(this); if(node != this){ return node; } boolean isChanged=false; ArrayList tmpListnewlocations = new ArrayList<>(); if(locations != null){ for(Expression elem : locations){ Expression newlocations = (Expression)elem.accept(visitor); isChanged = isChanged || newlocations != elem; tmpListnewlocations.add(newlocations); } } if(isChanged){ return new LoopAssigns(tmpListnewlocations.toArray(new Expression[0])); } return this; } }