annotate dmd/TypeBasic.d @ 187:b0d41ff5e0df

Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author Abscissa
date Tue, 07 Jun 2011 23:37:34 -0400
parents e3afd1303184
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TypeBasic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 96
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Token;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.TFLAGS;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.CppMangleState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.RealExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.ComplexExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.Port;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.Complex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
26 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
27
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 class TypeBasic : Type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
30 mixin insertMemberExtension!(typeof(this));
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
31
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 string dstring;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 uint flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 this(TY ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 157
diff changeset
37 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 super(ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 enum TFLAGSintegral = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 enum TFLAGSfloating = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 enum TFLAGSunsigned = 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 enum TFLAGSreal = 8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 enum TFLAGSimaginary = 0x10;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 enum TFLAGScomplex = 0x20;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 string d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 uint flags = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 case TY.Tvoid: d = Token.toChars(TOK.TOKvoid);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 case TY.Tint8: d = Token.toChars(TOK.TOKint8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 case TY.Tuns8: d = Token.toChars(TOK.TOKuns8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 case TY.Tint16: d = Token.toChars(TOK.TOKint16);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 case TY.Tuns16: d = Token.toChars(TOK.TOKuns16);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 case TY.Tint32: d = Token.toChars(TOK.TOKint32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 case TY.Tuns32: d = Token.toChars(TOK.TOKuns32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 case TY.Tfloat32: d = Token.toChars(TOK.TOKfloat32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 flags |= TFLAGSfloating | TFLAGSreal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 case TY.Tint64: d = Token.toChars(TOK.TOKint64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 case TY.Tuns64: d = Token.toChars(TOK.TOKuns64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 case TY.Tfloat64: d = Token.toChars(TOK.TOKfloat64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 flags |= TFLAGSfloating | TFLAGSreal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 case TY.Tfloat80: d = Token.toChars(TOK.TOKfloat80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 flags |= TFLAGSfloating | TFLAGSreal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 case TY.Timaginary32: d = Token.toChars(TOK.TOKimaginary32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 flags |= TFLAGSfloating | TFLAGSimaginary;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 case TY.Timaginary64: d = Token.toChars(TOK.TOKimaginary64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 flags |= TFLAGSfloating | TFLAGSimaginary;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 case TY.Timaginary80: d = Token.toChars(TOK.TOKimaginary80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 flags |= TFLAGSfloating | TFLAGSimaginary;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 case TY.Tcomplex32: d = Token.toChars(TOK.TOKcomplex32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 flags |= TFLAGSfloating | TFLAGScomplex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 case TY.Tcomplex64: d = Token.toChars(TOK.TOKcomplex64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 flags |= TFLAGSfloating | TFLAGScomplex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 case TY.Tcomplex80: d = Token.toChars(TOK.TOKcomplex80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 flags |= TFLAGSfloating | TFLAGScomplex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 case TY.Tbool: d = "bool";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 case TY.Tascii: d = Token.toChars(TOK.TOKchar);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 case TY.Twchar: d = Token.toChars(TOK.TOKwchar);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 case TY.Tdchar: d = Token.toChars(TOK.TOKdchar);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 break;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
138 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 this.dstring = d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 this.flags = flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
146 override Type syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 // No semantic analysis done on basic types, no need to copy
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
152 override ulong size(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 uint size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 //printf("TypeBasic.size()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 case TY.Tint8:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 case TY.Tuns8: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 case TY.Tint16:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 case TY.Tuns16: size = 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 case TY.Tint32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 case TY.Tuns32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 size = 4; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 case TY.Tint64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 case TY.Tuns64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 size = 8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 size = REALSIZE; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 size = 8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 size = 16; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 size = REALSIZE * 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 //size = Type.size(); // error message
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 size = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 case TY.Tbool: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 case TY.Tascii: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 case TY.Twchar: size = 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 case TY.Tdchar: size = 4; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 //printf("TypeBasic.size() = %d\n", size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 return size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
201 override uint alignsize()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 uint sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 sz = REALALIGNSIZE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
213 version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 case TY.Tint64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 case TY.Tuns64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 sz = 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 sz = cast(uint)size(Loc(0)); ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 return sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
232 override Expression getProperty(Loc loc, Identifier ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 long ivalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 real fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 //printf("TypeBasic.getProperty('%s')\n", ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 if (ident is Id.max)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 case TY.Tint8: ivalue = byte.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 case TY.Tuns8: ivalue = ubyte.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 case TY.Tint16: ivalue = short.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 case TY.Tuns16: ivalue = ushort.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 case TY.Tint32: ivalue = int.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 case TY.Tuns32: ivalue = uint.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 case TY.Tint64: ivalue = long.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 case TY.Tuns64: ivalue = ulong.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 case TY.Tbool: ivalue = bool.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 case TY.Tchar: ivalue = char.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 case TY.Twchar: ivalue = wchar.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 case TY.Tdchar: ivalue = 0x10FFFF; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 case TY.Tfloat32: fvalue = float.max; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 case TY.Tfloat64: fvalue = double.max;goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 case TY.Tfloat80: fvalue = real.max; goto Lfvalue;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
264 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 else if (ident is Id.min)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 case TY.Tint8: ivalue = byte.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 case TY.Tuns8: ivalue = ubyte.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 case TY.Tint16: ivalue = short.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 case TY.Tuns16: ivalue = ushort.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 case TY.Tint32: ivalue = int.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 case TY.Tuns32: ivalue = uint.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 case TY.Tint64: ivalue = long.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 case TY.Tuns64: ivalue = ulong.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 case TY.Tbool: ivalue = bool.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 case TY.Tchar: ivalue = char.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 case TY.Twchar: ivalue = wchar.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 case TY.Tdchar: ivalue = dchar.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 case TY.Timaginary32:
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
285 case Tfloat32:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
286 case Tcomplex64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
287 case Timaginary64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
288 case Tfloat64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
289 case Tcomplex80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
290 case Timaginary80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
291 case Tfloat80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
292 // For backwards compatibility - eventually, deprecate
acd69f84627e further work
Trass3r
parents: 72
diff changeset
293 goto Lmin_normal;
156
0c8cc2a10f99 + ArrayInitializer.toAssocArrayLiteral()
trass3r
parents: 134
diff changeset
294 default:
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
295 }
acd69f84627e further work
Trass3r
parents: 72
diff changeset
296 }
acd69f84627e further work
Trass3r
parents: 72
diff changeset
297 else if (ident == Id.min_normal)
acd69f84627e further work
Trass3r
parents: 72
diff changeset
298 {
acd69f84627e further work
Trass3r
parents: 72
diff changeset
299 Lmin_normal:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
300 switch (ty)
acd69f84627e further work
Trass3r
parents: 72
diff changeset
301 {
acd69f84627e further work
Trass3r
parents: 72
diff changeset
302 case Tcomplex32:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
303 case Timaginary32:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 case TY.Tfloat32: fvalue = float.min; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 case TY.Tfloat64: fvalue = double.min; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 case TY.Tfloat80: fvalue = real.min; goto Lfvalue;
134
4251f96733f4 Fix of the hopefully last regression with dmd2.037
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
311 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 else if (ident is Id.nan)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 fvalue = real.nan;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 }
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
331 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 else if (ident is Id.infinity)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 fvalue = real.infinity;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 goto Lfvalue;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
349 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 else if (ident is Id.dig)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 case TY.Tfloat32: ivalue = float.dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 case TY.Tfloat64: ivalue = double.dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 case TY.Tfloat80: ivalue = real.dig; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
365 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 else if (ident is Id.epsilon)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 case TY.Tfloat32: fvalue = float.epsilon; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 case TY.Tfloat64: fvalue = double.epsilon; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 case TY.Tfloat80: fvalue = real.epsilon; goto Lfvalue;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
381 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 else if (ident is Id.mant_dig)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 case TY.Tfloat32: ivalue = float.mant_dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 case TY.Tfloat64: ivalue = double.mant_dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 case TY.Tfloat80: ivalue = real.mant_dig; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
397 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 else if (ident is Id.max_10_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 case TY.Tfloat32: ivalue = float.max_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 case TY.Tfloat64: ivalue = double.max_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 case TY.Tfloat80: ivalue = real.max_10_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
413 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 else if (ident is Id.max_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 case TY.Tfloat32: ivalue = float.max_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 case TY.Tfloat64: ivalue = double.max_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 case TY.Tfloat80: ivalue = real.max_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
429 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 else if (ident is Id.min_10_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 case TY.Tfloat32: ivalue = float.min_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 case TY.Tfloat64: ivalue = double.min_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 case TY.Tfloat80: ivalue = real.min_10_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
445 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 else if (ident is Id.min_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 case TY.Tfloat32: ivalue = float.min_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 case TY.Tfloat64: ivalue = double.min_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 case TY.Tfloat80: ivalue = real.min_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
461 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 Ldefault:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 return Type.getProperty(loc, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 Livalue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 e = new IntegerExp(loc, ivalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 Lfvalue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 if (isreal() || isimaginary())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 e = new RealExp(loc, fvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 Complex!(real) cvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 cvalue.re = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 cvalue.im = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 //for (int i = 0; i < 20; i++)
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
482 // printf("%02x ", ((unsigned char *)&cvalue)[i]);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 //printf("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 e = new ComplexExp(loc, cvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 Lint:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 e = new IntegerExp(loc, ivalue, Type.tint32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
493 override Expression dotExp(Scope sc, Expression e, Identifier ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 printf("TypeBasic.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 if (ident is Id.re)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 case TY.Tcomplex32: t = tfloat32; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 case TY.Tcomplex64: t = tfloat64; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 case TY.Tcomplex80: t = tfloat80; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 L1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 e = e.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 case TY.Timaginary32: t = tfloat32; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 case TY.Timaginary64: t = tfloat64; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 case TY.Timaginary80: t = tfloat80; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 L2:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 e = new RealExp(Loc(0), 0.0, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
524 e = Type.getProperty(e.loc, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
525 break;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 else if (ident is Id.im)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 Type t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 case TY.Tcomplex32: t = timaginary32; t2 = tfloat32; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 case TY.Tcomplex64: t = timaginary64; t2 = tfloat64; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 case TY.Tcomplex80: t = timaginary80; t2 = tfloat80; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 L3:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 e = e.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 e.type = t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 case TY.Timaginary32: t = tfloat32; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 case TY.Timaginary64: t = tfloat64; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 case TY.Timaginary80: t = tfloat80; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 L4:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 e = e.copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 e.type = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 e = new RealExp(Loc(0), 0.0, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
557 e = Type.getProperty(e.loc, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
558 break;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 return Type.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
565 e = e.semantic(sc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
569 override string toChars()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 return Type.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
574 override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 //printf("TypeBasic.toCBuffer2(mod = %d, this.mod = %d)\n", mod, this.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 if (mod != this.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 toCBuffer3(buf, hgs, mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 buf.writestring(dstring);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586 void toCppMangle(OutBuffer buf, CppMangleState* cms)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
589 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
590 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
591 override bool isintegral()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
592 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
593 //printf("TypeBasic.isintegral('%s') x%x\n", toChars(), flags);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 return (flags & TFLAGS.TFLAGSintegral) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
596
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597 bool isbit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
602 override bool isfloating()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604 return (flags & TFLAGS.TFLAGSfloating) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
607 override bool isreal()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
609 return (flags & TFLAGS.TFLAGSreal) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
612 override bool isimaginary()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 return (flags & TFLAGS.TFLAGSimaginary) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
617 override bool iscomplex()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 return (flags & TFLAGS.TFLAGScomplex) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
622 override bool isscalar()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
624 return (flags & (TFLAGS.TFLAGSintegral | TFLAGS.TFLAGSfloating)) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
627 override bool isunsigned()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 return (flags & TFLAGS.TFLAGSunsigned) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
632 override MATCH implicitConvTo(Type to)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634 //printf("TypeBasic.implicitConvTo(%s) from %s\n", to.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 if (this is to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 return MATCH.MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639 if (ty is to.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 return (mod == to.mod) ? MATCH.MATCHexact : MATCH.MATCHconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 if (ty == TY.Tvoid || to.ty == TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 if (to.ty == TY.Tbool)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 if (!to.isTypeBasic())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 TypeBasic tob = cast(TypeBasic)to;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 if (flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 // Disallow implicit conversion of integers to imaginary or complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 if (tob.flags & (TFLAGS.TFLAGSimaginary | TFLAGS.TFLAGScomplex))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 // If converting from integral to integral
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661 if (1 && tob.flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 { ulong sz = size(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 ulong tosz = tob.size(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 /* Can't convert to smaller size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 if (sz > tosz)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 /* Can't change sign if same size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 /*if (sz == tosz && (flags ^ tob.flags) & TFLAGSunsigned)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673 return MATCH.MATCHnomatch;*/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 else if (flags & TFLAGS.TFLAGSfloating)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679 // Disallow implicit conversion of floating point to integer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 if (tob.flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 assert(tob.flags & TFLAGS.TFLAGSfloating);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685 // Disallow implicit conversion from complex to non-complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 if (flags & TFLAGS.TFLAGScomplex && !(tob.flags & TFLAGS.TFLAGScomplex))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 // Disallow implicit conversion of real or imaginary to complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
690 if (flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
691 tob.flags & TFLAGS.TFLAGScomplex)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 // Disallow implicit conversion to-from real and imaginary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 if ((flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary)) !=
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 (tob.flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary)))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 return MATCH.MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
702 override Expression defaultInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 long value = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 /*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 * Use a payload which is different from the machine NaN,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 * so that uninitialised variables can be
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 * detected even if exceptions are disabled.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 ushort[8] snan = [ 0, 0, 0, 0xA000, 0x7FFF, 0, 0, 0 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 /*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 * Although long doubles are 10 bytes long, some
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 * C ABIs pad them out to 12 or even 16 bytes, so
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 * leave enough space in the snan array.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 assert(REALSIZE <= snan.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 real fvalue = *cast(real*)snan.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 version (LOGDEFAULTINIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723 printf("TypeBasic.defaultInit() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 value = 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 value = 0xFFFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 return new RealExp(loc, fvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 return getProperty(loc, Id.nan);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 // Can't use fvalue + I*fvalue (the im part becomes a quiet NaN).
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 Complex!(real) cvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 cvalue.re = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 cvalue.im = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 return new ComplexExp(loc, cvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 return getProperty(loc, Id.nan);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 error(loc, "void does not have a default initializer");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 return new IntegerExp(loc, value, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
773 override bool isZeroInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
788 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 return false; // no
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 return true; // yes
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
797 override bool builtinTypeInfo()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 return mod ? false : true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 // For eliminating dynamic_cast
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
807 override TypeBasic isTypeBasic()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810 }
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
811 }