• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ACallCommand extends PCommand
10 {
11     private PPosition _position_;
12     private final LinkedList<TWord> _macro_ = new LinkedList<TWord>();
13     private final LinkedList<PExpression> _arguments_ = new LinkedList<PExpression>();
14 
ACallCommand()15     public ACallCommand()
16     {
17         // Constructor
18     }
19 
ACallCommand( @uppressWarnings"hiding") PPosition _position_, @SuppressWarnings("hiding") List<TWord> _macro_, @SuppressWarnings("hiding") List<PExpression> _arguments_)20     public ACallCommand(
21         @SuppressWarnings("hiding") PPosition _position_,
22         @SuppressWarnings("hiding") List<TWord> _macro_,
23         @SuppressWarnings("hiding") List<PExpression> _arguments_)
24     {
25         // Constructor
26         setPosition(_position_);
27 
28         setMacro(_macro_);
29 
30         setArguments(_arguments_);
31 
32     }
33 
34     @Override
clone()35     public Object clone()
36     {
37         return new ACallCommand(
38             cloneNode(this._position_),
39             cloneList(this._macro_),
40             cloneList(this._arguments_));
41     }
42 
apply(Switch sw)43     public void apply(Switch sw)
44     {
45         ((Analysis) sw).caseACallCommand(this);
46     }
47 
getPosition()48     public PPosition getPosition()
49     {
50         return this._position_;
51     }
52 
setPosition(PPosition node)53     public void setPosition(PPosition node)
54     {
55         if(this._position_ != null)
56         {
57             this._position_.parent(null);
58         }
59 
60         if(node != null)
61         {
62             if(node.parent() != null)
63             {
64                 node.parent().removeChild(node);
65             }
66 
67             node.parent(this);
68         }
69 
70         this._position_ = node;
71     }
72 
getMacro()73     public LinkedList<TWord> getMacro()
74     {
75         return this._macro_;
76     }
77 
setMacro(List<TWord> list)78     public void setMacro(List<TWord> list)
79     {
80         this._macro_.clear();
81         this._macro_.addAll(list);
82         for(TWord e : list)
83         {
84             if(e.parent() != null)
85             {
86                 e.parent().removeChild(e);
87             }
88 
89             e.parent(this);
90         }
91     }
92 
getArguments()93     public LinkedList<PExpression> getArguments()
94     {
95         return this._arguments_;
96     }
97 
setArguments(List<PExpression> list)98     public void setArguments(List<PExpression> list)
99     {
100         this._arguments_.clear();
101         this._arguments_.addAll(list);
102         for(PExpression e : list)
103         {
104             if(e.parent() != null)
105             {
106                 e.parent().removeChild(e);
107             }
108 
109             e.parent(this);
110         }
111     }
112 
113     @Override
toString()114     public String toString()
115     {
116         return ""
117             + toString(this._position_)
118             + toString(this._macro_)
119             + toString(this._arguments_);
120     }
121 
122     @Override
removeChild(@uppressWarnings"unused") Node child)123     void removeChild(@SuppressWarnings("unused") Node child)
124     {
125         // Remove child
126         if(this._position_ == child)
127         {
128             this._position_ = null;
129             return;
130         }
131 
132         if(this._macro_.remove(child))
133         {
134             return;
135         }
136 
137         if(this._arguments_.remove(child))
138         {
139             return;
140         }
141 
142         throw new RuntimeException("Not a child.");
143     }
144 
145     @Override
replaceChild(@uppressWarnings"unused") Node oldChild, @SuppressWarnings("unused") Node newChild)146     void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
147     {
148         // Replace child
149         if(this._position_ == oldChild)
150         {
151             setPosition((PPosition) newChild);
152             return;
153         }
154 
155         for(ListIterator<TWord> i = this._macro_.listIterator(); i.hasNext();)
156         {
157             if(i.next() == oldChild)
158             {
159                 if(newChild != null)
160                 {
161                     i.set((TWord) newChild);
162                     newChild.parent(this);
163                     oldChild.parent(null);
164                     return;
165                 }
166 
167                 i.remove();
168                 oldChild.parent(null);
169                 return;
170             }
171         }
172 
173         for(ListIterator<PExpression> i = this._arguments_.listIterator(); i.hasNext();)
174         {
175             if(i.next() == oldChild)
176             {
177                 if(newChild != null)
178                 {
179                     i.set((PExpression) newChild);
180                     newChild.parent(this);
181                     oldChild.parent(null);
182                     return;
183                 }
184 
185                 i.remove();
186                 oldChild.parent(null);
187                 return;
188             }
189         }
190 
191         throw new RuntimeException("Not a child.");
192     }
193 }
194