1/* This file was generated by SableCC (http://www.sablecc.org/). */ 2 3package com.google.clearsilver.jsilver.syntax.node; 4 5import java.util.*; 6import com.google.clearsilver.jsilver.syntax.analysis.*; 7 8@SuppressWarnings("nls") 9public final class AFunctionExpression extends PExpression 10{ 11 private PVariable _name_; 12 private final LinkedList<PExpression> _args_ = new LinkedList<PExpression>(); 13 14 public AFunctionExpression() 15 { 16 // Constructor 17 } 18 19 public AFunctionExpression( 20 @SuppressWarnings("hiding") PVariable _name_, 21 @SuppressWarnings("hiding") List<PExpression> _args_) 22 { 23 // Constructor 24 setName(_name_); 25 26 setArgs(_args_); 27 28 } 29 30 @Override 31 public Object clone() 32 { 33 return new AFunctionExpression( 34 cloneNode(this._name_), 35 cloneList(this._args_)); 36 } 37 38 public void apply(Switch sw) 39 { 40 ((Analysis) sw).caseAFunctionExpression(this); 41 } 42 43 public PVariable getName() 44 { 45 return this._name_; 46 } 47 48 public void setName(PVariable node) 49 { 50 if(this._name_ != null) 51 { 52 this._name_.parent(null); 53 } 54 55 if(node != null) 56 { 57 if(node.parent() != null) 58 { 59 node.parent().removeChild(node); 60 } 61 62 node.parent(this); 63 } 64 65 this._name_ = node; 66 } 67 68 public LinkedList<PExpression> getArgs() 69 { 70 return this._args_; 71 } 72 73 public void setArgs(List<PExpression> list) 74 { 75 this._args_.clear(); 76 this._args_.addAll(list); 77 for(PExpression e : list) 78 { 79 if(e.parent() != null) 80 { 81 e.parent().removeChild(e); 82 } 83 84 e.parent(this); 85 } 86 } 87 88 @Override 89 public String toString() 90 { 91 return "" 92 + toString(this._name_) 93 + toString(this._args_); 94 } 95 96 @Override 97 void removeChild(@SuppressWarnings("unused") Node child) 98 { 99 // Remove child 100 if(this._name_ == child) 101 { 102 this._name_ = null; 103 return; 104 } 105 106 if(this._args_.remove(child)) 107 { 108 return; 109 } 110 111 throw new RuntimeException("Not a child."); 112 } 113 114 @Override 115 void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) 116 { 117 // Replace child 118 if(this._name_ == oldChild) 119 { 120 setName((PVariable) newChild); 121 return; 122 } 123 124 for(ListIterator<PExpression> i = this._args_.listIterator(); i.hasNext();) 125 { 126 if(i.next() == oldChild) 127 { 128 if(newChild != null) 129 { 130 i.set((PExpression) newChild); 131 newChild.parent(this); 132 oldChild.parent(null); 133 return; 134 } 135 136 i.remove(); 137 oldChild.parent(null); 138 return; 139 } 140 } 141 142 throw new RuntimeException("Not a child."); 143 } 144} 145