Mercurial > projects > dil
annotate trunk/src/dil/ast/Types.d @ 670:d8c32113afde
Added command 'translate'.
Added Undefined to enum NodeCategory.
Fixed ctor of QualifiedType.
Improved GermanTranslator.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Thu, 17 Jan 2008 22:28:04 +0100 |
parents | a1f8d8f2db38 |
children | f1325a4506de |
rev | line source |
---|---|
94 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
94 | 4 +/ |
588
dcfec202718d
Moved dil.Types to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
586
diff
changeset
|
5 module dil.ast.Types; |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
521
diff
changeset
|
6 |
580
fa6d3c52757d
Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
7 import dil.ast.Node; |
659
304331ca2f95
Renamed EmptyExpression to IllegalExpression.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
655
diff
changeset
|
8 import dil.ast.Expression; |
608
fac9e8b258fc
Moved dil.ast.Parameter to dil.ast.Parameters.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
606
diff
changeset
|
9 import dil.ast.Parameters; |
600
041eae272362
Moved dil.Identifier to dil.lexer.Identifier.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
10 import dil.lexer.Identifier; |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
11 import dil.Enums; |
584
556bfb18dff8
Moved dil.TypeSystem to dil.semantic.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
580
diff
changeset
|
12 import dil.semantic.Types; |
94 | 13 |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
14 // Scheduled for deletion. |
135 | 15 enum TID |
16 { | |
17 Void = TOK.Void, | |
18 Char = TOK.Char, | |
19 Wchar = TOK.Wchar, | |
20 Dchar = TOK.Dchar, | |
21 Bool = TOK.Bool, | |
22 Byte = TOK.Byte, | |
23 Ubyte = TOK.Ubyte, | |
24 Short = TOK.Short, | |
25 Ushort = TOK.Ushort, | |
26 Int = TOK.Int, | |
27 Uint = TOK.Uint, | |
28 Long = TOK.Long, | |
29 Ulong = TOK.Ulong, | |
30 Float = TOK.Float, | |
31 Double = TOK.Double, | |
32 Real = TOK.Real, | |
33 Ifloat = TOK.Ifloat, | |
34 Idouble = TOK.Idouble, | |
35 Ireal = TOK.Ireal, | |
36 Cfloat = TOK.Cfloat, | |
37 Cdouble = TOK.Cdouble, | |
38 Creal = TOK.Creal, | |
521
772ffdb18fd4
Fix: added 'Cent' to enum TID.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
39 Cent = TOK.Cent, |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
40 Ucent = TOK.Ucent, |
135 | 41 |
42 Undefined, | |
655
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
43 BaseClass, |
135 | 44 Function, |
45 Delegate, | |
46 Pointer, | |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
47 CFuncPointer, |
135 | 48 Array, |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
49 Qualified, |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
50 ModuleScope, |
135 | 51 Identifier, |
52 Typeof, | |
153 | 53 TemplateInstance, |
269 | 54 Const, // D2 |
55 Invariant, // D2 | |
135 | 56 } |
57 | |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
58 /// The base class of all type nodes. |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
59 abstract class TypeNode : Node |
94 | 60 { |
135 | 61 TID tid; |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
62 TypeNode next; |
667
1ac758cd952a
Fixed a few things in DefaultVisitor.d and Pass1.d
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
659
diff
changeset
|
63 Type type; /// The semantic type of this type node. |
95 | 64 |
135 | 65 this(TID tid) |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
66 { |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
67 this(tid, null); |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
68 } |
135 | 69 |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
70 this(TID tid, TypeNode next) |
94 | 71 { |
275 | 72 super(NodeCategory.Type); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
73 addOptChild(next); |
135 | 74 this.tid = tid; |
95 | 75 this.next = next; |
94 | 76 } |
77 } | |
78 | |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
79 /// Illegal type. |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
80 class UndefinedType : TypeNode |
134
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
81 { |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
82 this() |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
83 { |
279 | 84 super(TID.Undefined); |
281 | 85 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
|
86 } |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
87 } |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
88 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
89 /// char, int, float etc. |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
90 class IntegralType : TypeNode |
153 | 91 { |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
92 this(TOK tok) |
153 | 93 { |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
94 super(cast(TID)tok); |
281 | 95 mixin(set_kind); |
153 | 96 } |
97 } | |
98 | |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
99 /// Identifier |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
100 class IdentifierType : TypeNode |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
101 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
102 Identifier* ident; |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
103 this(Identifier* ident) |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
104 { |
279 | 105 super(TID.Identifier); |
281 | 106 mixin(set_kind); |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
107 this.ident = ident; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
108 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
109 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
110 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
111 /// Type "." Type |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
112 class QualifiedType : TypeNode |
488
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
113 { |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
114 alias next left; |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
115 TypeNode right; |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
116 this(TypeNode left, TypeNode right) |
488
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
117 { |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
118 super(TID.Qualified, left); |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
119 mixin(set_kind); |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
120 addChild(right); |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
121 this.right = right; |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
122 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
123 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
124 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
125 /// "." Type |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
126 class ModuleScopeType : TypeNode |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
127 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
128 this(TypeNode next) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
129 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
130 super(TID.ModuleScope, next); |
488
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
131 mixin(set_kind); |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
132 } |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
133 } |
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
134 |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
135 /// "typeof" "(" Expression ") |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
136 class TypeofType : TypeNode |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
137 { |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
138 Expression e; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
139 this(Expression e) |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
140 { |
492
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
141 this(); |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
142 addChild(e); |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
143 this.e = e; |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
144 } |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
145 |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
146 /// D2.0: "typeof" "(" "return" ")" |
492
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
147 this() |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
148 { |
279 | 149 super(TID.Typeof); |
281 | 150 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
|
151 } |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
152 |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
153 bool isTypeofReturn() |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
154 { |
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
155 return e is null; |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
156 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
157 } |
95 | 158 |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
159 /// Identifier "!" "(" TemplateParameters? ")" |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
160 class TemplateInstanceType : TypeNode |
153 | 161 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
162 Identifier* ident; |
153 | 163 TemplateArguments targs; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
164 this(Identifier* ident, TemplateArguments targs) |
153 | 165 { |
279 | 166 super(TID.TemplateInstance); |
281 | 167 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
168 addOptChild(targs); |
153 | 169 this.ident = ident; |
170 this.targs = targs; | |
171 } | |
172 } | |
173 | |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
174 /// Type * |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
175 class PointerType : TypeNode |
95 | 176 { |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
177 this(TypeNode t) |
95 | 178 { |
135 | 179 super(TID.Pointer, t); |
281 | 180 mixin(set_kind); |
95 | 181 } |
182 } | |
183 | |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
184 /// Dynamic array: T[] or |
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
185 /// Static array: T[E] or |
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
186 /// Slice array (for tuples): T[E..E] or |
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
187 /// Associative array: T[T] |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
188 class ArrayType : TypeNode |
95 | 189 { |
106 | 190 Expression e, e2; |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
191 TypeNode assocType; |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
192 |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
193 this(TypeNode t) |
95 | 194 { |
135 | 195 super(TID.Array, t); |
281 | 196 mixin(set_kind); |
106 | 197 } |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
198 |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
199 this(TypeNode t, Expression e, Expression e2) |
106 | 200 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
201 addChild(e); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
202 addOptChild(e2); |
95 | 203 this.e = e; |
106 | 204 this.e2 = e2; |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
205 this(t); |
106 | 206 } |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
207 |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
208 this(TypeNode t, TypeNode assocType) |
106 | 209 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
210 addChild(assocType); |
295
75b47c71a34c
- Assigning to Node.children in several constructors that inherit from Node.
aziz
parents:
291
diff
changeset
|
211 this.assocType = assocType; |
106 | 212 this(t); |
95 | 213 } |
214 } | |
100 | 215 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
216 /// ReturnType "function" "(" Parameters? ")" |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
217 class FunctionType : TypeNode |
130 | 218 { |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
219 TypeNode returnType; |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
220 Parameters params; |
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
221 this(TypeNode returnType, Parameters params) |
130 | 222 { |
279 | 223 super(TID.Function); |
281 | 224 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
225 addChild(returnType); |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
226 addChild(params); |
130 | 227 this.returnType = returnType; |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
228 this.params = params; |
130 | 229 } |
230 } | |
135 | 231 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
232 /// ReturnType "delegate" "(" Parameters? ")" |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
233 class DelegateType : TypeNode |
135 | 234 { |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
235 TypeNode returnType; |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
236 Parameters params; |
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
237 this(TypeNode returnType, Parameters params) |
135 | 238 { |
291
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
239 super(TID.Delegate); |
281 | 240 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
241 addChild(returnType); |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
242 addChild(params); |
291
c0e857931ff6
- Changed FunctionType and DelegateType. Both receive return type and parameters.
aziz
parents:
281
diff
changeset
|
243 this.returnType = returnType; |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
244 this.params = params; |
135 | 245 } |
246 } | |
269 | 247 |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
248 /// Type "(" BasicType2 Identifier ")" "(" Parameters? ")" |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
249 class CFuncPointerType : TypeNode |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
250 { |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
251 Parameters params; |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
252 this(TypeNode type, Parameters params) |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
253 { |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
254 super(TID.CFuncPointer, type); |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
255 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
256 addOptChild(params); |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
257 } |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
258 } |
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
376
diff
changeset
|
259 |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
260 /// "class" Identifier : BaseClasses |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
667
diff
changeset
|
261 class BaseClassType : TypeNode |
655
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
262 { |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
263 Protection prot; |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
264 this(Protection prot, TypeNode type) |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
265 { |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
266 super(TID.BaseClass, type); |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
267 mixin(set_kind); |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
268 this.prot = prot; |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
269 } |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
270 } |
0acc43b86bf2
Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
271 |
635 | 272 // version(D2) |
273 // { | |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
274 /// "const" "(" Type ")" |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
275 class ConstType : TypeNode |
269 | 276 { |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
277 this(TypeNode t) |
269 | 278 { |
279 // If t is null: cast(const) | |
280 super(TID.Const, t); | |
281 | 281 mixin(set_kind); |
269 | 282 } |
283 } | |
284 | |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
285 /// "invariant" "(" Type ")" |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
286 class InvariantType : TypeNode |
269 | 287 { |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
288 this(TypeNode t) |
269 | 289 { |
290 // If t is null: cast(invariant) | |
291 super(TID.Invariant, t); | |
281 | 292 mixin(set_kind); |
269 | 293 } |
294 } | |
635 | 295 // } // version(D2) |