comparison trunk/src/dil/ast/Types.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 5e3ef1b2011c
children 9e6c6bb73e5f
comparison
equal deleted inserted replaced
790:a83a07f6233d 791:5fe89bb8cbdd
6 6
7 public import dil.ast.Type; 7 public import dil.ast.Type;
8 import dil.ast.Node; 8 import dil.ast.Node;
9 import dil.ast.Expression; 9 import dil.ast.Expression;
10 import dil.ast.Parameters; 10 import dil.ast.Parameters;
11 import dil.ast.NodeCopier;
11 import dil.lexer.Identifier; 12 import dil.lexer.Identifier;
12 import dil.semantic.Types; 13 import dil.semantic.Types;
13 import dil.Enums; 14 import dil.Enums;
14 15
15 /// Syntax error. 16 /// Syntax error.
17 { 18 {
18 this() 19 this()
19 { 20 {
20 mixin(set_kind); 21 mixin(set_kind);
21 } 22 }
23 mixin(copyMethod);
22 } 24 }
23 25
24 /// char, int, float etc. 26 /// char, int, float etc.
25 class IntegralType : TypeNode 27 class IntegralType : TypeNode
26 { 28 {
28 this(TOK tok) 30 this(TOK tok)
29 { 31 {
30 mixin(set_kind); 32 mixin(set_kind);
31 this.tok = tok; 33 this.tok = tok;
32 } 34 }
35 mixin(copyMethod);
33 } 36 }
34 37
35 /// Identifier 38 /// Identifier
36 class IdentifierType : TypeNode 39 class IdentifierType : TypeNode
37 { 40 {
39 this(Identifier* ident) 42 this(Identifier* ident)
40 { 43 {
41 mixin(set_kind); 44 mixin(set_kind);
42 this.ident = ident; 45 this.ident = ident;
43 } 46 }
47 mixin(copyMethod);
44 } 48 }
45 49
46 /// Type "." Type 50 /// Type "." Type
47 class QualifiedType : TypeNode 51 class QualifiedType : TypeNode
48 { 52 {
53 super(lhs); 57 super(lhs);
54 mixin(set_kind); 58 mixin(set_kind);
55 addChild(rhs); 59 addChild(rhs);
56 this.rhs = rhs; 60 this.rhs = rhs;
57 } 61 }
62 mixin(copyMethod);
58 } 63 }
59 64
60 /// "." Type 65 /// "." Type
61 class ModuleScopeType : TypeNode 66 class ModuleScopeType : TypeNode
62 { 67 {
63 this(TypeNode next) 68 this(TypeNode next)
64 { 69 {
65 super(next); 70 super(next);
66 mixin(set_kind); 71 mixin(set_kind);
67 } 72 }
73 mixin(copyMethod);
68 } 74 }
69 75
70 /// "typeof" "(" Expression ")" or$(BR) 76 /// "typeof" "(" Expression ")" or$(BR)
71 /// "typeof" "(" "return" ")" (D2.0) 77 /// "typeof" "(" "return" ")" (D2.0)
72 class TypeofType : TypeNode 78 class TypeofType : TypeNode
87 93
88 bool isTypeofReturn() 94 bool isTypeofReturn()
89 { 95 {
90 return e is null; 96 return e is null;
91 } 97 }
98
99 mixin(copyMethod);
92 } 100 }
93 101
94 /// Identifier "!" "(" TemplateParameters? ")" 102 /// Identifier "!" "(" TemplateParameters? ")"
95 class TemplateInstanceType : TypeNode 103 class TemplateInstanceType : TypeNode
96 { 104 {
101 mixin(set_kind); 109 mixin(set_kind);
102 addOptChild(targs); 110 addOptChild(targs);
103 this.ident = ident; 111 this.ident = ident;
104 this.targs = targs; 112 this.targs = targs;
105 } 113 }
114 mixin(copyMethod);
106 } 115 }
107 116
108 /// Type * 117 /// Type *
109 class PointerType : TypeNode 118 class PointerType : TypeNode
110 { 119 {
111 this(TypeNode next) 120 this(TypeNode next)
112 { 121 {
113 super(next); 122 super(next);
114 mixin(set_kind); 123 mixin(set_kind);
115 } 124 }
125 mixin(copyMethod);
116 } 126 }
117 127
118 /// Dynamic array: T[] or$(BR) 128 /// Dynamic array: T[] or$(BR)
119 /// Static array: T[E] or$(BR) 129 /// Static array: T[E] or$(BR)
120 /// Slice array (for tuples): T[E..E] or$(BR) 130 /// Slice array (for tuples): T[E..E] or$(BR)
163 173
164 bool isAssociative() 174 bool isAssociative()
165 { 175 {
166 return assocType !is null; 176 return assocType !is null;
167 } 177 }
178
179 mixin(copyMethod);
168 } 180 }
169 181
170 /// ReturnType "function" "(" Parameters? ")" 182 /// ReturnType "function" "(" Parameters? ")"
171 class FunctionType : TypeNode 183 class FunctionType : TypeNode
172 { 184 {
177 super(returnType); 189 super(returnType);
178 mixin(set_kind); 190 mixin(set_kind);
179 addChild(params); 191 addChild(params);
180 this.params = params; 192 this.params = params;
181 } 193 }
194 mixin(copyMethod);
182 } 195 }
183 196
184 /// ReturnType "delegate" "(" Parameters? ")" 197 /// ReturnType "delegate" "(" Parameters? ")"
185 class DelegateType : TypeNode 198 class DelegateType : TypeNode
186 { 199 {
191 super(returnType); 204 super(returnType);
192 mixin(set_kind); 205 mixin(set_kind);
193 addChild(params); 206 addChild(params);
194 this.params = params; 207 this.params = params;
195 } 208 }
209 mixin(copyMethod);
196 } 210 }
197 211
198 /// Type "(" BasicType2 Identifier ")" "(" Parameters? ")" 212 /// Type "(" BasicType2 Identifier ")" "(" Parameters? ")"
199 class CFuncPointerType : TypeNode 213 class CFuncPointerType : TypeNode
200 { 214 {
203 { 217 {
204 super(type); 218 super(type);
205 mixin(set_kind); 219 mixin(set_kind);
206 addOptChild(params); 220 addOptChild(params);
207 } 221 }
222 mixin(copyMethod);
208 } 223 }
209 224
210 /// "class" Identifier : BaseClasses 225 /// "class" Identifier : BaseClasses
211 class BaseClassType : TypeNode 226 class BaseClassType : TypeNode
212 { 227 {
215 { 230 {
216 super(type); 231 super(type);
217 mixin(set_kind); 232 mixin(set_kind);
218 this.prot = prot; 233 this.prot = prot;
219 } 234 }
235 mixin(copyMethod);
220 } 236 }
221 237
222 // version(D2) 238 // version(D2)
223 // { 239 // {
224 /// "const" "(" Type ")" 240 /// "const" "(" Type ")"
228 { 244 {
229 // If t is null: cast(const) 245 // If t is null: cast(const)
230 super(next); 246 super(next);
231 mixin(set_kind); 247 mixin(set_kind);
232 } 248 }
249 mixin(copyMethod);
233 } 250 }
234 251
235 /// "invariant" "(" Type ")" 252 /// "invariant" "(" Type ")"
236 class InvariantType : TypeNode 253 class InvariantType : TypeNode
237 { 254 {
239 { 256 {
240 // If t is null: cast(invariant) 257 // If t is null: cast(invariant)
241 super(next); 258 super(next);
242 mixin(set_kind); 259 mixin(set_kind);
243 } 260 }
261 mixin(copyMethod);
244 } 262 }
245 // } // version(D2) 263 // } // version(D2)