/* IfThenElseExpression -- Automatically generated by TreeBuilder (2024-10-27T16:47Z) */ package de.uni_freiburg.informatik.ultimate.model.acsl.ast; import java.util.List; import de.uni_freiburg.informatik.ultimate.model.acsl.ACSLNode; /** * Represents a if then else expression which is a special form of a expression. */ public class IfThenElseExpression extends Expression { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(IfThenElseExpression.class); /** * The condition of this if then else expression. */ Expression condition; /** * The then part of this if then else expression. */ Expression thenPart; /** * The else part of this if then else expression. */ Expression elsePart; /** * The constructor taking initial values. * @param condition the condition of this if then else expression. * @param thenPart the then part of this if then else expression. * @param elsePart the else part of this if then else expression. */ public IfThenElseExpression(Expression condition, Expression thenPart, Expression elsePart) { super(); this.condition = condition; this.thenPart = thenPart; this.elsePart = elsePart; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid IfThenElseExpression: " + this; } /** * The constructor taking initial values. * @param type the type of this expression. * @param condition the condition of this if then else expression. * @param thenPart the then part of this if then else expression. * @param elsePart the else part of this if then else expression. */ public IfThenElseExpression(ACSLType type, Expression condition, Expression thenPart, Expression elsePart) { super(type); this.condition = condition; this.thenPart = thenPart; this.elsePart = elsePart; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid IfThenElseExpression: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("IfThenElseExpression").append('['); sb.append(condition); sb.append(',').append(thenPart); sb.append(',').append(elsePart); return sb.append(']').toString(); } /** * Gets the condition of this if then else expression. * @return the condition of this if then else expression. */ public Expression getCondition() { return condition; } /** * Gets the then part of this if then else expression. * @return the then part of this if then else expression. */ public Expression getThenPart() { return thenPart; } /** * Gets the else part of this if then else expression. * @return the else part of this if then else expression. */ public Expression getElsePart() { return elsePart; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); children.add(condition); children.add(thenPart); children.add(elsePart); return children; } public void accept(ACSLVisitor visitor) { if (visitor.visit((Expression)this)) { //visit parent types higher up if necessary } else { return; } if (visitor.visit(this)) { if(condition!=null){ condition.accept(visitor); } if(thenPart!=null){ thenPart.accept(visitor); } if(elsePart!=null){ elsePart.accept(visitor); } if(type!=null){ type.accept(visitor); } } } public Expression accept(ACSLTransformer visitor) { Expression node = visitor.transform(this); if(node != this){ return node; } Expression newcondition = null; if(condition != null){ newcondition = (Expression)condition.accept(visitor); } Expression newthenPart = null; if(thenPart != null){ newthenPart = (Expression)thenPart.accept(visitor); } Expression newelsePart = null; if(elsePart != null){ newelsePart = (Expression)elsePart.accept(visitor); } ACSLType newtype = null; if(type != null){ newtype = (ACSLType)type.accept(visitor); } if(condition != newcondition || thenPart != newthenPart || elsePart != newelsePart || type != newtype){ return new IfThenElseExpression(newtype, newcondition, newthenPart, newelsePart); } return this; } }