001: /* This file was generated by SableCC (http://www.sablecc.org/). */
002:
003: package org.jmatlab.node;
004:
005: import java.util.*;
006: import org.jmatlab.analysis.*;
007:
008: public final class AIdentifierFunctionDef extends PFunctionDef {
009: private TFunction _function_;
010: private TIdentifier _n1_;
011: private TAssignop _assignop_;
012: private TIdentifier _n2_;
013: private TLParen _lParen_;
014: private PVariables _variables_;
015: private TRParen _rParen_;
016: private final LinkedList _statement_ = new TypedLinkedList(
017: new Statement_Cast());
018: private TEnd _end_;
019:
020: public AIdentifierFunctionDef() {
021: }
022:
023: public AIdentifierFunctionDef(TFunction _function_,
024: TIdentifier _n1_, TAssignop _assignop_, TIdentifier _n2_,
025: TLParen _lParen_, PVariables _variables_, TRParen _rParen_,
026: List _statement_, TEnd _end_) {
027: setFunction(_function_);
028:
029: setN1(_n1_);
030:
031: setAssignop(_assignop_);
032:
033: setN2(_n2_);
034:
035: setLParen(_lParen_);
036:
037: setVariables(_variables_);
038:
039: setRParen(_rParen_);
040:
041: {
042: this ._statement_.clear();
043: this ._statement_.addAll(_statement_);
044: }
045:
046: setEnd(_end_);
047:
048: }
049:
050: public Object clone() {
051: return new AIdentifierFunctionDef(
052: (TFunction) cloneNode(_function_),
053: (TIdentifier) cloneNode(_n1_),
054: (TAssignop) cloneNode(_assignop_),
055: (TIdentifier) cloneNode(_n2_),
056: (TLParen) cloneNode(_lParen_),
057: (PVariables) cloneNode(_variables_),
058: (TRParen) cloneNode(_rParen_), cloneList(_statement_),
059: (TEnd) cloneNode(_end_));
060: }
061:
062: public void apply(Switch sw) {
063: ((Analysis) sw).caseAIdentifierFunctionDef(this );
064: }
065:
066: public TFunction getFunction() {
067: return _function_;
068: }
069:
070: public void setFunction(TFunction node) {
071: if (_function_ != null) {
072: _function_.parent(null);
073: }
074:
075: if (node != null) {
076: if (node.parent() != null) {
077: node.parent().removeChild(node);
078: }
079:
080: node.parent(this );
081: }
082:
083: _function_ = node;
084: }
085:
086: public TIdentifier getN1() {
087: return _n1_;
088: }
089:
090: public void setN1(TIdentifier node) {
091: if (_n1_ != null) {
092: _n1_.parent(null);
093: }
094:
095: if (node != null) {
096: if (node.parent() != null) {
097: node.parent().removeChild(node);
098: }
099:
100: node.parent(this );
101: }
102:
103: _n1_ = node;
104: }
105:
106: public TAssignop getAssignop() {
107: return _assignop_;
108: }
109:
110: public void setAssignop(TAssignop node) {
111: if (_assignop_ != null) {
112: _assignop_.parent(null);
113: }
114:
115: if (node != null) {
116: if (node.parent() != null) {
117: node.parent().removeChild(node);
118: }
119:
120: node.parent(this );
121: }
122:
123: _assignop_ = node;
124: }
125:
126: public TIdentifier getN2() {
127: return _n2_;
128: }
129:
130: public void setN2(TIdentifier node) {
131: if (_n2_ != null) {
132: _n2_.parent(null);
133: }
134:
135: if (node != null) {
136: if (node.parent() != null) {
137: node.parent().removeChild(node);
138: }
139:
140: node.parent(this );
141: }
142:
143: _n2_ = node;
144: }
145:
146: public TLParen getLParen() {
147: return _lParen_;
148: }
149:
150: public void setLParen(TLParen node) {
151: if (_lParen_ != null) {
152: _lParen_.parent(null);
153: }
154:
155: if (node != null) {
156: if (node.parent() != null) {
157: node.parent().removeChild(node);
158: }
159:
160: node.parent(this );
161: }
162:
163: _lParen_ = node;
164: }
165:
166: public PVariables getVariables() {
167: return _variables_;
168: }
169:
170: public void setVariables(PVariables node) {
171: if (_variables_ != null) {
172: _variables_.parent(null);
173: }
174:
175: if (node != null) {
176: if (node.parent() != null) {
177: node.parent().removeChild(node);
178: }
179:
180: node.parent(this );
181: }
182:
183: _variables_ = node;
184: }
185:
186: public TRParen getRParen() {
187: return _rParen_;
188: }
189:
190: public void setRParen(TRParen node) {
191: if (_rParen_ != null) {
192: _rParen_.parent(null);
193: }
194:
195: if (node != null) {
196: if (node.parent() != null) {
197: node.parent().removeChild(node);
198: }
199:
200: node.parent(this );
201: }
202:
203: _rParen_ = node;
204: }
205:
206: public LinkedList getStatement() {
207: return _statement_;
208: }
209:
210: public void setStatement(List list) {
211: _statement_.clear();
212: _statement_.addAll(list);
213: }
214:
215: public TEnd getEnd() {
216: return _end_;
217: }
218:
219: public void setEnd(TEnd node) {
220: if (_end_ != null) {
221: _end_.parent(null);
222: }
223:
224: if (node != null) {
225: if (node.parent() != null) {
226: node.parent().removeChild(node);
227: }
228:
229: node.parent(this );
230: }
231:
232: _end_ = node;
233: }
234:
235: public String toString() {
236: return "" + toString(_function_) + toString(_n1_)
237: + toString(_assignop_) + toString(_n2_)
238: + toString(_lParen_) + toString(_variables_)
239: + toString(_rParen_) + toString(_statement_)
240: + toString(_end_);
241: }
242:
243: void removeChild(Node child) {
244: if (_function_ == child) {
245: _function_ = null;
246: return;
247: }
248:
249: if (_n1_ == child) {
250: _n1_ = null;
251: return;
252: }
253:
254: if (_assignop_ == child) {
255: _assignop_ = null;
256: return;
257: }
258:
259: if (_n2_ == child) {
260: _n2_ = null;
261: return;
262: }
263:
264: if (_lParen_ == child) {
265: _lParen_ = null;
266: return;
267: }
268:
269: if (_variables_ == child) {
270: _variables_ = null;
271: return;
272: }
273:
274: if (_rParen_ == child) {
275: _rParen_ = null;
276: return;
277: }
278:
279: if (_statement_.remove(child)) {
280: return;
281: }
282:
283: if (_end_ == child) {
284: _end_ = null;
285: return;
286: }
287:
288: }
289:
290: void replaceChild(Node oldChild, Node newChild) {
291: if (_function_ == oldChild) {
292: setFunction((TFunction) newChild);
293: return;
294: }
295:
296: if (_n1_ == oldChild) {
297: setN1((TIdentifier) newChild);
298: return;
299: }
300:
301: if (_assignop_ == oldChild) {
302: setAssignop((TAssignop) newChild);
303: return;
304: }
305:
306: if (_n2_ == oldChild) {
307: setN2((TIdentifier) newChild);
308: return;
309: }
310:
311: if (_lParen_ == oldChild) {
312: setLParen((TLParen) newChild);
313: return;
314: }
315:
316: if (_variables_ == oldChild) {
317: setVariables((PVariables) newChild);
318: return;
319: }
320:
321: if (_rParen_ == oldChild) {
322: setRParen((TRParen) newChild);
323: return;
324: }
325:
326: for (ListIterator i = _statement_.listIterator(); i.hasNext();) {
327: if (i.next() == oldChild) {
328: if (newChild != null) {
329: i.set(newChild);
330: oldChild.parent(null);
331: return;
332: }
333:
334: i.remove();
335: oldChild.parent(null);
336: return;
337: }
338: }
339:
340: if (_end_ == oldChild) {
341: setEnd((TEnd) newChild);
342: return;
343: }
344:
345: }
346:
347: private class Statement_Cast implements Cast {
348: public Object cast(Object o) {
349: PStatement node = (PStatement) o;
350:
351: if ((node.parent() != null)
352: && (node.parent() != AIdentifierFunctionDef.this)) {
353: node.parent().removeChild(node);
354: }
355:
356: if ((node.parent() == null)
357: || (node.parent() != AIdentifierFunctionDef.this)) {
358: node.parent(AIdentifierFunctionDef.this);
359: }
360:
361: return node;
362: }
363: }
364: }
|