blob: 0d091f2d81a167ad0da551f99f70f2a4c62696df [file] [log] [blame]
/* 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<PExpression> _args_ = new LinkedList<PExpression>();
public AFunctionExpression()
{
// Constructor
}
public AFunctionExpression(
@SuppressWarnings("hiding") PVariable _name_,
@SuppressWarnings("hiding") List<PExpression> _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<PExpression> getArgs()
{
return this._args_;
}
public void setArgs(List<PExpression> 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<PExpression> 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.");
}
}