/* FunctionApplication -- Automatically generated by TreeBuilder (2024-10-27T16:47Z) */ package de.uni_freiburg.informatik.ultimate.model.acsl.ast; import java.util.List; import java.util.Arrays; import java.util.ArrayList; import de.uni_freiburg.informatik.ultimate.model.acsl.ACSLNode; /** * Represents a function application which is a special form of a expression. */ public class FunctionApplication extends Expression { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(FunctionApplication.class); /** * The identifier of this function application. */ String identifier; /** * The arguments of this function application. */ Expression[] arguments; /** * The constructor taking initial values. * @param identifier the identifier of this function application. * @param arguments the arguments of this function application. */ public FunctionApplication(String identifier, Expression[] arguments) { super(); this.identifier = identifier; this.arguments = arguments; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid FunctionApplication: " + this; } /** * The constructor taking initial values. * @param type the type of this expression. * @param identifier the identifier of this function application. * @param arguments the arguments of this function application. */ public FunctionApplication(ACSLType type, String identifier, Expression[] arguments) { super(type); this.identifier = identifier; this.arguments = arguments; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid FunctionApplication: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("FunctionApplication").append('['); sb.append(identifier); sb.append(','); if (arguments == null) { sb.append("null"); } else { sb.append('['); for(int i1 = 0; i1 < arguments.length; i1++) { if (i1 > 0) sb.append(','); sb.append(arguments[i1]); } sb.append(']'); } return sb.append(']').toString(); } /** * Gets the identifier of this function application. * @return the identifier of this function application. */ public String getIdentifier() { return identifier; } /** * Gets the arguments of this function application. * @return the arguments of this function application. */ public Expression[] getArguments() { return arguments; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); if(arguments!=null){ children.addAll(Arrays.asList(arguments)); } 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(arguments!=null){ for (Expression elem : arguments) { elem.accept(visitor); } } if(type!=null){ type.accept(visitor); } } } public Expression accept(ACSLTransformer visitor) { Expression node = visitor.transform(this); if(node != this){ return node; } boolean isChanged=false; ArrayList tmpListnewarguments = new ArrayList<>(); if(arguments != null){ for(Expression elem : arguments){ Expression newarguments = (Expression)elem.accept(visitor); isChanged = isChanged || newarguments != elem; tmpListnewarguments.add(newarguments); } } ACSLType newtype = null; if(type != null){ newtype = (ACSLType)type.accept(visitor); } if(isChanged || type != newtype){ return new FunctionApplication(newtype, identifier, tmpListnewarguments.toArray(new Expression[0])); } return this; } }