annotate dmd/CastExp.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 832f71e6f96c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.CastExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.TypeStruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TypeExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.DotIdExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.CallExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.BinExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.UnaExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Token;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.InterState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.IntRange;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.ClassDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 import dmd.Optimize;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import dmd.PREC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 import dmd.Cast;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 import dmd.expression.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 import dmd.backend.OPER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 import dmd.codegen.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 import dmd.backend.RTLSYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 class CastExp : UnaExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 // Possible to cast to one type while painting to another type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 Type to; // type to cast to
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 MOD mod; // MODxxxxx
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 this(Loc loc, Expression e, Type t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 super(loc, TOK.TOKcast, CastExp.sizeof, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 to = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 this.mod = cast(MOD)~0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 this(Loc loc, Expression e, MOD mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 super(loc, TOK.TOKcast, CastExp.sizeof, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 to = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 this.mod = mod;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 Expression syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 return to ? new CastExp(loc, e1.syntaxCopy(), to.syntaxCopy())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 : new CastExp(loc, e1.syntaxCopy(), mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Expression semantic(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 BinExp b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 UnaExp u;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 version (LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 printf("CastExp.semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 //static int x; assert(++x < 10);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 if (type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 super.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 if (e1.type) // if not a tuple
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 e1 = resolveProperties(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 if (!to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 /* Handle cast(const) and cast(immutable), etc.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 to = e1.type.castMod(mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 to = to.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 if (!to.equals(e1.type))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 return e.implicitCastTo(sc, to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 Type t1b = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 Type tob = to.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 if (tob.ty == TY.Tstruct &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 !tob.equals(t1b) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 (cast(TypeStruct)tob).sym.search(Loc(0), Id.call, 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 /* Look to replace:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 * cast(S)t
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 * with:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 * S(t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 // Rewrite as to.call(e1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 e = new TypeExp(loc, to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 e = new DotIdExp(loc, e, Id.call);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 e = new CallExp(loc, e, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 else if (!to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 { error("cannot cast tuple");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 to = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 if (global.params.safe && !sc.module_.safe && !sc.intypeof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 { // Disallow unsafe casts
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 Type tob = to.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 Type t1b = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 if (!t1b.isMutable() && tob.isMutable())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 { // Cast not mutable to mutable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 Lunsafe:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 error("cast from %s to %s not allowed in safe mode", e1.type.toChars(), to.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 else if (t1b.isShared() && !tob.isShared())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 // Cast away shared
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 goto Lunsafe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 else if (tob.ty == TY.Tpointer)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 { if (t1b.ty != TY.Tpointer)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 goto Lunsafe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 Type tobn = tob.nextOf().toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 Type t1bn = t1b.nextOf().toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 if (!t1bn.isMutable() && tobn.isMutable())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 // Cast away pointer to not mutable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 goto Lunsafe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 if (t1bn.isShared() && !tobn.isShared())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 // Cast away pointer to shared
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 goto Lunsafe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 if (tobn.isTypeBasic() && tobn.size() < t1bn.size()) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 // Allow things like casting a long* to an int*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 } else if (tobn.ty != TY.Tvoid) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 // Cast to a pointer other than void*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 goto Lunsafe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 // BUG: Check for casting array types, such as void[] to int*[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 e = e1.castTo(sc, to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 MATCH implicitConvTo(Type t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 printf("CastExp::implicitConvTo(this=%s, type=%s, t=%s)\n", toChars(), type.toChars(), t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 MATCH result = type.implicitConvTo(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 if (result == MATCHnomatch)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 if (t.isintegral() &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 e1.type.isintegral() &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 e1.implicitConvTo(t) != MATCHnomatch)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 result = MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 result = Expression.implicitConvTo(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 return result;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 IntRange getIntRange()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 Expression optimize(int result)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 //printf("CastExp.optimize(result = %d) %s\n", result, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 //printf("from %s to %s\n", type.toChars(), to.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 //printf("from %s\n", type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 //printf("e1.type %s\n", e1.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 //printf("type = %p\n", type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 assert(type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 TOK op1 = e1.op;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 Expression e1old = e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 e1 = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 e1 = fromConstInitializer(result, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 if (e1 == e1old &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 e1.op == TOK.TOKarrayliteral &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 type.toBasetype().ty == TY.Tpointer &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 e1.type.toBasetype().ty != TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 // Casting this will result in the same expression, and
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 // infinite loop because of Expression.implicitCastTo()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 return this; // no change
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 if ((e1.op == TOK.TOKstring || e1.op == TOK.TOKarrayliteral) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 (type.ty == TY.Tpointer || type.ty == TY.Tarray) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 e1.type.nextOf().size() == type.nextOf().size()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 Expression e = e1.castTo(null, type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 printf(" returning1 %s\n", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 if (e1.op == TOK.TOKstructliteral &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 e1.type.implicitConvTo(type) >= MATCH.MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 printf(" returning2 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 /* The first test here is to prevent infinite loops
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 if (op1 != TOK.TOKarrayliteral && e1.op == TOK.TOKarrayliteral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 return e1.castTo(null, to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 if (e1.op == TOK.TOKnull &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 (type.ty == TY.Tpointer || type.ty == TY.Tclass || type.ty == TY.Tarray))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 printf(" returning3 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 if (result & WANT.WANTflags && type.ty == TY.Tclass && e1.type.ty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 // See if we can remove an unnecessary cast
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 ClassDeclaration cdfrom;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 ClassDeclaration cdto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 int offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 cdfrom = e1.type.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 cdto = type.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 if (cdto.isBaseOf(cdfrom, &offset) && offset == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 printf(" returning4 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 // We can convert 'head const' to mutable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 if (to.constOf().equals(e1.type.constOf()))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 // if (to.constConv(e1.type) >= MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 printf(" returning5 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 if (e1.isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 if (e1.op == TOK.TOKsymoff)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 if (type.size() == e1.type.size() &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 type.toBasetype().ty != TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 if (to.toBasetype().ty == TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 e = Cast(type, to, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 printf(" returning6 %s\n", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 Expression interpret(InterState* istate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 bool checkSideEffect(int flag)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 void checkEscape()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 Type tb = type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 if (tb.ty == TY.Tarray && e1.op == TOK.TOKvar && e1.type.toBasetype().ty ==TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 VarExp ve = cast(VarExp)e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 VarDeclaration v = ve.var.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 if (v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 if (!v.isDataseg() && !v.isParameter())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 error("escaping reference to local %s", v.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 buf.writestring("cast(");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 version (DMDV1) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 to.toCBuffer(buf, null, hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 if (to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 to.toCBuffer(buf, null, hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 switch (mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 case MODundefined:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 case MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 buf.writestring(Token.tochars[TOKconst]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 case MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 buf.writestring(Token.tochars[TOKimmutable]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 case MODshared:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 buf.writestring(Token.tochars[TOKshared]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 case MODshared | MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 buf.writestring(Token.tochars[TOKshared]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 buf.writeByte(' ');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 buf.writestring(Token.tochars[TOKconst]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 buf.writeByte(')');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 expToCBuffer(buf, hgs, e1, precedence[op]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 void buildArrayIdent(OutBuffer buf, Expressions arguments)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 Expression buildArrayLoop(Arguments fparams)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 static int X(int fty, int tty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 return ((fty) * TY.TMAX + (tty));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 elem* toElem(IRState* irs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 elem* e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 TY fty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 TY tty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 tym_t ftym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 tym_t ttym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 OPER eop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 Type tfrom;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 printf("CastExp::toElem()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 printf("\tfrom: %s\n", e1.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 printf("\tto : %s\n", to.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 e = e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 tfrom = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 t = to.toBasetype(); // skip over typedef's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 if (t.equals(tfrom))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 fty = tfrom.ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 //printf("fty = %d\n", fty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 tty = t.ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 if (tty == TY.Tpointer && fty == TY.Tarray
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 ///static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 /// && (t.next.ty == Tvoid || t.next.equals(e1.type.next))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 if (e.Eoper == OPER.OPvar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 // e1 . *(&e1 + 4)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 e = el_una(OPER.OPaddr, TYM.TYnptr, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 e = el_bin(OPER.OPadd, TYM.TYnptr, e, el_long(TYM.TYint, 4));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 e = el_una(OPER.OPind, t.totym(),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 // e1 . (unsigned)(e1 >> 32)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 e = el_bin(OPER.OPshr, TYM.TYullong, e, el_long(TYM.TYint, 32));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 e = el_una(OPER.OP64_32, t.totym(), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 if (tty == TY.Tpointer && fty == TY.Tsarray
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 ///static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 /// && (t.next.ty == Tvoid || t.next.equals(e1.type.next))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 // e1 . &e1
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 e = el_una(OPER.OPaddr, TYM.TYnptr, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 // Convert from static array to dynamic array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 if (tty == TY.Tarray && fty == TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 e = sarray_toDarray(loc, tfrom, t, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 // Convert from dynamic array to dynamic array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 if (tty == TY.Tarray && fty == TY.Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 uint fsize = cast(uint)tfrom.nextOf().size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 uint tsize = cast(uint)t.nextOf().size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 if (fsize != tsize)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 elem* ep = el_params(e, el_long(TYM.TYint, fsize), el_long(TYM.TYint, tsize), null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 e = el_bin(OPER.OPcall, type.totym(), el_var(rtlsym[RTLSYM.RTLSYM_ARRAYCAST]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 // Convert from dynamic array string literal to static array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 if (tty == TY.Tsarray && fty == TY.Tarray && e1.op == TOK.TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 goto Lret; // treat as a 'paint'
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 // Casting from base class to derived class requires a runtime check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 if (fty == TY.Tclass && tty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 // Casting from derived class to base class is a no-op
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 ClassDeclaration cdfrom;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 ClassDeclaration cdto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 int offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 int rtl = RTLSYM.RTLSYM_DYNAMIC_CAST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 cdfrom = tfrom.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 cdto = t.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 if (cdfrom.isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 rtl = RTLSYM.RTLSYM_INTERFACE_CAST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 if (cdfrom.isCPPinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 if (cdto.isCPPinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 /* Casting from a C++ interface to a C++ interface
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 * is always a 'paint' operation
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 goto Lret; // no-op
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 /* Casting from a C++ interface to a class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 * always results in null because there is no runtime
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 * information available to do it.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 *
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 * Casting from a C++ interface to a non-C++ interface
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 * always results in null because there's no way one
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 * can be derived from the other.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 e = el_bin(OPER.OPcomma, TYM.TYnptr, e, el_long(TYM.TYnptr, 0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 if (cdto.isBaseOf(cdfrom, &offset) && offset != OFFSET_RUNTIME)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 /* The offset from cdfrom=>cdto is known at compile time.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 //printf("offset = %d\n", offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 if (offset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 /* Rewrite cast as (e ? e + offset : null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 elem* etmp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 elem* ex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 if (e1.op == TOK.TOKthis)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 // Assume 'this' is never null, so skip null check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 e = el_bin(OPER.OPadd, TYM.TYnptr, e, el_long(TYM.TYint, offset));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 etmp = el_same(&e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 ex = el_bin(OPER.OPadd, TYM.TYnptr, etmp, el_long(TYM.TYint, offset));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541 ex = el_bin(OPER.OPcolon, TYM.TYnptr, ex, el_long(TYM.TYnptr, 0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 e = el_bin(OPER.OPcond, TYM.TYnptr, e, ex);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 goto Lret; // no-op
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 /* The offset from cdfrom=>cdto can only be determined at runtime.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 elem* ep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 ep = el_param(el_ptr(cdto.toSymbol()), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 e = el_bin(OPER.OPcall, TYM.TYnptr, el_var(rtlsym[rtl]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 ftym = e.Ety;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 ttym = t.totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559 if (ftym == ttym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 switch (tty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564 case TY.Tpointer:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565 if (fty == TY.Tdelegate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 tty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 tty = TY.Tuns8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 tty = TY.Tuns16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 tty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 case TY.Tbool:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 // Construct e?true:false
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 elem* eq;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587 e = el_una(OPER.OPbool, ttym, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
589 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
590
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
591 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
592 break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
593 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 switch (fty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
596 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597 case TY.Tpointer: fty = TY.Tuns32; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598 case TY.Tchar: fty = TY.Tuns8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 case TY.Twchar: fty = TY.Tuns16; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600 case TY.Tdchar: fty = TY.Tuns32; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 default: break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
602 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604 Lagain:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605 switch (X(fty,tty))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
607 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608 case X(TY.Tbit,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
609 case X(TY.Tbit,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611 case X(TY.Tbit,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612 case X(TY.Tbit,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613 case X(TY.Tbit,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 case X(TY.Tbit,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 eop = OPu8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
617 case X(TY.Tbit,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618 case X(TY.Tbit,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 case X(TY.Tbit,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 case X(TY.Tbit,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 case X(TY.Tbit,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622 case X(TY.Tbit,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 case X(TY.Tbit,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
624 case X(TY.Tbit,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 e = el_una(OPER.OPu8_16, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628 case X(Tbit,Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 case X(Tbit,Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 case X(Tbit,Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
632 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 case X(TY.Tbool,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 case X(TY.Tbool,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 case X(TY.Tbool,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639 case X(TY.Tbool,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 case X(TY.Tbool,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 case X(TY.Tbool,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 eop = OPER.OPu8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 case X(TY.Tbool,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 case X(TY.Tbool,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646 case X(TY.Tbool,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 case X(TY.Tbool,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 case X(TY.Tbool,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 case X(TY.Tbool,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 case X(TY.Tbool,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651 case X(TY.Tbool,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 e = el_una(OPER.OPu8_16, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 case X(TY.Tbool,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 case X(TY.Tbool,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 case X(TY.Tbool,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 case X(TY.Tint8,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 case X(TY.Tint8,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 case X(TY.Tint8,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 case X(TY.Tint8,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 case X(TY.Tint8,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 eop = OPER.OPs8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 case X(TY.Tint8,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 case X(TY.Tint8,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 case X(TY.Tint8,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673 case X(TY.Tint8,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 case X(TY.Tint8,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 case X(TY.Tint8,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 case X(TY.Tint8,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 case X(TY.Tint8,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 e = el_una(OPER.OPs8_16, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 case X(TY.Tint8,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682 case X(TY.Tint8,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 case X(TY.Tint8,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 case X(TY.Tuns8,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
690 case X(TY.Tuns8,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
691 case X(TY.Tuns8,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692 case X(TY.Tuns8,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693 case X(TY.Tuns8,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 eop = OPER.OPu8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 case X(TY.Tuns8,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 case X(TY.Tuns8,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 case X(TY.Tuns8,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 case X(TY.Tuns8,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 case X(TY.Tuns8,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701 case X(TY.Tuns8,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 case X(TY.Tuns8,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 case X(TY.Tuns8,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 e = el_una(OPER.OPu8_16, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 case X(TY.Tuns8,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 case X(TY.Tuns8,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 case X(TY.Tuns8,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 case X(TY.Tint16,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 case X(TY.Tint16,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 eop = OPER.OP16_8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 case X(TY.Tint16,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 case X(TY.Tint16,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721 case X(TY.Tint16,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 eop = OPER.OPs16_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 case X(TY.Tint16,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 case X(TY.Tint16,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 e = el_una(OPER.OPs16_32, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 case X(TY.Tint16,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 case X(TY.Tint16,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 case X(TY.Tint16,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 case X(TY.Tint16,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 case X(TY.Tint16,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 case X(TY.Tint16,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 e = el_una(OPER.OPs16_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 case X(TY.Tint16,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 case X(TY.Tint16,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 case X(TY.Tint16,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 case X(TY.Tuns16,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 case X(TY.Tuns16,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747 eop = OPER.OP16_8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749 case X(TY.Tuns16,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 case X(TY.Tuns16,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752 case X(TY.Tuns16,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 eop = OPER.OPu16_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 case X(TY.Tuns16,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 case X(TY.Tuns16,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757 case X(TY.Tuns16,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 case X(TY.Tuns16,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 case X(TY.Tuns16,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 case X(TY.Tuns16,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 case X(TY.Tuns16,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 case X(TY.Tuns16,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763 e = el_una(OPER.OPu16_32, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 case X(TY.Tuns16,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 case X(TY.Tuns16,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 case X(TY.Tuns16,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 case X(TY.Tint32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774 case X(TY.Tint32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775 e = el_una(OPER.OP32_16, TYM.TYshort, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 fty = TY.Tint16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778 case X(TY.Tint32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 case X(TY.Tint32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 eop = OPER.OP32_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 case X(TY.Tint32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 case X(TY.Tint32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 case X(TY.Tint32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 eop = OPER.OPs32_64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
788 case X(TY.Tint32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 case X(TY.Tint32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 case X(TY.Tint32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 case X(TY.Tint32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 case X(TY.Tint32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 case X(TY.Tint32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 e = el_una(OPER.OPs32_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 case X(TY.Tint32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798 case X(TY.Tint32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 case X(TY.Tint32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804 case X(TY.Tuns32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805 case X(TY.Tuns32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 e = el_una(OPER.OP32_16, TYM.TYshort, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
807 fty = TY.Tuns16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809 case X(TY.Tuns32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810 case X(TY.Tuns32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
811 eop = OPER.OP32_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
812 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
813 case X(TY.Tuns32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
814 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
815 case X(TY.Tuns32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
816 case X(TY.Tuns32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
817 eop = OPER.OPu32_64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
818 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
819 case X(TY.Tuns32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
820 case X(TY.Tuns32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
821 case X(TY.Tuns32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
822 case X(TY.Tuns32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
823 case X(TY.Tuns32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
824 case X(TY.Tuns32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
825 e = el_una(OPER.OPu32_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
826 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
827 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
828 case X(TY.Tuns32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
829 case X(TY.Tuns32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
830 case X(TY.Tuns32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
831 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
832
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
833 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
834
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
835 case X(TY.Tint64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
836 case X(TY.Tint64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
837 case X(TY.Tint64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
838 case X(TY.Tint64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
839 e = el_una(OPER.OP64_32, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
840 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
841 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
842 case X(TY.Tint64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
843 case X(TY.Tint64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
844 eop = OPER.OP64_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
845 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
846 case X(TY.Tint64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
847 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
848 case X(TY.Tint64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
849 case X(TY.Tint64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
850 case X(TY.Tint64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
851 case X(TY.Tint64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
852 case X(TY.Tint64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
853 case X(TY.Tint64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
854 e = el_una(OPER.OPs64_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
855 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
856 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
857 case X(TY.Tint64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
858 case X(TY.Tint64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
859 case X(TY.Tint64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
860 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
861
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
862 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
863
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
864 case X(TY.Tuns64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
865 case X(TY.Tuns64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
866 case X(TY.Tuns64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
867 case X(TY.Tuns64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
868 e = el_una(OPER.OP64_32, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
869 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
870 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
871 case X(TY.Tuns64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
872 case X(TY.Tuns64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
873 eop = OPER.OP64_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
874 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
875 case X(TY.Tuns64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
876 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
877 case X(TY.Tuns64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
878 case X(TY.Tuns64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
879 case X(TY.Tuns64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
880 case X(TY.Tuns64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
881 case X(TY.Tuns64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
882 case X(TY.Tuns64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
883 e = el_una(OPER.OPu64_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
884 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
885 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
886 case X(TY.Tuns64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
887 case X(TY.Tuns64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
888 case X(TY.Tuns64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
889 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
890
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
891 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
892
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
893 case X(TY.Tfloat32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
894 case X(TY.Tfloat32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
895 case X(TY.Tfloat32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
896 case X(TY.Tfloat32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
897 case X(TY.Tfloat32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
898 case X(TY.Tfloat32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
899 case X(TY.Tfloat32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
900 case X(TY.Tfloat32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
901 case X(TY.Tfloat32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
902 e = el_una(OPER.OPf_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
903 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
904 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
905 case X(TY.Tfloat32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
906 eop = OPER.OPf_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
907 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
908 case X(TY.Tfloat32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
909 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
910 case X(TY.Tfloat32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
911 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
912 case X(TY.Tfloat32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
913 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
914 case X(TY.Tfloat32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
915 case X(TY.Tfloat32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
916 case X(TY.Tfloat32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
917 e = el_bin(OPER.OPadd,TYM.TYcfloat,el_long(TYM.TYifloat,0),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
918 fty = TY.Tcomplex32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
919 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
920
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
921 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
922
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
923 case X(TY.Tfloat64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
924 case X(TY.Tfloat64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
925 e = el_una(OPER.OPd_s16, TYM.TYshort, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
926 fty = TY.Tint16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
927 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
928 case X(TY.Tfloat64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
929 eop = OPER.OPd_s16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
930 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
931 case X(TY.Tfloat64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
932 eop = OPER.OPd_u16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
933 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
934 case X(TY.Tfloat64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
935 eop = OPER.OPd_s32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
936 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
937 case X(TY.Tfloat64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
938 eop = OPER.OPd_u32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
939 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
940 case X(TY.Tfloat64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
941 eop = OPER.OPd_s64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
942 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
943 case X(TY.Tfloat64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
944 eop = OPER.OPd_u64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
945 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
946 case X(TY.Tfloat64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
947 eop = OPER.OPd_f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
948 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
949 case X(TY.Tfloat64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
950 eop = OPER.OPd_ld;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
951 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
952 case X(TY.Tfloat64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
953 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
954 case X(TY.Tfloat64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
955 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
956 case X(TY.Tfloat64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
957 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
958 case X(TY.Tfloat64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
959 case X(TY.Tfloat64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
960 case X(TY.Tfloat64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
961 e = el_bin(OPER.OPadd,TYM.TYcfloat,el_long(TYM.TYidouble,0),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
962 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
963 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
964
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
965 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
966
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
967 case X(TY.Tfloat80,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
968 case X(TY.Tfloat80,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
969 case X(TY.Tfloat80,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
970 case X(TY.Tfloat80,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
971 case X(TY.Tfloat80,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
972 case X(TY.Tfloat80,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
973 case X(TY.Tfloat80,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
974 case X(TY.Tfloat80,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
975 e = el_una(OPER.OPld_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
976 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
977 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
978 case X(TY.Tfloat80,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
979 eop = OPER.OPld_u64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
980 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
981 case X(TY.Tfloat80,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
982 eop = OPER.OPld_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
983 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
984 case X(TY.Tfloat80,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
985 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
986 case X(TY.Tfloat80,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
987 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
988 case X(TY.Tfloat80,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
989 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
990 case X(TY.Tfloat80,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
991 case X(TY.Tfloat80,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
992 case X(TY.Tfloat80,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
993 e = el_bin(OPER.OPadd,TYM.TYcldouble,e,el_long(TYM.TYildouble,0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
994 fty = TY.Tcomplex80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
995 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
996
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
997 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
998
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
999 case X(TY.Timaginary32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1000 case X(TY.Timaginary32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1001 case X(TY.Timaginary32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1002 case X(TY.Timaginary32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1003 case X(TY.Timaginary32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1004 case X(TY.Timaginary32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1005 case X(TY.Timaginary32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1006 case X(TY.Timaginary32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1007 case X(TY.Timaginary32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1008 case X(TY.Timaginary32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1009 case X(TY.Timaginary32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1010 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1011 case X(TY.Timaginary32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1012 eop = OPER.OPf_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1013 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1014 case X(TY.Timaginary32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1015 e = el_una(OPER.OPf_d, TYM.TYidouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1016 fty = TY.Timaginary64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1017 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1018 case X(TY.Timaginary32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1019 case X(TY.Timaginary32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1020 case X(TY.Timaginary32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1021 e = el_bin(OPER.OPadd,TYM.TYcfloat,el_long(TYM.TYfloat,0),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1022 fty = TY.Tcomplex32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1023 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1024
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1025 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1026
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1027 case X(TY.Timaginary64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1028 case X(TY.Timaginary64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1029 case X(TY.Timaginary64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1030 case X(TY.Timaginary64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1031 case X(TY.Timaginary64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1032 case X(TY.Timaginary64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1033 case X(TY.Timaginary64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1034 case X(TY.Timaginary64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1035 case X(TY.Timaginary64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1036 case X(TY.Timaginary64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1037 case X(TY.Timaginary64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1038 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1039 case X(TY.Timaginary64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1040 eop = OPER.OPd_f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1041 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1042 case X(TY.Timaginary64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1043 eop = OPER.OPd_ld;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1044 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1045 case X(TY.Timaginary64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1046 case X(TY.Timaginary64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1047 case X(TY.Timaginary64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1048 e = el_bin(OPER.OPadd, TYM.TYcdouble, el_long(TYM.TYdouble,0), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1049 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1050 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1051
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1052 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1053
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1054 case X(TY.Timaginary80,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1055 case X(TY.Timaginary80,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1056 case X(TY.Timaginary80,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1057 case X(TY.Timaginary80,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1058 case X(TY.Timaginary80,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1059 case X(TY.Timaginary80,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1060 case X(TY.Timaginary80,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1061 case X(TY.Timaginary80,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1062 case X(TY.Timaginary80,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1063 case X(TY.Timaginary80,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1064 case X(TY.Timaginary80,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1065 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1066 case X(TY.Timaginary80,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1067 e = el_una(OPER.OPf_d, TYM.TYidouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1068 fty = TY.Timaginary64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1069 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1070 case X(TY.Timaginary80,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1071 eop = OPER.OPld_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1072 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1073 case X(TY.Timaginary80,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1074 case X(TY.Timaginary80,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1075 case X(TY.Timaginary80,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1076 e = el_bin(OPER.OPadd, TYM.TYcldouble, el_long(TYM.TYldouble,0), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1077 fty = TY.Tcomplex80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1078 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1079
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1080 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1081
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1082 case X(TY.Tcomplex32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1083 case X(TY.Tcomplex32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1084 case X(TY.Tcomplex32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1085 case X(TY.Tcomplex32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1086 case X(TY.Tcomplex32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1087 case X(TY.Tcomplex32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1088 case X(TY.Tcomplex32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1089 case X(TY.Tcomplex32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1090 case X(TY.Tcomplex32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1091 case X(TY.Tcomplex32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1092 case X(TY.Tcomplex32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1093 e = el_una(OPER.OPc_r, TYM.TYfloat, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1094 fty = TY.Tfloat32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1095 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1096 case X(TY.Tcomplex32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1097 case X(TY.Tcomplex32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1098 case X(TY.Tcomplex32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1099 e = el_una(OPER.OPc_i, TYM.TYifloat, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1100 fty = TY.Timaginary32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1101 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1102 case X(TY.Tcomplex32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1103 case X(TY.Tcomplex32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1104 e = el_una(OPER.OPf_d, TYM.TYcdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1105 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1106 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1107
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1108 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1109
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1110 case X(TY.Tcomplex64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1111 case X(TY.Tcomplex64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1112 case X(TY.Tcomplex64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1113 case X(TY.Tcomplex64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1114 case X(TY.Tcomplex64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1115 case X(TY.Tcomplex64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1116 case X(TY.Tcomplex64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1117 case X(TY.Tcomplex64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1118 case X(TY.Tcomplex64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1119 case X(TY.Tcomplex64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1120 case X(TY.Tcomplex64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1121 e = el_una(OPER.OPc_r, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1122 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1123 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1124 case X(TY.Tcomplex64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1125 case X(TY.Tcomplex64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1126 case X(TY.Tcomplex64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1127 e = el_una(OPER.OPc_i, TYM.TYidouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1128 fty = TY.Timaginary64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1129 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1130 case X(TY.Tcomplex64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1131 eop = OPER.OPd_f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1132 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1133 case X(TY.Tcomplex64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1134 eop = OPER.OPd_ld;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1135 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1136
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1137 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1138
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1139 case X(TY.Tcomplex80,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1140 case X(TY.Tcomplex80,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1141 case X(TY.Tcomplex80,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1142 case X(TY.Tcomplex80,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1143 case X(TY.Tcomplex80,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1144 case X(TY.Tcomplex80,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1145 case X(TY.Tcomplex80,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1146 case X(TY.Tcomplex80,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1147 case X(TY.Tcomplex80,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1148 case X(TY.Tcomplex80,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1149 case X(TY.Tcomplex80,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1150 e = el_una(OPER.OPc_r, TYM.TYldouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1151 fty = TY.Tfloat80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1152 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1153 case X(TY.Tcomplex80,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1154 case X(TY.Tcomplex80,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1155 case X(TY.Tcomplex80,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1156 e = el_una(OPER.OPc_i, TYM.TYildouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1157 fty = TY.Timaginary80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1158 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1159 case X(TY.Tcomplex80,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1160 case X(TY.Tcomplex80,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1161 e = el_una(OPER.OPld_d, TYM.TYcdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1162 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1163 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1164
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1165 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1166
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1167 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1168 if (fty == tty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1169 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1170 //dump(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1171 //printf("fty = %d, tty = %d\n", fty, tty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1172 error("e2ir: cannot cast from %s to %s", e1.type.toChars(), t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1173 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1174
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1175 Lzero:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1176 e = el_long(ttym, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1177 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1178
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1179 Lpaint:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1180 e.Ety = ttym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1181 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1182
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1183 Leop:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1184 e = el_una(eop, ttym, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1185 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1186 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1187 Lret:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1188 // Adjust for any type paints
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1189 t = type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1190 e.Ety = t.totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1191
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1192 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1193 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1194 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1195
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1196 Identifier opId()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1197 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1198 return Id.cast_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1199 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1200 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1201