annotate dmd/CastExp.d @ 53:a8b50ff7f201

ForeachStatement.syntaxCopy SliceExp.syntaxCopy AnonDeclaration.syntaxCopy SwitchStatement.syntaxCopy CaseStatement.syntaxCopy BreakStatement.syntaxCopy ThrowStatement.syntaxCopy NewExp.syntaxCopy DefaultStatement.syntaxCopy AssertExp.syntaxCopy ClassDeclaration.syntaxCopy TypeTypedef.constConv eval_builtin ComplexExp.isConst DVCondition.syntaxCopy OrExp.getIntRange AndExp.getIntRange getMask IntegerExp.getIntRange Type.sizemask CastExp.getIntRange Expression.getIntRange
author korDen
date Sat, 21 Aug 2010 12:15:47 +0400
parents 832f71e6f96c
children cab4c37afb89
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 {
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
196 IntRange ir;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
197 ir = e1.getIntRange();
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
198 // Do sign extension
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
199 switch (e1.type.toBasetype().ty)
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
200 {
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
201 case Tint8:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
202 if (ir.imax & 0x80)
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
203 ir.imax |= 0xFFFFFFFFFFFFFF00UL;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
204 break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
205 case Tint16:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
206 if (ir.imax & 0x8000)
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
207 ir.imax |= 0xFFFFFFFFFFFF0000UL;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
208 break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
209 case Tint32:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
210 if (ir.imax & 0x80000000)
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
211 ir.imax |= 0xFFFFFFFF00000000UL;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
212 break;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
213 default:
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
214 }
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
215 ir.imin &= type.sizemask();
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
216 ir.imax &= type.sizemask();
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
217 //printf("CastExp: imin = x%llx, imax = x%llx\n", ir.imin, ir.imax);
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 12
diff changeset
218 return ir;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 Expression optimize(int result)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 //printf("CastExp.optimize(result = %d) %s\n", result, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 //printf("from %s to %s\n", type.toChars(), to.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 //printf("from %s\n", type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 //printf("e1.type %s\n", e1.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 //printf("type = %p\n", type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 assert(type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 TOK op1 = e1.op;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 Expression e1old = e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 e1 = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 e1 = fromConstInitializer(result, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 if (e1 == e1old &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 e1.op == TOK.TOKarrayliteral &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 type.toBasetype().ty == TY.Tpointer &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 e1.type.toBasetype().ty != TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 // Casting this will result in the same expression, and
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 // infinite loop because of Expression.implicitCastTo()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 return this; // no change
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 if ((e1.op == TOK.TOKstring || e1.op == TOK.TOKarrayliteral) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 (type.ty == TY.Tpointer || type.ty == TY.Tarray) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 e1.type.nextOf().size() == type.nextOf().size()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 Expression e = e1.castTo(null, type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 printf(" returning1 %s\n", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 if (e1.op == TOK.TOKstructliteral &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 e1.type.implicitConvTo(type) >= MATCH.MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 printf(" returning2 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 /* The first test here is to prevent infinite loops
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 if (op1 != TOK.TOKarrayliteral && e1.op == TOK.TOKarrayliteral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 return e1.castTo(null, to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 if (e1.op == TOK.TOKnull &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 (type.ty == TY.Tpointer || type.ty == TY.Tclass || type.ty == TY.Tarray))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 printf(" returning3 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 if (result & WANT.WANTflags && type.ty == TY.Tclass && e1.type.ty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 // See if we can remove an unnecessary cast
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 ClassDeclaration cdfrom;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 ClassDeclaration cdto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 int offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 cdfrom = e1.type.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 cdto = type.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 if (cdto.isBaseOf(cdfrom, &offset) && offset == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 printf(" returning4 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 // We can convert 'head const' to mutable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 if (to.constOf().equals(e1.type.constOf()))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 // if (to.constConv(e1.type) >= MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 printf(" returning5 %s\n", e1.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 if (e1.isConst())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 if (e1.op == TOK.TOKsymoff)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 if (type.size() == e1.type.size() &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 type.toBasetype().ty != TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 e1.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 if (to.toBasetype().ty == TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 e = Cast(type, to, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 printf(" returning6 %s\n", e.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 Expression interpret(InterState* istate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 bool checkSideEffect(int flag)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 void checkEscape()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 Type tb = type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 if (tb.ty == TY.Tarray && e1.op == TOK.TOKvar && e1.type.toBasetype().ty ==TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 VarExp ve = cast(VarExp)e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 VarDeclaration v = ve.var.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 if (v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 if (!v.isDataseg() && !v.isParameter())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 error("escaping reference to local %s", v.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 buf.writestring("cast(");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 version (DMDV1) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 to.toCBuffer(buf, null, hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 if (to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 to.toCBuffer(buf, null, hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 switch (mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 case MODundefined:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 case MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 buf.writestring(Token.tochars[TOKconst]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 case MODinvariant:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 buf.writestring(Token.tochars[TOKimmutable]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 case MODshared:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 buf.writestring(Token.tochars[TOKshared]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 case MODshared | MODconst:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 buf.writestring(Token.tochars[TOKshared]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 buf.writeByte(' ');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 buf.writestring(Token.tochars[TOKconst]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 buf.writeByte(')');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 expToCBuffer(buf, hgs, e1, precedence[op]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 void buildArrayIdent(OutBuffer buf, Expressions arguments)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 {
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
403 Type tb = type.toBasetype();
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
404 if (tb.ty == Tarray || tb.ty == Tsarray)
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
405 {
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
406 e1.buildArrayIdent(buf, arguments);
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
407 }
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
408 else
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
409 Expression.buildArrayIdent(buf, arguments);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 Expression buildArrayLoop(Arguments fparams)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 {
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
414 Type tb = type.toBasetype();
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
415 if (tb.ty == Tarray || tb.ty == Tsarray)
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
416 {
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
417 return e1.buildArrayLoop(fparams);
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
418 }
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
419 else
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
420 return Expression.buildArrayLoop(fparams);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 static int X(int fty, int tty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 return ((fty) * TY.TMAX + (tty));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 elem* toElem(IRState* irs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 elem* e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 TY fty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 TY tty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 tym_t ftym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 tym_t ttym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 OPER eop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 Type tfrom;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 printf("CastExp::toElem()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 printf("\tfrom: %s\n", e1.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 printf("\tto : %s\n", to.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 e = e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 tfrom = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 t = to.toBasetype(); // skip over typedef's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 if (t.equals(tfrom))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 fty = tfrom.ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 //printf("fty = %d\n", fty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 tty = t.ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 if (tty == TY.Tpointer && fty == TY.Tarray
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 ///static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 /// && (t.next.ty == Tvoid || t.next.equals(e1.type.next))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 if (e.Eoper == OPER.OPvar)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 // e1 . *(&e1 + 4)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 e = el_una(OPER.OPaddr, TYM.TYnptr, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 e = el_bin(OPER.OPadd, TYM.TYnptr, e, el_long(TYM.TYint, 4));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 e = el_una(OPER.OPind, t.totym(),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 // e1 . (unsigned)(e1 >> 32)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 e = el_bin(OPER.OPshr, TYM.TYullong, e, el_long(TYM.TYint, 32));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 e = el_una(OPER.OP64_32, t.totym(), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 if (tty == TY.Tpointer && fty == TY.Tsarray
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 ///static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 /// && (t.next.ty == Tvoid || t.next.equals(e1.type.next))
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 // e1 . &e1
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 e = el_una(OPER.OPaddr, TYM.TYnptr, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 // Convert from static array to dynamic array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 if (tty == TY.Tarray && fty == TY.Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 e = sarray_toDarray(loc, tfrom, t, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 // Convert from dynamic array to dynamic array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 if (tty == TY.Tarray && fty == TY.Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 uint fsize = cast(uint)tfrom.nextOf().size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 uint tsize = cast(uint)t.nextOf().size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 if (fsize != tsize)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 elem* ep = el_params(e, el_long(TYM.TYint, fsize), el_long(TYM.TYint, tsize), null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 e = el_bin(OPER.OPcall, type.totym(), el_var(rtlsym[RTLSYM.RTLSYM_ARRAYCAST]), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 // Convert from dynamic array string literal to static array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 if (tty == TY.Tsarray && fty == TY.Tarray && e1.op == TOK.TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 goto Lret; // treat as a 'paint'
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 // Casting from base class to derived class requires a runtime check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 if (fty == TY.Tclass && tty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 // Casting from derived class to base class is a no-op
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 ClassDeclaration cdfrom;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 ClassDeclaration cdto;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 int offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 int rtl = RTLSYM.RTLSYM_DYNAMIC_CAST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 cdfrom = tfrom.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 cdto = t.isClassHandle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 if (cdfrom.isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 rtl = RTLSYM.RTLSYM_INTERFACE_CAST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 if (cdfrom.isCPPinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 if (cdto.isCPPinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 /* Casting from a C++ interface to a C++ interface
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 * is always a 'paint' operation
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 goto Lret; // no-op
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541 /* Casting from a C++ interface to a class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 * always results in null because there is no runtime
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 * information available to do it.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 *
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 * Casting from a C++ interface to a non-C++ interface
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 * always results in null because there's no way one
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 * can be derived from the other.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 e = el_bin(OPER.OPcomma, TYM.TYnptr, e, el_long(TYM.TYnptr, 0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 if (cdto.isBaseOf(cdfrom, &offset) && offset != OFFSET_RUNTIME)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 /* The offset from cdfrom=>cdto is known at compile time.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 //printf("offset = %d\n", offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559 if (offset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 /* Rewrite cast as (e ? e + offset : null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 elem* etmp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564 elem* ex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 if (e1.op == TOK.TOKthis)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568 // Assume 'this' is never null, so skip null check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569 e = el_bin(OPER.OPadd, TYM.TYnptr, e, el_long(TYM.TYint, offset));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 etmp = el_same(&e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 ex = el_bin(OPER.OPadd, TYM.TYnptr, etmp, el_long(TYM.TYint, offset));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575 ex = el_bin(OPER.OPcolon, TYM.TYnptr, ex, el_long(TYM.TYnptr, 0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 e = el_bin(OPER.OPcond, TYM.TYnptr, e, ex);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 goto Lret; // no-op
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 /* The offset from cdfrom=>cdto can only be determined at runtime.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 elem* ep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586 ep = el_param(el_ptr(cdto.toSymbol()), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587 e = el_bin(OPER.OPcall, TYM.TYnptr, el_var(rtlsym[rtl]), ep);
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 ftym = e.Ety;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
592 ttym = t.totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
593 if (ftym == ttym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
596 switch (tty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598 case TY.Tpointer:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 if (fty == TY.Tdelegate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 tty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
602 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605 tty = TY.Tuns8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
607 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608 tty = TY.Tuns16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
609 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611 tty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 case TY.Tbool:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
617 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618 // Construct e?true:false
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 elem* eq;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 e = el_una(OPER.OPbool, ttym, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
624
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 switch (fty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631 case TY.Tpointer: fty = TY.Tuns32; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
632 case TY.Tchar: fty = TY.Tuns8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 case TY.Twchar: fty = TY.Tuns16; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634 case TY.Tdchar: fty = TY.Tuns32; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 default: break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 Lagain:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639 switch (X(fty,tty))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 case X(TY.Tbit,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 case X(TY.Tbit,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 case X(TY.Tbit,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646 case X(TY.Tbit,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 case X(TY.Tbit,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 case X(TY.Tbit,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 eop = OPu8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651 case X(TY.Tbit,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 case X(TY.Tbit,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 case X(TY.Tbit,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 case X(TY.Tbit,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 case X(TY.Tbit,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 case X(TY.Tbit,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 case X(TY.Tbit,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 case X(TY.Tbit,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 e = el_una(OPER.OPu8_16, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 case X(Tbit,Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 case X(Tbit,Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 case X(Tbit,Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 case X(TY.Tbool,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 case X(TY.Tbool,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 case X(TY.Tbool,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673 case X(TY.Tbool,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 case X(TY.Tbool,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 case X(TY.Tbool,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 eop = OPER.OPu8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 case X(TY.Tbool,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679 case X(TY.Tbool,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 case X(TY.Tbool,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 case X(TY.Tbool,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682 case X(TY.Tbool,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 case X(TY.Tbool,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684 case X(TY.Tbool,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685 case X(TY.Tbool,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 e = el_una(OPER.OPu8_16, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 case X(TY.Tbool,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
690 case X(TY.Tbool,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
691 case X(TY.Tbool,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 case X(TY.Tint8,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 case X(TY.Tint8,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 case X(TY.Tint8,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 case X(TY.Tint8,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701 case X(TY.Tint8,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 eop = OPER.OPs8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 case X(TY.Tint8,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 case X(TY.Tint8,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 case X(TY.Tint8,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 case X(TY.Tint8,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 case X(TY.Tint8,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 case X(TY.Tint8,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 case X(TY.Tint8,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 case X(TY.Tint8,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 e = el_una(OPER.OPs8_16, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 case X(TY.Tint8,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 case X(TY.Tint8,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 case X(TY.Tint8,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 case X(TY.Tuns8,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 case X(TY.Tuns8,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 case X(TY.Tuns8,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 case X(TY.Tuns8,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 case X(TY.Tuns8,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 eop = OPER.OPu8_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 case X(TY.Tuns8,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 case X(TY.Tuns8,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 case X(TY.Tuns8,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 case X(TY.Tuns8,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 case X(TY.Tuns8,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 case X(TY.Tuns8,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 case X(TY.Tuns8,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 case X(TY.Tuns8,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 e = el_una(OPER.OPu8_16, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 case X(TY.Tuns8,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742 case X(TY.Tuns8,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 case X(TY.Tuns8,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 case X(TY.Tint16,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749 case X(TY.Tint16,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 eop = OPER.OP16_8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752 case X(TY.Tint16,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 case X(TY.Tint16,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 case X(TY.Tint16,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 eop = OPER.OPs16_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 case X(TY.Tint16,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 case X(TY.Tint16,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 e = el_una(OPER.OPs16_32, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763 case X(TY.Tint16,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 case X(TY.Tint16,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 case X(TY.Tint16,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 case X(TY.Tint16,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 case X(TY.Tint16,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 case X(TY.Tint16,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 e = el_una(OPER.OPs16_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772 case X(TY.Tint16,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 case X(TY.Tint16,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774 case X(TY.Tint16,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 case X(TY.Tuns16,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 case X(TY.Tuns16,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 eop = OPER.OP16_8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783 case X(TY.Tuns16,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 case X(TY.Tuns16,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 case X(TY.Tuns16,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787 eop = OPER.OPu16_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
788 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 case X(TY.Tuns16,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 case X(TY.Tuns16,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 case X(TY.Tuns16,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 case X(TY.Tuns16,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 case X(TY.Tuns16,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 case X(TY.Tuns16,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 case X(TY.Tuns16,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 case X(TY.Tuns16,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 e = el_una(OPER.OPu16_32, TYM.TYuint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798 fty = TY.Tuns32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 case X(TY.Tuns16,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 case X(TY.Tuns16,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802 case X(TY.Tuns16,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
807 case X(TY.Tint32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 case X(TY.Tint32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809 e = el_una(OPER.OP32_16, TYM.TYshort, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810 fty = TY.Tint16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
811 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
812 case X(TY.Tint32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
813 case X(TY.Tint32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
814 eop = OPER.OP32_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
815 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
816 case X(TY.Tint32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
817 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
818 case X(TY.Tint32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
819 case X(TY.Tint32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
820 eop = OPER.OPs32_64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
821 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
822 case X(TY.Tint32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
823 case X(TY.Tint32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
824 case X(TY.Tint32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
825 case X(TY.Tint32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
826 case X(TY.Tint32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
827 case X(TY.Tint32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
828 e = el_una(OPER.OPs32_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
829 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
830 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
831 case X(TY.Tint32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
832 case X(TY.Tint32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
833 case X(TY.Tint32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
834 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
835
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
836 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
837
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
838 case X(TY.Tuns32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
839 case X(TY.Tuns32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
840 e = el_una(OPER.OP32_16, TYM.TYshort, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
841 fty = TY.Tuns16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
842 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
843 case X(TY.Tuns32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
844 case X(TY.Tuns32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
845 eop = OPER.OP32_16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
846 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
847 case X(TY.Tuns32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
848 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
849 case X(TY.Tuns32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
850 case X(TY.Tuns32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
851 eop = OPER.OPu32_64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
852 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
853 case X(TY.Tuns32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
854 case X(TY.Tuns32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
855 case X(TY.Tuns32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
856 case X(TY.Tuns32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
857 case X(TY.Tuns32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
858 case X(TY.Tuns32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
859 e = el_una(OPER.OPu32_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
860 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
861 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
862 case X(TY.Tuns32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
863 case X(TY.Tuns32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
864 case X(TY.Tuns32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
865 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
866
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
867 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
868
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
869 case X(TY.Tint64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
870 case X(TY.Tint64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
871 case X(TY.Tint64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
872 case X(TY.Tint64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
873 e = el_una(OPER.OP64_32, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
874 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
875 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
876 case X(TY.Tint64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
877 case X(TY.Tint64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
878 eop = OPER.OP64_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
879 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
880 case X(TY.Tint64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
881 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
882 case X(TY.Tint64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
883 case X(TY.Tint64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
884 case X(TY.Tint64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
885 case X(TY.Tint64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
886 case X(TY.Tint64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
887 case X(TY.Tint64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
888 e = el_una(OPER.OPs64_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
889 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
890 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
891 case X(TY.Tint64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
892 case X(TY.Tint64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
893 case X(TY.Tint64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
894 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
895
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
896 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
897
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
898 case X(TY.Tuns64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
899 case X(TY.Tuns64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
900 case X(TY.Tuns64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
901 case X(TY.Tuns64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
902 e = el_una(OPER.OP64_32, TYM.TYint, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
903 fty = TY.Tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
904 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
905 case X(TY.Tuns64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
906 case X(TY.Tuns64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
907 eop = OPER.OP64_32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
908 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
909 case X(TY.Tuns64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
910 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
911 case X(TY.Tuns64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
912 case X(TY.Tuns64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
913 case X(TY.Tuns64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
914 case X(TY.Tuns64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
915 case X(TY.Tuns64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
916 case X(TY.Tuns64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
917 e = el_una(OPER.OPu64_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
918 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
919 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
920 case X(TY.Tuns64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
921 case X(TY.Tuns64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
922 case X(TY.Tuns64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
923 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
924
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
925 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
926
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
927 case X(TY.Tfloat32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
928 case X(TY.Tfloat32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
929 case X(TY.Tfloat32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
930 case X(TY.Tfloat32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
931 case X(TY.Tfloat32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
932 case X(TY.Tfloat32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
933 case X(TY.Tfloat32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
934 case X(TY.Tfloat32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
935 case X(TY.Tfloat32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
936 e = el_una(OPER.OPf_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
937 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
938 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
939 case X(TY.Tfloat32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
940 eop = OPER.OPf_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
941 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
942 case X(TY.Tfloat32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
943 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
944 case X(TY.Tfloat32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
945 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
946 case X(TY.Tfloat32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
947 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
948 case X(TY.Tfloat32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
949 case X(TY.Tfloat32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
950 case X(TY.Tfloat32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
951 e = el_bin(OPER.OPadd,TYM.TYcfloat,el_long(TYM.TYifloat,0),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
952 fty = TY.Tcomplex32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
953 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
954
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
955 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
956
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
957 case X(TY.Tfloat64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
958 case X(TY.Tfloat64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
959 e = el_una(OPER.OPd_s16, TYM.TYshort, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
960 fty = TY.Tint16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
961 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
962 case X(TY.Tfloat64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
963 eop = OPER.OPd_s16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
964 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
965 case X(TY.Tfloat64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
966 eop = OPER.OPd_u16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
967 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
968 case X(TY.Tfloat64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
969 eop = OPER.OPd_s32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
970 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
971 case X(TY.Tfloat64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
972 eop = OPER.OPd_u32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
973 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
974 case X(TY.Tfloat64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
975 eop = OPER.OPd_s64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
976 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
977 case X(TY.Tfloat64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
978 eop = OPER.OPd_u64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
979 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
980 case X(TY.Tfloat64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
981 eop = OPER.OPd_f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
982 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
983 case X(TY.Tfloat64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
984 eop = OPER.OPd_ld;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
985 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
986 case X(TY.Tfloat64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
987 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
988 case X(TY.Tfloat64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
989 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
990 case X(TY.Tfloat64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
991 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
992 case X(TY.Tfloat64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
993 case X(TY.Tfloat64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
994 case X(TY.Tfloat64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
995 e = el_bin(OPER.OPadd,TYM.TYcfloat,el_long(TYM.TYidouble,0),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
996 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
997 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
998
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
999 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1001 case X(TY.Tfloat80,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1002 case X(TY.Tfloat80,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1003 case X(TY.Tfloat80,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1004 case X(TY.Tfloat80,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1005 case X(TY.Tfloat80,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1006 case X(TY.Tfloat80,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1007 case X(TY.Tfloat80,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1008 case X(TY.Tfloat80,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1009 e = el_una(OPER.OPld_d, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1010 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1011 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1012 case X(TY.Tfloat80,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1013 eop = OPER.OPld_u64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1014 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1015 case X(TY.Tfloat80,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1016 eop = OPER.OPld_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1017 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1018 case X(TY.Tfloat80,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1019 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1020 case X(TY.Tfloat80,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1021 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1022 case X(TY.Tfloat80,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1023 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1024 case X(TY.Tfloat80,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1025 case X(TY.Tfloat80,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1026 case X(TY.Tfloat80,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1027 e = el_bin(OPER.OPadd,TYM.TYcldouble,e,el_long(TYM.TYildouble,0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1028 fty = TY.Tcomplex80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1029 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1030
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1031 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1032
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1033 case X(TY.Timaginary32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1034 case X(TY.Timaginary32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1035 case X(TY.Timaginary32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1036 case X(TY.Timaginary32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1037 case X(TY.Timaginary32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1038 case X(TY.Timaginary32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1039 case X(TY.Timaginary32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1040 case X(TY.Timaginary32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1041 case X(TY.Timaginary32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1042 case X(TY.Timaginary32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1043 case X(TY.Timaginary32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1044 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1045 case X(TY.Timaginary32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1046 eop = OPER.OPf_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1047 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1048 case X(TY.Timaginary32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1049 e = el_una(OPER.OPf_d, TYM.TYidouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1050 fty = TY.Timaginary64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1051 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1052 case X(TY.Timaginary32,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1053 case X(TY.Timaginary32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1054 case X(TY.Timaginary32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1055 e = el_bin(OPER.OPadd,TYM.TYcfloat,el_long(TYM.TYfloat,0),e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1056 fty = TY.Tcomplex32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1057 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1058
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1059 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1060
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1061 case X(TY.Timaginary64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1062 case X(TY.Timaginary64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1063 case X(TY.Timaginary64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1064 case X(TY.Timaginary64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1065 case X(TY.Timaginary64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1066 case X(TY.Timaginary64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1067 case X(TY.Timaginary64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1068 case X(TY.Timaginary64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1069 case X(TY.Timaginary64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1070 case X(TY.Timaginary64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1071 case X(TY.Timaginary64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1072 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1073 case X(TY.Timaginary64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1074 eop = OPER.OPd_f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1075 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1076 case X(TY.Timaginary64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1077 eop = OPER.OPd_ld;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1078 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1079 case X(TY.Timaginary64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1080 case X(TY.Timaginary64,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1081 case X(TY.Timaginary64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1082 e = el_bin(OPER.OPadd, TYM.TYcdouble, el_long(TYM.TYdouble,0), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1083 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1084 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1085
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1086 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1087
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1088 case X(TY.Timaginary80,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1089 case X(TY.Timaginary80,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1090 case X(TY.Timaginary80,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1091 case X(TY.Timaginary80,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1092 case X(TY.Timaginary80,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1093 case X(TY.Timaginary80,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1094 case X(TY.Timaginary80,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1095 case X(TY.Timaginary80,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1096 case X(TY.Timaginary80,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1097 case X(TY.Timaginary80,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1098 case X(TY.Timaginary80,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1099 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1100 case X(TY.Timaginary80,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1101 e = el_una(OPER.OPf_d, TYM.TYidouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1102 fty = TY.Timaginary64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1103 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1104 case X(TY.Timaginary80,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1105 eop = OPER.OPld_d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1106 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1107 case X(TY.Timaginary80,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1108 case X(TY.Timaginary80,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1109 case X(TY.Timaginary80,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1110 e = el_bin(OPER.OPadd, TYM.TYcldouble, el_long(TYM.TYldouble,0), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1111 fty = TY.Tcomplex80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1112 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1113
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1114 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1115
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1116 case X(TY.Tcomplex32,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1117 case X(TY.Tcomplex32,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1118 case X(TY.Tcomplex32,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1119 case X(TY.Tcomplex32,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1120 case X(TY.Tcomplex32,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1121 case X(TY.Tcomplex32,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1122 case X(TY.Tcomplex32,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1123 case X(TY.Tcomplex32,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1124 case X(TY.Tcomplex32,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1125 case X(TY.Tcomplex32,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1126 case X(TY.Tcomplex32,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1127 e = el_una(OPER.OPc_r, TYM.TYfloat, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1128 fty = TY.Tfloat32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1129 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1130 case X(TY.Tcomplex32,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1131 case X(TY.Tcomplex32,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1132 case X(TY.Tcomplex32,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1133 e = el_una(OPER.OPc_i, TYM.TYifloat, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1134 fty = TY.Timaginary32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1135 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1136 case X(TY.Tcomplex32,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1137 case X(TY.Tcomplex32,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1138 e = el_una(OPER.OPf_d, TYM.TYcdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1139 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1140 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1141
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1142 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1143
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1144 case X(TY.Tcomplex64,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1145 case X(TY.Tcomplex64,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1146 case X(TY.Tcomplex64,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1147 case X(TY.Tcomplex64,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1148 case X(TY.Tcomplex64,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1149 case X(TY.Tcomplex64,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1150 case X(TY.Tcomplex64,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1151 case X(TY.Tcomplex64,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1152 case X(TY.Tcomplex64,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1153 case X(TY.Tcomplex64,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1154 case X(TY.Tcomplex64,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1155 e = el_una(OPER.OPc_r, TYM.TYdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1156 fty = TY.Tfloat64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1157 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1158 case X(TY.Tcomplex64,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1159 case X(TY.Tcomplex64,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1160 case X(TY.Tcomplex64,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1161 e = el_una(OPER.OPc_i, TYM.TYidouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1162 fty = TY.Timaginary64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1163 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1164 case X(TY.Tcomplex64,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1165 eop = OPER.OPd_f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1166 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1167 case X(TY.Tcomplex64,TY.Tcomplex80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1168 eop = OPER.OPd_ld;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1169 goto Leop;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1170
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1171 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1172
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1173 case X(TY.Tcomplex80,TY.Tint8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1174 case X(TY.Tcomplex80,TY.Tuns8):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1175 case X(TY.Tcomplex80,TY.Tint16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1176 case X(TY.Tcomplex80,TY.Tuns16):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1177 case X(TY.Tcomplex80,TY.Tint32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1178 case X(TY.Tcomplex80,TY.Tuns32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1179 case X(TY.Tcomplex80,TY.Tint64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1180 case X(TY.Tcomplex80,TY.Tuns64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1181 case X(TY.Tcomplex80,TY.Tfloat32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1182 case X(TY.Tcomplex80,TY.Tfloat64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1183 case X(TY.Tcomplex80,TY.Tfloat80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1184 e = el_una(OPER.OPc_r, TYM.TYldouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1185 fty = TY.Tfloat80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1186 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1187 case X(TY.Tcomplex80,TY.Timaginary32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1188 case X(TY.Tcomplex80,TY.Timaginary64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1189 case X(TY.Tcomplex80,TY.Timaginary80):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1190 e = el_una(OPER.OPc_i, TYM.TYildouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1191 fty = TY.Timaginary80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1192 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1193 case X(TY.Tcomplex80,TY.Tcomplex32):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1194 case X(TY.Tcomplex80,TY.Tcomplex64):
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1195 e = el_una(OPER.OPld_d, TYM.TYcdouble, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1196 fty = TY.Tcomplex64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1197 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1198
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1199 /* ============================= */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1200
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1201 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1202 if (fty == tty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1203 goto Lpaint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1204 //dump(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1205 //printf("fty = %d, tty = %d\n", fty, tty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1206 error("e2ir: cannot cast from %s to %s", e1.type.toChars(), t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1207 goto Lzero;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1208
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1209 Lzero:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1210 e = el_long(ttym, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1211 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1212
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1213 Lpaint:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1214 e.Ety = ttym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1215 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1216
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1217 Leop:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1218 e = el_una(eop, ttym, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1219 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1221 Lret:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1222 // Adjust for any type paints
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1223 t = type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1224 e.Ety = t.totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1225
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1226 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1227 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1228 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1229
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1230 Identifier opId()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1231 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1232 return Id.cast_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1233 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1234 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1235