annotate trunk/src/dil/ast/Types.d @ 769:5e3ef1b2011c

Added and improved documentation.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 17 Feb 2008 02:21:55 +0100
parents 65ad2f96df1f
children 5fe89bb8cbdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94
0fe650a7a8d1 - Renamed Type enum to InfoType in module Information.
aziz
parents:
diff changeset
1 /++
0fe650a7a8d1 - Renamed Type enum to InfoType in module Information.
aziz
parents:
diff changeset
2 Author: Aziz Köksal
249
32d354584b28 - Upgraded license notices to GPL3.
aziz
parents: 248
diff changeset
3 License: GPL3
94
0fe650a7a8d1 - Renamed Type enum to InfoType in module Information.
aziz
parents:
diff changeset
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
701
65ad2f96df1f Moved TypeNode to new module dil.ast.Type.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 694
diff changeset
7 public import dil.ast.Type;
580
fa6d3c52757d Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 562
diff changeset
8 import dil.ast.Node;
659
304331ca2f95 Renamed EmptyExpression to IllegalExpression.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 655
diff changeset
9 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
10 import dil.ast.Parameters;
600
041eae272362 Moved dil.Identifier to dil.lexer.Identifier.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
11 import dil.lexer.Identifier;
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
12 import dil.semantic.Types;
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
13 import dil.Enums;
135
145e0d68ec95 - Added enum TID to module Type.
aziz
parents: 134
diff changeset
14
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
15 /// Syntax error.
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
16 class IllegalType : TypeNode
134
a31aa0d6dd5e - Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents: 130
diff changeset
17 {
a31aa0d6dd5e - Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents: 130
diff changeset
18 this()
a31aa0d6dd5e - Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents: 130
diff changeset
19 {
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
20 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
21 }
a31aa0d6dd5e - Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents: 130
diff changeset
22 }
a31aa0d6dd5e - Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents: 130
diff changeset
23
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
24 /// char, int, float etc.
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
25 class IntegralType : TypeNode
153
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
26 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
27 TOK tok;
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
28 this(TOK tok)
153
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
29 {
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
30 mixin(set_kind);
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
31 this.tok = tok;
153
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
32 }
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
33 }
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
34
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
35 /// Identifier
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
36 class IdentifierType : TypeNode
154
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
37 {
505
3bb94ba21490 Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 495
diff changeset
38 Identifier* ident;
3bb94ba21490 Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 495
diff changeset
39 this(Identifier* ident)
154
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
40 {
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
41 mixin(set_kind);
154
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
42 this.ident = ident;
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
43 }
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
44 }
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
45
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
46 /// Type "." Type
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
47 class QualifiedType : TypeNode
488
cfb3805768b6 Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 409
diff changeset
48 {
694
19a34b69cc7d Renamed some members of BinaryExpression and QualifiedType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 689
diff changeset
49 alias next lhs; /// Left-hand side type.
19a34b69cc7d Renamed some members of BinaryExpression and QualifiedType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 689
diff changeset
50 TypeNode rhs; /// Right-hand side type.
19a34b69cc7d Renamed some members of BinaryExpression and QualifiedType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 689
diff changeset
51 this(TypeNode lhs, TypeNode rhs)
488
cfb3805768b6 Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 409
diff changeset
52 {
694
19a34b69cc7d Renamed some members of BinaryExpression and QualifiedType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 689
diff changeset
53 super(lhs);
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 668
diff changeset
54 mixin(set_kind);
694
19a34b69cc7d Renamed some members of BinaryExpression and QualifiedType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 689
diff changeset
55 addChild(rhs);
19a34b69cc7d Renamed some members of BinaryExpression and QualifiedType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 689
diff changeset
56 this.rhs = rhs;
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
57 }
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
58 }
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
59
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
60 /// "." Type
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
61 class ModuleScopeType : TypeNode
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
62 {
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
63 this(TypeNode next)
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 608
diff changeset
64 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
65 super(next);
488
cfb3805768b6 Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 409
diff changeset
66 mixin(set_kind);
cfb3805768b6 Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 409
diff changeset
67 }
cfb3805768b6 Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 409
diff changeset
68 }
cfb3805768b6 Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 409
diff changeset
69
769
5e3ef1b2011c Added and improved documentation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 701
diff changeset
70 /// "typeof" "(" Expression ")" or$(BR)
5e3ef1b2011c Added and improved documentation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 701
diff changeset
71 /// "typeof" "(" "return" ")" (D2.0)
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
72 class TypeofType : TypeNode
154
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
73 {
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
74 Expression e;
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
75 this(Expression e)
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
76 {
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
77 this();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
78 addChild(e);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
79 this.e = e;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
80 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
81
769
5e3ef1b2011c Added and improved documentation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 701
diff changeset
82 // For 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
83 this()
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
84 {
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
85 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
86 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
87
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
88 bool isTypeofReturn()
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
89 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
90 return e is null;
154
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
91 }
0e7cefb15e43 - Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents: 153
diff changeset
92 }
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
93
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 668
diff changeset
94 /// Identifier "!" "(" TemplateParameters? ")"
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
95 class TemplateInstanceType : TypeNode
153
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
96 {
505
3bb94ba21490 Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 495
diff changeset
97 Identifier* ident;
153
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
98 TemplateArguments targs;
505
3bb94ba21490 Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 495
diff changeset
99 this(Identifier* ident, TemplateArguments targs)
153
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
100 {
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
101 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
102 addOptChild(targs);
153
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
103 this.ident = ident;
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
104 this.targs = targs;
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
105 }
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
106 }
66790fc2c0a2 - Added method parseIdentifierListType().
aziz
parents: 150
diff changeset
107
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 668
diff changeset
108 /// Type *
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
109 class PointerType : TypeNode
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
110 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
111 this(TypeNode next)
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
112 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
113 super(next);
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
114 mixin(set_kind);
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
115 }
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
116 }
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
117
769
5e3ef1b2011c Added and improved documentation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 701
diff changeset
118 /// Dynamic array: T[] or$(BR)
5e3ef1b2011c Added and improved documentation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 701
diff changeset
119 /// Static array: T[E] or$(BR)
5e3ef1b2011c Added and improved documentation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 701
diff changeset
120 /// Slice array (for tuples): T[E..E] or$(BR)
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
121 /// Associative array: T[T]
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
122 class ArrayType : TypeNode
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
123 {
689
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
124 Expression e1, e2;
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
125 TypeNode assocType;
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
126
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
127 this(TypeNode t)
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
128 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
129 super(t);
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
130 mixin(set_kind);
106
441962b0f526 - Added parseArrayType() method.
aziz
parents: 100
diff changeset
131 }
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
132
689
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
133 this(TypeNode t, Expression e1, Expression e2)
106
441962b0f526 - Added parseArrayType() method.
aziz
parents: 100
diff changeset
134 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
135 this(t);
689
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
136 addChild(e1);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
137 addOptChild(e2);
689
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
138 this.e1 = e1;
106
441962b0f526 - Added parseArrayType() method.
aziz
parents: 100
diff changeset
139 this.e2 = e2;
441962b0f526 - Added parseArrayType() method.
aziz
parents: 100
diff changeset
140 }
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
141
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
142 this(TypeNode t, TypeNode assocType)
106
441962b0f526 - Added parseArrayType() method.
aziz
parents: 100
diff changeset
143 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
144 this(t);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
145 addChild(assocType);
295
75b47c71a34c - Assigning to Node.children in several constructors that inherit from Node.
aziz
parents: 291
diff changeset
146 this.assocType = assocType;
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
147 }
689
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
148
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
149 bool isDynamic()
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
150 {
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
151 return !assocType && !e1;
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
152 }
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
153
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
154 bool isStatic()
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
155 {
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
156 return e1 && !e2;
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
157 }
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
158
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
159 bool isSlice()
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
160 {
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
161 return e1 && e2;
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
162 }
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
163
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
164 bool isAssociative()
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
165 {
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
166 return assocType !is null;
8e38774d562b Added some methods to ArrayType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
167 }
95
0eb4c8a5b32b - Added TOK.Invalid.
aziz
parents: 94
diff changeset
168 }
100
538e8b546669 - Added code for parsing IsExpressions.
aziz
parents: 95
diff changeset
169
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
170 /// ReturnType "function" "(" Parameters? ")"
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
171 class FunctionType : TypeNode
130
0467f01ed524 - Fix: parameters can have optional identifier.
aziz
parents: 117
diff changeset
172 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
173 alias next returnType;
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
174 Parameters params;
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
175 this(TypeNode returnType, Parameters params)
130
0467f01ed524 - Fix: parameters can have optional identifier.
aziz
parents: 117
diff changeset
176 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
177 super(returnType);
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
178 mixin(set_kind);
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
179 addChild(params);
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
180 this.params = params;
130
0467f01ed524 - Fix: parameters can have optional identifier.
aziz
parents: 117
diff changeset
181 }
0467f01ed524 - Fix: parameters can have optional identifier.
aziz
parents: 117
diff changeset
182 }
135
145e0d68ec95 - Added enum TID to module Type.
aziz
parents: 134
diff changeset
183
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
184 /// ReturnType "delegate" "(" Parameters? ")"
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
185 class DelegateType : TypeNode
135
145e0d68ec95 - Added enum TID to module Type.
aziz
parents: 134
diff changeset
186 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
187 alias next returnType;
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
188 Parameters params;
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
189 this(TypeNode returnType, Parameters params)
135
145e0d68ec95 - Added enum TID to module Type.
aziz
parents: 134
diff changeset
190 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
191 super(returnType);
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
192 mixin(set_kind);
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
193 addChild(params);
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
194 this.params = params;
135
145e0d68ec95 - Added enum TID to module Type.
aziz
parents: 134
diff changeset
195 }
145e0d68ec95 - Added enum TID to module Type.
aziz
parents: 134
diff changeset
196 }
269
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
197
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 668
diff changeset
198 /// Type "(" BasicType2 Identifier ")" "(" Parameters? ")"
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
199 class CFuncPointerType : TypeNode
409
38fccd2640eb Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 376
diff changeset
200 {
38fccd2640eb Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 376
diff changeset
201 Parameters params;
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
202 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
203 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
204 super(type);
409
38fccd2640eb Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 376
diff changeset
205 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 488
diff changeset
206 addOptChild(params);
409
38fccd2640eb Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 376
diff changeset
207 }
38fccd2640eb Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 376
diff changeset
208 }
38fccd2640eb Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 376
diff changeset
209
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 668
diff changeset
210 /// "class" Identifier : BaseClasses
668
a1f8d8f2db38 Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 667
diff changeset
211 class BaseClassType : TypeNode
655
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
212 {
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
213 Protection prot;
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
214 this(Protection prot, TypeNode type)
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
215 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
216 super(type);
655
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
217 mixin(set_kind);
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
218 this.prot = prot;
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
219 }
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
220 }
0acc43b86bf2 Moved class BaseClass to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 648
diff changeset
221
635
b2fc028d8b55 Added class Visitor.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 618
diff changeset
222 // version(D2)
b2fc028d8b55 Added class Visitor.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 618
diff changeset
223 // {
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 668
diff changeset
224 /// "const" "(" Type ")"
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
225 class ConstType : TypeNode
269
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
226 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
227 this(TypeNode next)
269
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
228 {
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
229 // If t is null: cast(const)
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
230 super(next);
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
231 mixin(set_kind);
269
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
232 }
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
233 }
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
234
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 668
diff changeset
235 /// "invariant" "(" Type ")"
511
aa73f669c298 Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 505
diff changeset
236 class InvariantType : TypeNode
269
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
237 {
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
238 this(TypeNode next)
269
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
239 {
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
240 // If t is null: cast(invariant)
671
f1325a4506de Removed enum TID from dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
241 super(next);
281
c1fcfbce9499 - BaseClass inherits from Node now.
aziz
parents: 280
diff changeset
242 mixin(set_kind);
269
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
243 }
a416e09c08ea - Implemented D 2.0 additions.
aziz
parents: 264
diff changeset
244 }
635
b2fc028d8b55 Added class Visitor.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 618
diff changeset
245 // } // version(D2)