/* UnaryExpression -- 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 unary expression which is a special form of a expression. */ public class UnaryExpression extends Expression { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(UnaryExpression.class); public enum Operator { LOGICNEG, PLUS, MINUS, LOGICCOMPLEMENT, POINTER, ADDROF, LTLGLOBALLY, LTLFINALLY, LTLNEXT } /** * The operator of this unary expression. */ Operator operator; /** * The expr of this unary expression. */ Expression expr; /** * The constructor taking initial values. * @param operator the operator of this unary expression. * @param expr the expr of this unary expression. */ public UnaryExpression(Operator operator, Expression expr) { super(); this.operator = operator; this.expr = expr; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid UnaryExpression: " + this; } /** * The constructor taking initial values. * @param type the type of this expression. * @param operator the operator of this unary expression. * @param expr the expr of this unary expression. */ public UnaryExpression(ACSLType type, Operator operator, Expression expr) { super(type); this.operator = operator; this.expr = expr; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid UnaryExpression: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("UnaryExpression").append('['); sb.append(operator); sb.append(',').append(expr); return sb.append(']').toString(); } /** * Gets the operator of this unary expression. * @return the operator of this unary expression. */ public Operator getOperator() { return operator; } /** * Gets the expr of this unary expression. * @return the expr of this unary expression. */ public Expression getExpr() { return expr; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); children.add(expr); 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(expr!=null){ expr.accept(visitor); } if(type!=null){ type.accept(visitor); } } } public Expression accept(ACSLTransformer visitor) { Expression node = visitor.transform(this); if(node != this){ return node; } Expression newexpr = null; if(expr != null){ newexpr = (Expression)expr.accept(visitor); } ACSLType newtype = null; if(type != null){ newtype = (ACSLType)type.accept(visitor); } if(expr != newexpr || type != newtype){ return new UnaryExpression(newtype, operator, newexpr); } return this; } }