Mercurial > projects > dil
comparison trunk/src/dil/ast/Parameters.d @ 786:3b34f6a95a27
Added and revised documenation comments.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 24 Feb 2008 02:41:11 +0100 |
parents | 00f872d949ea |
children | 5fe89bb8cbdd |
comparison
equal
deleted
inserted
replaced
785:57ef69eced96 | 786:3b34f6a95a27 |
---|---|
8 import dil.ast.Type; | 8 import dil.ast.Type; |
9 import dil.ast.Expression; | 9 import dil.ast.Expression; |
10 import dil.lexer.Identifier; | 10 import dil.lexer.Identifier; |
11 import dil.Enums; | 11 import dil.Enums; |
12 | 12 |
13 /// A function or foreach parameter. | |
13 class Parameter : Node | 14 class Parameter : Node |
14 { | 15 { |
15 StorageClass stc; | 16 StorageClass stc; /// The storage classes of the parameter. |
16 TypeNode type; | 17 TypeNode type; /// The parameter's type. |
17 Identifier* name; | 18 Identifier* name; /// The name of the parameter. |
18 Expression defValue; | 19 Expression defValue; /// The default initialization value. |
19 | 20 |
20 this(StorageClass stc, TypeNode type, Identifier* name, Expression defValue) | 21 this(StorageClass stc, TypeNode type, Identifier* name, Expression defValue) |
21 { | 22 { |
22 super(NodeCategory.Other); | 23 super(NodeCategory.Other); |
23 mixin(set_kind); | 24 mixin(set_kind); |
29 this.type = type; | 30 this.type = type; |
30 this.name = name; | 31 this.name = name; |
31 this.defValue = defValue; | 32 this.defValue = defValue; |
32 } | 33 } |
33 | 34 |
34 /// func(...) or func(int[] values ...) | 35 /// Returns true if this is a D-style variadic parameter. |
35 bool isVariadic() | 36 /// E.g.: func(int[] values ...) |
36 { | |
37 return !!(stc & StorageClass.Variadic); | |
38 } | |
39 | |
40 /// func(int[] values ...) | |
41 bool isDVariadic() | 37 bool isDVariadic() |
42 { | 38 { |
43 return isVariadic && !isCVariadic; | 39 return isVariadic && !isCVariadic; |
44 } | 40 } |
45 | 41 |
46 /// func(...) | 42 /// Returns true if this is a C-style variadic parameter. |
43 /// E.g.: func(...) | |
47 bool isCVariadic() | 44 bool isCVariadic() |
48 { | 45 { |
49 return stc == StorageClass.Variadic && | 46 return stc == StorageClass.Variadic && |
50 type is null && name is null; | 47 type is null && name is null; |
51 } | 48 } |
52 } | 49 |
53 | 50 /// Returns true if this is a D- or C-style variadic parameter. |
51 bool isVariadic() | |
52 { | |
53 return !!(stc & StorageClass.Variadic); | |
54 } | |
55 } | |
56 | |
57 /// Array of parameters. | |
54 class Parameters : Node | 58 class Parameters : Node |
55 { | 59 { |
56 this() | 60 this() |
57 { | 61 { |
58 super(NodeCategory.Other); | 62 super(NodeCategory.Other); |
78 | 82 |
79 /*~~~~~~~~~~~~~~~~~~~~~~ | 83 /*~~~~~~~~~~~~~~~~~~~~~~ |
80 ~ Template parameters: ~ | 84 ~ Template parameters: ~ |
81 ~~~~~~~~~~~~~~~~~~~~~~*/ | 85 ~~~~~~~~~~~~~~~~~~~~~~*/ |
82 | 86 |
87 /// Abstract base class for all template parameters. | |
83 abstract class TemplateParameter : Node | 88 abstract class TemplateParameter : Node |
84 { | 89 { |
85 Identifier* ident; | 90 Identifier* ident; |
86 this(Identifier* ident) | 91 this(Identifier* ident) |
87 { | 92 { |
88 super(NodeCategory.Other); | 93 super(NodeCategory.Other); |
89 this.ident = ident; | 94 this.ident = ident; |
90 } | 95 } |
91 } | 96 } |
92 | 97 |
98 /// E.g.: (alias T) | |
93 class TemplateAliasParameter : TemplateParameter | 99 class TemplateAliasParameter : TemplateParameter |
94 { | 100 { |
95 TypeNode specType, defType; | 101 TypeNode specType, defType; |
96 this(Identifier* ident, TypeNode specType, TypeNode defType) | 102 this(Identifier* ident, TypeNode specType, TypeNode defType) |
97 { | 103 { |
103 this.specType = specType; | 109 this.specType = specType; |
104 this.defType = defType; | 110 this.defType = defType; |
105 } | 111 } |
106 } | 112 } |
107 | 113 |
114 /// E.g.: (T t) | |
108 class TemplateTypeParameter : TemplateParameter | 115 class TemplateTypeParameter : TemplateParameter |
109 { | 116 { |
110 TypeNode specType, defType; | 117 TypeNode specType, defType; |
111 this(Identifier* ident, TypeNode specType, TypeNode defType) | 118 this(Identifier* ident, TypeNode specType, TypeNode defType) |
112 { | 119 { |
120 } | 127 } |
121 } | 128 } |
122 | 129 |
123 // version(D2) | 130 // version(D2) |
124 // { | 131 // { |
132 /// E.g.: (this T) | |
125 class TemplateThisParameter : TemplateParameter | 133 class TemplateThisParameter : TemplateParameter |
126 { | 134 { |
127 TypeNode specType, defType; | 135 TypeNode specType, defType; |
128 this(Identifier* ident, TypeNode specType, TypeNode defType) | 136 this(Identifier* ident, TypeNode specType, TypeNode defType) |
129 { | 137 { |
136 this.defType = defType; | 144 this.defType = defType; |
137 } | 145 } |
138 } | 146 } |
139 // } | 147 // } |
140 | 148 |
149 /// E.g.: (T) | |
141 class TemplateValueParameter : TemplateParameter | 150 class TemplateValueParameter : TemplateParameter |
142 { | 151 { |
143 TypeNode valueType; | 152 TypeNode valueType; |
144 Expression specValue, defValue; | 153 Expression specValue, defValue; |
145 this(TypeNode valueType, Identifier* ident, Expression specValue, Expression defValue) | 154 this(TypeNode valueType, Identifier* ident, Expression specValue, Expression defValue) |
154 this.specValue = specValue; | 163 this.specValue = specValue; |
155 this.defValue = defValue; | 164 this.defValue = defValue; |
156 } | 165 } |
157 } | 166 } |
158 | 167 |
168 /// E.g.: (T...) | |
159 class TemplateTupleParameter : TemplateParameter | 169 class TemplateTupleParameter : TemplateParameter |
160 { | 170 { |
161 this(Identifier* ident) | 171 this(Identifier* ident) |
162 { | 172 { |
163 super(ident); | 173 super(ident); |
164 mixin(set_kind); | 174 mixin(set_kind); |
165 this.ident = ident; | 175 this.ident = ident; |
166 } | 176 } |
167 } | 177 } |
168 | 178 |
179 /// Array of template parameters. | |
169 class TemplateParameters : Node | 180 class TemplateParameters : Node |
170 { | 181 { |
171 this() | 182 this() |
172 { | 183 { |
173 super(NodeCategory.Other); | 184 super(NodeCategory.Other); |
183 { | 194 { |
184 return cast(TemplateParameter[])children; | 195 return cast(TemplateParameter[])children; |
185 } | 196 } |
186 } | 197 } |
187 | 198 |
199 /// Array of template arguments. | |
188 class TemplateArguments : Node | 200 class TemplateArguments : Node |
189 { | 201 { |
190 this() | 202 this() |
191 { | 203 { |
192 super(NodeCategory.Other); | 204 super(NodeCategory.Other); |