Mercurial > projects > ddmd
comparison dmd/XorExp.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | 832f71e6f96c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:10317f0c89a5 |
---|---|
1 module dmd.XorExp; | |
2 | |
3 import dmd.Expression; | |
4 import dmd.Identifier; | |
5 import dmd.InterState; | |
6 import dmd.MATCH; | |
7 import dmd.Id; | |
8 import dmd.Type; | |
9 import dmd.OutBuffer; | |
10 import dmd.Loc; | |
11 import dmd.Scope; | |
12 import dmd.IntRange; | |
13 import dmd.IRState; | |
14 import dmd.ArrayTypes; | |
15 import dmd.BinExp; | |
16 import dmd.TOK; | |
17 import dmd.TY; | |
18 | |
19 import dmd.backend.elem; | |
20 import dmd.expression.Util; | |
21 import dmd.expression.Xor; | |
22 | |
23 class XorExp : BinExp | |
24 { | |
25 this(Loc loc, Expression e1, Expression e2) | |
26 { | |
27 super(loc, TOK.TOKxor, XorExp.sizeof, e1, e2); | |
28 } | |
29 | |
30 Expression semantic(Scope sc) | |
31 { | |
32 Expression e; | |
33 | |
34 if (!type) | |
35 { | |
36 BinExp.semanticp(sc); | |
37 e = op_overload(sc); | |
38 if (e) | |
39 return e; | |
40 if (e1.type.toBasetype().ty == Tbool && | |
41 e2.type.toBasetype().ty == Tbool) | |
42 { | |
43 type = e1.type; | |
44 e = this; | |
45 } | |
46 else | |
47 { | |
48 typeCombine(sc); | |
49 if (e1.op != TOKslice && e2.op != TOKslice) | |
50 { | |
51 e1.checkIntegral(); | |
52 e2.checkIntegral(); | |
53 } | |
54 } | |
55 } | |
56 return this; | |
57 } | |
58 | |
59 Expression optimize(int result) | |
60 { | |
61 Expression e; | |
62 | |
63 e1 = e1.optimize(result); | |
64 e2 = e2.optimize(result); | |
65 if (e1.isConst() == 1 && e2.isConst() == 1) | |
66 e = Xor(type, e1, e2); | |
67 else | |
68 e = this; | |
69 | |
70 return e; | |
71 } | |
72 | |
73 Expression interpret(InterState* istate) | |
74 { | |
75 assert(false); | |
76 } | |
77 | |
78 void buildArrayIdent(OutBuffer buf, Expressions arguments) | |
79 { | |
80 assert(false); | |
81 } | |
82 | |
83 Expression buildArrayLoop(Arguments fparams) | |
84 { | |
85 assert(false); | |
86 } | |
87 | |
88 MATCH implicitConvTo(Type t) | |
89 { | |
90 assert(false); | |
91 } | |
92 | |
93 IntRange getIntRange() | |
94 { | |
95 assert(false); | |
96 } | |
97 | |
98 bool isCommutative() | |
99 { | |
100 return true; | |
101 } | |
102 | |
103 Identifier opId() | |
104 { | |
105 return Id.ixor; | |
106 } | |
107 | |
108 Identifier opId_r() | |
109 { | |
110 return Id.ixor_r; | |
111 } | |
112 | |
113 elem* toElem(IRState* irs) | |
114 { | |
115 assert(false); | |
116 } | |
117 } | |
118 |