annotate dmd/TypeBasic.d @ 96:acd69f84627e

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