comparison trunk/src/dil/ast/Parameters.d @ 791:5fe89bb8cbdd

Implemented syntax tree copying.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 26 Feb 2008 20:13:41 +0100
parents 3b34f6a95a27
children
comparison
equal deleted inserted replaced
790:a83a07f6233d 791:5fe89bb8cbdd
5 module dil.ast.Parameters; 5 module dil.ast.Parameters;
6 6
7 import dil.ast.Node; 7 import dil.ast.Node;
8 import dil.ast.Type; 8 import dil.ast.Type;
9 import dil.ast.Expression; 9 import dil.ast.Expression;
10 import dil.ast.NodeCopier;
10 import dil.lexer.Identifier; 11 import dil.lexer.Identifier;
11 import dil.Enums; 12 import dil.Enums;
12 13
13 /// A function or foreach parameter. 14 /// A function or foreach parameter.
14 class Parameter : Node 15 class Parameter : Node
50 /// Returns true if this is a D- or C-style variadic parameter. 51 /// Returns true if this is a D- or C-style variadic parameter.
51 bool isVariadic() 52 bool isVariadic()
52 { 53 {
53 return !!(stc & StorageClass.Variadic); 54 return !!(stc & StorageClass.Variadic);
54 } 55 }
56
57 mixin(copyMethod);
55 } 58 }
56 59
57 /// Array of parameters. 60 /// Array of parameters.
58 class Parameters : Node 61 class Parameters : Node
59 { 62 {
76 Parameter[] items() 79 Parameter[] items()
77 { return cast(Parameter[])children; } 80 { return cast(Parameter[])children; }
78 81
79 size_t length() 82 size_t length()
80 { return children.length; } 83 { return children.length; }
84
85 mixin(copyMethod);
81 } 86 }
82 87
83 /*~~~~~~~~~~~~~~~~~~~~~~ 88 /*~~~~~~~~~~~~~~~~~~~~~~
84 ~ Template parameters: ~ 89 ~ Template parameters: ~
85 ~~~~~~~~~~~~~~~~~~~~~~*/ 90 ~~~~~~~~~~~~~~~~~~~~~~*/
91 this(Identifier* ident) 96 this(Identifier* ident)
92 { 97 {
93 super(NodeCategory.Other); 98 super(NodeCategory.Other);
94 this.ident = ident; 99 this.ident = ident;
95 } 100 }
101 override abstract TemplateParameter copy();
96 } 102 }
97 103
98 /// E.g.: (alias T) 104 /// E.g.: (alias T)
99 class TemplateAliasParameter : TemplateParameter 105 class TemplateAliasParameter : TemplateParameter
100 { 106 {
107 addOptChild(defType); 113 addOptChild(defType);
108 this.ident = ident; 114 this.ident = ident;
109 this.specType = specType; 115 this.specType = specType;
110 this.defType = defType; 116 this.defType = defType;
111 } 117 }
118 mixin(copyMethod);
112 } 119 }
113 120
114 /// E.g.: (T t) 121 /// E.g.: (T t)
115 class TemplateTypeParameter : TemplateParameter 122 class TemplateTypeParameter : TemplateParameter
116 { 123 {
123 addOptChild(defType); 130 addOptChild(defType);
124 this.ident = ident; 131 this.ident = ident;
125 this.specType = specType; 132 this.specType = specType;
126 this.defType = defType; 133 this.defType = defType;
127 } 134 }
135 mixin(copyMethod);
128 } 136 }
129 137
130 // version(D2) 138 // version(D2)
131 // { 139 // {
132 /// E.g.: (this T) 140 /// E.g.: (this T)
141 addOptChild(defType); 149 addOptChild(defType);
142 this.ident = ident; 150 this.ident = ident;
143 this.specType = specType; 151 this.specType = specType;
144 this.defType = defType; 152 this.defType = defType;
145 } 153 }
154 mixin(copyMethod);
146 } 155 }
147 // } 156 // }
148 157
149 /// E.g.: (T) 158 /// E.g.: (T)
150 class TemplateValueParameter : TemplateParameter 159 class TemplateValueParameter : TemplateParameter
161 this.valueType = valueType; 170 this.valueType = valueType;
162 this.ident = ident; 171 this.ident = ident;
163 this.specValue = specValue; 172 this.specValue = specValue;
164 this.defValue = defValue; 173 this.defValue = defValue;
165 } 174 }
175 mixin(copyMethod);
166 } 176 }
167 177
168 /// E.g.: (T...) 178 /// E.g.: (T...)
169 class TemplateTupleParameter : TemplateParameter 179 class TemplateTupleParameter : TemplateParameter
170 { 180 {
172 { 182 {
173 super(ident); 183 super(ident);
174 mixin(set_kind); 184 mixin(set_kind);
175 this.ident = ident; 185 this.ident = ident;
176 } 186 }
187 mixin(copyMethod);
177 } 188 }
178 189
179 /// Array of template parameters. 190 /// Array of template parameters.
180 class TemplateParameters : Node 191 class TemplateParameters : Node
181 { 192 {
192 203
193 TemplateParameter[] items() 204 TemplateParameter[] items()
194 { 205 {
195 return cast(TemplateParameter[])children; 206 return cast(TemplateParameter[])children;
196 } 207 }
208
209 mixin(copyMethod);
197 } 210 }
198 211
199 /// Array of template arguments. 212 /// Array of template arguments.
200 class TemplateArguments : Node 213 class TemplateArguments : Node
201 { 214 {
207 220
208 void opCatAssign(Node argument) 221 void opCatAssign(Node argument)
209 { 222 {
210 addChild(argument); 223 addChild(argument);
211 } 224 }
212 } 225
226 mixin(copyMethod);
227 }