/* This file was generated by SableCC (http://www.sablecc.org/). */ package com.google.clearsilver.jsilver.syntax.node; import java.util.*; import com.google.clearsilver.jsilver.syntax.analysis.*; @SuppressWarnings("nls") public final class AFunctionExpression extends PExpression { private PVariable _name_; private final LinkedList _args_ = new LinkedList(); public AFunctionExpression() { // Constructor } public AFunctionExpression( @SuppressWarnings("hiding") PVariable _name_, @SuppressWarnings("hiding") List _args_) { // Constructor setName(_name_); setArgs(_args_); } @Override public Object clone() { return new AFunctionExpression( cloneNode(this._name_), cloneList(this._args_)); } public void apply(Switch sw) { ((Analysis) sw).caseAFunctionExpression(this); } public PVariable getName() { return this._name_; } public void setName(PVariable node) { if(this._name_ != null) { this._name_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); } this._name_ = node; } public LinkedList getArgs() { return this._args_; } public void setArgs(List list) { this._args_.clear(); this._args_.addAll(list); for(PExpression e : list) { if(e.parent() != null) { e.parent().removeChild(e); } e.parent(this); } } @Override public String toString() { return "" + toString(this._name_) + toString(this._args_); } @Override void removeChild(@SuppressWarnings("unused") Node child) { // Remove child if(this._name_ == child) { this._name_ = null; return; } if(this._args_.remove(child)) { return; } throw new RuntimeException("Not a child."); } @Override void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) { // Replace child if(this._name_ == oldChild) { setName((PVariable) newChild); return; } for(ListIterator i = this._args_.listIterator(); i.hasNext();) { if(i.next() == oldChild) { if(newChild != null) { i.set((PExpression) newChild); newChild.parent(this); oldChild.parent(null); return; } i.remove(); oldChild.parent(null); return; } } throw new RuntimeException("Not a child."); } }