1 /* This file was generated by SableCC (http://www.sablecc.org/). */ 2 3 package com.google.clearsilver.jsilver.syntax.node; 4 5 import java.util.*; 6 import com.google.clearsilver.jsilver.syntax.analysis.*; 7 8 @SuppressWarnings("nls") 9 public final class ADefCommand extends PCommand 10 { 11 private PPosition _position_; 12 private final LinkedList<TWord> _macro_ = new LinkedList<TWord>(); 13 private final LinkedList<PVariable> _arguments_ = new LinkedList<PVariable>(); 14 private PCommand _command_; 15 16 public ADefCommand() 17 { 18 // Constructor 19 } 20 21 public ADefCommand( 22 @SuppressWarnings("hiding") PPosition _position_, 23 @SuppressWarnings("hiding") List<TWord> _macro_, 24 @SuppressWarnings("hiding") List<PVariable> _arguments_, 25 @SuppressWarnings("hiding") PCommand _command_) 26 { 27 // Constructor 28 setPosition(_position_); 29 30 setMacro(_macro_); 31 32 setArguments(_arguments_); 33 34 setCommand(_command_); 35 36 } 37 38 @Override 39 public Object clone() 40 { 41 return new ADefCommand( 42 cloneNode(this._position_), 43 cloneList(this._macro_), 44 cloneList(this._arguments_), 45 cloneNode(this._command_)); 46 } 47 48 public void apply(Switch sw) 49 { 50 ((Analysis) sw).caseADefCommand(this); 51 } 52 53 public PPosition getPosition() 54 { 55 return this._position_; 56 } 57 58 public void setPosition(PPosition node) 59 { 60 if(this._position_ != null) 61 { 62 this._position_.parent(null); 63 } 64 65 if(node != null) 66 { 67 if(node.parent() != null) 68 { 69 node.parent().removeChild(node); 70 } 71 72 node.parent(this); 73 } 74 75 this._position_ = node; 76 } 77 78 public LinkedList<TWord> getMacro() 79 { 80 return this._macro_; 81 } 82 83 public void setMacro(List<TWord> list) 84 { 85 this._macro_.clear(); 86 this._macro_.addAll(list); 87 for(TWord e : list) 88 { 89 if(e.parent() != null) 90 { 91 e.parent().removeChild(e); 92 } 93 94 e.parent(this); 95 } 96 } 97 98 public LinkedList<PVariable> getArguments() 99 { 100 return this._arguments_; 101 } 102 103 public void setArguments(List<PVariable> list) 104 { 105 this._arguments_.clear(); 106 this._arguments_.addAll(list); 107 for(PVariable e : list) 108 { 109 if(e.parent() != null) 110 { 111 e.parent().removeChild(e); 112 } 113 114 e.parent(this); 115 } 116 } 117 118 public PCommand getCommand() 119 { 120 return this._command_; 121 } 122 123 public void setCommand(PCommand node) 124 { 125 if(this._command_ != null) 126 { 127 this._command_.parent(null); 128 } 129 130 if(node != null) 131 { 132 if(node.parent() != null) 133 { 134 node.parent().removeChild(node); 135 } 136 137 node.parent(this); 138 } 139 140 this._command_ = node; 141 } 142 143 @Override 144 public String toString() 145 { 146 return "" 147 + toString(this._position_) 148 + toString(this._macro_) 149 + toString(this._arguments_) 150 + toString(this._command_); 151 } 152 153 @Override 154 void removeChild(@SuppressWarnings("unused") Node child) 155 { 156 // Remove child 157 if(this._position_ == child) 158 { 159 this._position_ = null; 160 return; 161 } 162 163 if(this._macro_.remove(child)) 164 { 165 return; 166 } 167 168 if(this._arguments_.remove(child)) 169 { 170 return; 171 } 172 173 if(this._command_ == child) 174 { 175 this._command_ = null; 176 return; 177 } 178 179 throw new RuntimeException("Not a child."); 180 } 181 182 @Override 183 void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) 184 { 185 // Replace child 186 if(this._position_ == oldChild) 187 { 188 setPosition((PPosition) newChild); 189 return; 190 } 191 192 for(ListIterator<TWord> i = this._macro_.listIterator(); i.hasNext();) 193 { 194 if(i.next() == oldChild) 195 { 196 if(newChild != null) 197 { 198 i.set((TWord) newChild); 199 newChild.parent(this); 200 oldChild.parent(null); 201 return; 202 } 203 204 i.remove(); 205 oldChild.parent(null); 206 return; 207 } 208 } 209 210 for(ListIterator<PVariable> i = this._arguments_.listIterator(); i.hasNext();) 211 { 212 if(i.next() == oldChild) 213 { 214 if(newChild != null) 215 { 216 i.set((PVariable) newChild); 217 newChild.parent(this); 218 oldChild.parent(null); 219 return; 220 } 221 222 i.remove(); 223 oldChild.parent(null); 224 return; 225 } 226 } 227 228 if(this._command_ == oldChild) 229 { 230 setCommand((PCommand) newChild); 231 return; 232 } 233 234 throw new RuntimeException("Not a child."); 235 } 236 } 237