/* CastExpression -- 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 cast expression which is a special form of a expression. */ public class CastExpression extends Expression { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(CastExpression.class); /** * The casted type of this cast expression. */ ACSLType castedType; /** * The expression of this cast expression. */ Expression expression; /** * The constructor taking initial values. * @param castedType the casted type of this cast expression. * @param expression the expression of this cast expression. */ public CastExpression(ACSLType castedType, Expression expression) { super(); this.castedType = castedType; this.expression = expression; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid CastExpression: " + this; } /** * The constructor taking initial values. * @param type the type of this expression. * @param castedType the casted type of this cast expression. * @param expression the expression of this cast expression. */ public CastExpression(ACSLType type, ACSLType castedType, Expression expression) { super(type); this.castedType = castedType; this.expression = expression; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid CastExpression: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("CastExpression").append('['); sb.append(castedType); sb.append(',').append(expression); return sb.append(']').toString(); } /** * Gets the casted type of this cast expression. * @return the casted type of this cast expression. */ public ACSLType getCastedType() { return castedType; } /** * Gets the expression of this cast expression. * @return the expression of this cast expression. */ public Expression getExpression() { return expression; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); children.add(castedType); children.add(expression); 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(castedType!=null){ castedType.accept(visitor); } if(expression!=null){ expression.accept(visitor); } if(type!=null){ type.accept(visitor); } } } public Expression accept(ACSLTransformer visitor) { Expression node = visitor.transform(this); if(node != this){ return node; } ACSLType newcastedType = null; if(castedType != null){ newcastedType = (ACSLType)castedType.accept(visitor); } Expression newexpression = null; if(expression != null){ newexpression = (Expression)expression.accept(visitor); } ACSLType newtype = null; if(type != null){ newtype = (ACSLType)type.accept(visitor); } if(castedType != newcastedType || expression != newexpression || type != newtype){ return new CastExpression(newtype, newcastedType, newexpression); } return this; } }