/* BinaryExpression -- 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 binary expression which is a special form of a expression. */ public class BinaryExpression extends Expression { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(BinaryExpression.class); public enum Operator { LOGICIFF, LOGICIMPLIES, LOGICAND, LOGICOR, LOGICXOR, COMPLT, COMPGT, COMPLEQ, COMPGEQ, COMPEQ, COMPNEQ, COMPPO, BITVECCONCAT, ARITHPLUS, ARITHMINUS, ARITHMUL, ARITHDIV, ARITHMOD, BITAND, BITOR, BITIMPLIES, BITIFF, BITXOR, BITSHIFTLEFT, BITSHIFTRIGHT, LTLUNTIL, LTLRELEASE, LTLWEAKUNTIL } /** * The operator of this binary expression. */ Operator operator; /** * The left of this binary expression. */ Expression left; /** * The right of this binary expression. */ Expression right; /** * The constructor taking initial values. * @param operator the operator of this binary expression. * @param left the left of this binary expression. * @param right the right of this binary expression. */ public BinaryExpression(Operator operator, Expression left, Expression right) { super(); this.operator = operator; this.left = left; this.right = right; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid BinaryExpression: " + this; } /** * The constructor taking initial values. * @param type the type of this expression. * @param operator the operator of this binary expression. * @param left the left of this binary expression. * @param right the right of this binary expression. */ public BinaryExpression(ACSLType type, Operator operator, Expression left, Expression right) { super(type); this.operator = operator; this.left = left; this.right = right; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid BinaryExpression: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("BinaryExpression").append('['); sb.append(operator); sb.append(',').append(left); sb.append(',').append(right); return sb.append(']').toString(); } /** * Gets the operator of this binary expression. * @return the operator of this binary expression. */ public Operator getOperator() { return operator; } /** * Gets the left of this binary expression. * @return the left of this binary expression. */ public Expression getLeft() { return left; } /** * Gets the right of this binary expression. * @return the right of this binary expression. */ public Expression getRight() { return right; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); children.add(left); children.add(right); 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(left!=null){ left.accept(visitor); } if(right!=null){ right.accept(visitor); } if(type!=null){ type.accept(visitor); } } } public Expression accept(ACSLTransformer visitor) { Expression node = visitor.transform(this); if(node != this){ return node; } Expression newleft = null; if(left != null){ newleft = (Expression)left.accept(visitor); } Expression newright = null; if(right != null){ newright = (Expression)right.accept(visitor); } ACSLType newtype = null; if(type != null){ newtype = (ACSLType)type.accept(visitor); } if(left != newleft || right != newright || type != newtype){ return new BinaryExpression(newtype, operator, newleft, newright); } return this; } }