Mercurial > projects > dil
annotate trunk/src/dil/Types.d @ 492:9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Moved ImportParser from module Parser to its own module. Added a few methods
from class Parser and simplified them. Now protection attributes are taken into
consideration as well.
Added class TemplateThisParameter. Adapted TypeofType so that typeof(return)
can be recognized.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Thu, 06 Dec 2007 22:19:55 +0100 |
parents | a7291d3ee9d7 |
children | b60450804b6e |
rev | line source |
---|---|
94 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
94 | 4 +/ |
326 | 5 module dil.Types; |
327 | 6 import dil.SyntaxTree; |
7 import dil.Token; | |
8 import dil.Expressions; | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
9 import dil.Enums; |
94 | 10 |
359
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
11 class Linkage : Node |
159 | 12 { |
359
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
13 enum Type |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
14 { |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
15 Extern, |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
16 C, |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
17 Cpp, |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
18 D, |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
19 Windows, |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
20 Pascal, |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
21 System |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
22 } |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
23 |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
24 /++ |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
25 This enum is used by the parser to find redundant |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
26 or conflicting extern attribute declarations. |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
27 +/ |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
28 enum Category |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
29 { |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
30 Unset, |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
31 ExternSymbol = 1<<1, /// Extern |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
32 MangleSymbol = 1<<2 /// C, Cpp, D, Windows, Pascal, System |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
33 } |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
34 |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
35 Linkage.Type type; |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
36 |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
37 this(typeof(type) type) |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
38 { |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
39 super(NodeCategory.Other); |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
40 mixin(set_kind); |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
41 this.type = type; |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
42 } |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
43 |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
44 static Category getCategory(Linkage linkage) |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
45 { |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
46 if (linkage is null) |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
47 return Category.ExternSymbol; |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
48 else |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
49 return Category.MangleSymbol; |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
357
diff
changeset
|
50 } |
159 | 51 } |
52 | |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
53 class Parameter : Node |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
54 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
55 StorageClass stc; |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
56 Token* stcTok; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
57 Type type; |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
58 Token* ident; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
59 Expression assignExpr; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
60 |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
61 this(Token* stcTok, Type type, Token* ident, Expression assignExpr) |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
62 { |
275 | 63 super(NodeCategory.Other); |
281 | 64 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
65 // type can be null when param in foreach statement |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
66 addOptChild(type); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
67 addOptChild(assignExpr); |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
68 |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
69 StorageClass stc; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
70 if (stcTok !is null) |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
71 { |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
72 // NB: In D 2.0 StorageClass.In means final/scope/const |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
73 switch (stcTok.type) |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
74 { |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
75 // TODO: D 2.0 invariant/const/final/scope |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
76 case TOK.In: stc = StorageClass.In; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
77 case TOK.Out: stc = StorageClass.Out; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
78 case TOK.Inout: |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
79 case TOK.Ref: stc = StorageClass.Ref; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
80 case TOK.Lazy: stc = StorageClass.Lazy; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
81 case TOK.Ellipses: |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
82 stc = StorageClass.Variadic; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
83 default: |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
84 } |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
85 } |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
86 |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
87 this.stc = stc; |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
88 this.stcTok = stcTok; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
89 this.type = type; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
90 this.ident = ident; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
91 this.assignExpr = assignExpr; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
92 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
93 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
94 bool isVariadic() |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
95 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
96 return !!(stc & StorageClass.Variadic); |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
97 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
98 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
99 bool isOnlyVariadic() |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
100 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
101 return stc == StorageClass.Variadic; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
102 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
103 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
104 |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
105 class Parameters : Node |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
106 { |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
107 this() |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
108 { |
275 | 109 super(NodeCategory.Other); |
281 | 110 mixin(set_kind); |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
111 } |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
112 |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
113 bool hasVariadic() |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
114 { |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
115 if (children.length != 0) |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
116 return items[$-1].isVariadic(); |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
117 return false; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
118 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
119 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
120 void opCatAssign(Parameter param) |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
121 { addChild(param); } |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
122 |
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
123 Parameter[] items() |
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
124 { return cast(Parameter[])children; } |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
125 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
126 size_t length() |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
127 { return children.length; } |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
128 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
129 |
281 | 130 class BaseClass : Node |
158
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
131 { |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
132 Protection prot; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
133 Type type; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
134 this(Protection prot, Type type) |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
135 { |
281 | 136 super(NodeCategory.Other); |
137 mixin(set_kind); | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
138 addChild(type); |
158
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
139 this.prot = prot; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
140 this.type = type; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
141 } |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
142 } |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
143 |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
144 abstract class TemplateParameter : Node |
137 | 145 { |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
146 this() |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
147 { |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
148 super(NodeCategory.Other); |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
149 } |
137 | 150 } |
151 | |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
152 class TemplateAliasParameter : TemplateParameter |
137 | 153 { |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
154 Token* ident; |
137 | 155 Type specType, defType; |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
156 this(Token* ident, Type specType, Type defType) |
137 | 157 { |
281 | 158 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
159 addOptChild(specType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
160 addOptChild(defType); |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
161 this.ident = ident; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
162 this.specType = specType; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
163 this.defType = defType; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
164 } |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
165 } |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
166 |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
167 class TemplateTypeParameter : TemplateParameter |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
168 { |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
169 Token* ident; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
170 Type specType, defType; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
171 this(Token* ident, Type specType, Type defType) |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
172 { |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
173 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
174 addOptChild(specType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
175 addOptChild(defType); |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
176 this.ident = ident; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
177 this.specType = specType; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
178 this.defType = defType; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
179 } |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
180 } |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
181 |
492
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
182 version(D2) |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
183 { |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
184 class TemplateThisParameter : TemplateParameter |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
185 { |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
186 Token* ident; |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
187 Type specType, defType; |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
188 this(Token* ident, Type specType, Type defType) |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
189 { |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
190 mixin(set_kind); |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
191 addOptChild(specType); |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
192 addOptChild(defType); |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
193 this.ident = ident; |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
194 this.specType = specType; |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
195 this.defType = defType; |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
196 } |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
197 } |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
198 } |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
199 |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
200 class TemplateValueParameter : TemplateParameter |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
201 { |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
202 Type valueType; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
203 Token* ident; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
204 Expression specValue, defValue; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
205 this(Type valueType, Token* ident, Expression specValue, Expression defValue) |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
206 { |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
207 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
208 addChild(valueType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
209 addOptChild(specValue); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
210 addOptChild(defValue); |
137 | 211 this.valueType = valueType; |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
137
diff
changeset
|
212 this.ident = ident; |
137 | 213 this.specValue = specValue; |
214 this.defValue = defValue; | |
215 } | |
216 } | |
217 | |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
218 class TemplateTupleParameter : TemplateParameter |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
219 { |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
220 Token* ident; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
221 this(Token* ident) |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
222 { |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
223 mixin(set_kind); |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
224 this.ident = ident; |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
225 } |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
226 } |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
227 |
258 | 228 class TemplateParameters : Node |
229 { | |
230 this() | |
231 { | |
275 | 232 super(NodeCategory.Other); |
281 | 233 mixin(set_kind); |
258 | 234 } |
235 | |
236 void opCatAssign(TemplateParameter parameter) | |
237 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
238 addChild(parameter); |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
239 } |
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
240 |
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
241 TemplateParameter[] items() |
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
242 { |
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
243 return cast(TemplateParameter[])children; |
258 | 244 } |
245 } | |
246 | |
254
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
247 class TemplateArguments : Node |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
248 { |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
249 this() |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
250 { |
275 | 251 super(NodeCategory.Other); |
281 | 252 mixin(set_kind); |
254
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
253 } |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
254 |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
255 void opCatAssign(Node argument) |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
256 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
257 addChild(argument); |
254
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
258 } |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
259 } |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
137
diff
changeset
|
260 |
135 | 261 enum TID |
262 { | |
263 Void = TOK.Void, | |
264 Char = TOK.Char, | |
265 Wchar = TOK.Wchar, | |
266 Dchar = TOK.Dchar, | |
267 Bool = TOK.Bool, | |
268 Byte = TOK.Byte, | |
269 Ubyte = TOK.Ubyte, | |
270 Short = TOK.Short, | |
271 Ushort = TOK.Ushort, | |
272 Int = TOK.Int, | |
273 Uint = TOK.Uint, | |
274 Long = TOK.Long, | |
275 Ulong = TOK.Ulong, | |
276 Float = TOK.Float, | |
277 Double = TOK.Double, | |
278 Real = TOK.Real, | |
279 Ifloat = TOK.Ifloat, | |
280 Idouble = TOK.Idouble, | |
281 Ireal = TOK.Ireal, | |
282 Cfloat = TOK.Cfloat, | |
283 Cdouble = TOK.Cdouble, | |
284 Creal = TOK.Creal, | |
285 | |
286 Undefined, | |
287 Function, | |
288 Delegate, | |
289 Pointer, | |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
290 CFuncPointer, |
135 | 291 Array, |
488
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
292 Dot, |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
293 DotList, |
135 | 294 Identifier, |
295 Typeof, | |
153 | 296 TemplateInstance, |
269 | 297 Const, // D2 |
298 Invariant, // D2 | |
135 | 299 } |
300 | |
280 | 301 abstract class Type : Node |
94 | 302 { |
135 | 303 TID tid; |
95 | 304 Type next; |
305 | |
135 | 306 this(TID tid) |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
307 { |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
308 this(tid, null); |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
309 } |
135 | 310 |
311 this(TID tid, Type next) | |
94 | 312 { |
275 | 313 super(NodeCategory.Type); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
314 addOptChild(next); |
135 | 315 this.tid = tid; |
95 | 316 this.next = next; |
94 | 317 } |
318 } | |
319 | |
280 | 320 class IntegralType : Type |
321 { | |
322 this(TOK tok) | |
323 { | |
324 super(cast(TID)tok); | |
281 | 325 mixin(set_kind); |
280 | 326 } |
327 } | |
328 | |
134
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
329 class UndefinedType : Type |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
330 { |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
331 this() |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
332 { |
279 | 333 super(TID.Undefined); |
281 | 334 mixin(set_kind); |
134
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
335 } |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
336 } |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
337 |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
338 class DotListType : Type |
153 | 339 { |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
340 Type[] dotList; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
341 this(Type[] dotList) |
153 | 342 { |
279 | 343 super(TID.DotList); |
281 | 344 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
345 addChildren(dotList); |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
346 this.dotList = dotList; |
153 | 347 } |
348 } | |
349 | |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
350 class IdentifierType : Type |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
351 { |
264 | 352 Token* ident; |
353 this(Token* ident) | |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
354 { |
279 | 355 super(TID.Identifier); |
281 | 356 mixin(set_kind); |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
357 this.ident = ident; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
358 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
359 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
360 |
488
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
361 class DotType : Type |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
362 { |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
363 this() |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
364 { |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
365 super(TID.Dot); |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
366 mixin(set_kind); |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
367 } |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
368 } |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
369 |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
370 class TypeofType : Type |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
371 { |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
372 Expression e; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
373 this(Expression e) |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
374 { |
492
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
375 this(); |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
376 addChild(e); |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
377 this.e = e; |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
378 } |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
379 |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
380 this() |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
381 { |
279 | 382 super(TID.Typeof); |
281 | 383 mixin(set_kind); |
492
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
384 } |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
385 |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
386 bool isTypeofReturn() |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
387 { |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
388 return e is null; |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
389 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
390 } |
95 | 391 |
153 | 392 class TemplateInstanceType : Type |
393 { | |
264 | 394 Token* ident; |
153 | 395 TemplateArguments targs; |
264 | 396 this(Token* ident, TemplateArguments targs) |
153 | 397 { |
279 | 398 super(TID.TemplateInstance); |
281 | 399 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
400 addOptChild(targs); |
153 | 401 this.ident = ident; |
402 this.targs = targs; | |
403 } | |
404 } | |
405 | |
95 | 406 class PointerType : Type |
407 { | |
408 this(Type t) | |
409 { | |
135 | 410 super(TID.Pointer, t); |
281 | 411 mixin(set_kind); |
95 | 412 } |
413 } | |
414 | |
415 class ArrayType : Type | |
416 { | |
106 | 417 Expression e, e2; |
418 Type assocType; | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
419 |
106 | 420 this(Type t) |
95 | 421 { |
135 | 422 super(TID.Array, t); |
281 | 423 mixin(set_kind); |
106 | 424 } |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
425 |
106 | 426 this(Type t, Expression e, Expression e2) |
427 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
428 addChild(e); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
429 addOptChild(e2); |
95 | 430 this.e = e; |
106 | 431 this.e2 = e2; |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
432 this(t); |
106 | 433 } |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
434 |
106 | 435 this(Type t, Type assocType) |
436 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
437 addChild(assocType); |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
438 this.assocType = assocType; |
106 | 439 this(t); |
95 | 440 } |
441 } | |
100 | 442 |
130 | 443 class FunctionType : Type |
444 { | |
445 Type returnType; | |
446 Parameters parameters; | |
291
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
447 this(Type returnType, Parameters parameters) |
130 | 448 { |
279 | 449 super(TID.Function); |
281 | 450 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
451 addChild(returnType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
452 addChild(parameters); |
130 | 453 this.returnType = returnType; |
454 this.parameters = parameters; | |
455 } | |
456 } | |
135 | 457 |
458 class DelegateType : Type | |
459 { | |
291
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
460 Type returnType; |
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
461 Parameters parameters; |
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
462 this(Type returnType, Parameters parameters) |
135 | 463 { |
291
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
464 super(TID.Delegate); |
281 | 465 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
466 addChild(returnType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
467 addChild(parameters); |
291
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
468 this.returnType = returnType; |
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
469 this.parameters = parameters; |
135 | 470 } |
471 } | |
269 | 472 |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
473 class CFuncPointerType : Type |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
474 { |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
475 Parameters params; |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
476 this(Type type, Parameters params) |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
477 { |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
478 super(TID.CFuncPointer, type); |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
479 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
480 addOptChild(params); |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
481 } |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
482 } |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
483 |
269 | 484 version(D2) |
485 { | |
486 class ConstType : Type | |
487 { | |
488 this(Type t) | |
489 { | |
490 // If t is null: cast(const) | |
491 super(TID.Const, t); | |
281 | 492 mixin(set_kind); |
269 | 493 } |
494 } | |
495 | |
496 class InvariantType : Type | |
497 { | |
498 this(Type t) | |
499 { | |
500 // If t is null: cast(invariant) | |
501 super(TID.Invariant, t); | |
281 | 502 mixin(set_kind); |
269 | 503 } |
504 } | |
505 } // version(D2) |