/* LogicFunction -- Automatically generated by TreeBuilder (2024-10-27T16:47Z) */ package de.uni_freiburg.informatik.ultimate.model.acsl.ast; import java.util.List; import java.util.ArrayList; import de.uni_freiburg.informatik.ultimate.model.acsl.ACSLNode; /** * Represents a logic function which is a special form of a logic statement. */ public class LogicFunction extends LogicStatement { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(LogicFunction.class); /** * The type of this logic function. */ ACSLType type; /** * The formula of this logic function. */ Expression formula; /** * The constructor taking initial values. * @param polyId the poly id of this logic statement. * @param type the type of this logic function. * @param formula the formula of this logic function. */ public LogicFunction(PolyIdentifier polyId, ACSLType type, Expression formula) { super(polyId); this.type = type; this.formula = formula; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid LogicFunction: " + this; } /** * The constructor taking initial values. * @param polyId the poly id of this logic statement. * @param parameters the parameters of this logic statement. * @param type the type of this logic function. * @param formula the formula of this logic function. */ public LogicFunction(PolyIdentifier polyId, Parameter[] parameters, ACSLType type, Expression formula) { super(polyId, parameters); this.type = type; this.formula = formula; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid LogicFunction: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("LogicFunction").append('['); sb.append(type); sb.append(',').append(formula); return sb.append(']').toString(); } /** * Gets the type of this logic function. * @return the type of this logic function. */ public ACSLType getType() { return type; } /** * Gets the formula of this logic function. * @return the formula of this logic function. */ public Expression getFormula() { return formula; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); children.add(type); children.add(formula); return children; } public void accept(ACSLVisitor visitor) { if (visitor.visit((LogicStatement)this)) { //visit parent types higher up if necessary } else { return; } if (visitor.visit(this)) { if(type!=null){ type.accept(visitor); } if(formula!=null){ formula.accept(visitor); } if(polyId!=null){ polyId.accept(visitor); } if(parameters!=null){ for (Parameter elem : parameters) { elem.accept(visitor); } } } } public LogicStatement accept(ACSLTransformer visitor) { LogicStatement node = visitor.transform(this); if(node != this){ return node; } ACSLType newtype = null; if(type != null){ newtype = (ACSLType)type.accept(visitor); } Expression newformula = null; if(formula != null){ newformula = (Expression)formula.accept(visitor); } PolyIdentifier newpolyId = null; if(polyId != null){ newpolyId = (PolyIdentifier)polyId.accept(visitor); } boolean isChanged=false; ArrayList tmpListnewparameters = new ArrayList<>(); if(parameters != null){ for(Parameter elem : parameters){ Parameter newparameters = (Parameter)elem.accept(visitor); isChanged = isChanged || newparameters != elem; tmpListnewparameters.add(newparameters); } } if(isChanged || type != newtype || formula != newformula || polyId != newpolyId){ return new LogicFunction(newpolyId, tmpListnewparameters.toArray(new Parameter[0]), newtype, newformula); } return this; } }