Mercurial > projects > ddmd
annotate dmd/UshrAssignExp.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children |
rev | line source |
---|---|
0 | 1 module dmd.UshrAssignExp; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.BinExp; |
5 import dmd.Loc; | |
6 import dmd.Expression; | |
7 import dmd.Scope; | |
8 import dmd.InterState; | |
9 import dmd.Identifier; | |
10 import dmd.IRState; | |
11 import dmd.Id; | |
12 import dmd.TOK; | |
13 import dmd.Type; | |
131
206db751bd4c
dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
130
diff
changeset
|
14 import dmd.ArrayLengthExp; |
0 | 15 import dmd.backend.elem; |
117 | 16 import dmd.expression.Ushr; |
0 | 17 import dmd.expression.Util; |
18 | |
131
206db751bd4c
dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
130
diff
changeset
|
19 import dmd.backend.OPER; |
206db751bd4c
dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
130
diff
changeset
|
20 |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
21 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
22 |
0 | 23 class UshrAssignExp : BinExp |
24 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
25 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
26 |
0 | 27 this(Loc loc, Expression e1, Expression e2) |
28 { | |
178 | 29 register(); |
0 | 30 super(loc, TOK.TOKushrass, UshrAssignExp.sizeof, e1, e2); |
31 } | |
32 | |
72 | 33 override Expression semantic(Scope sc) |
0 | 34 { |
35 Expression e; | |
36 | |
37 BinExp.semantic(sc); | |
38 e2 = resolveProperties(sc, e2); | |
39 | |
40 e = op_overload(sc); | |
41 if (e) | |
42 return e; | |
43 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
44 if (e1.op == TOK.TOKarraylength) |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
45 { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
46 e = ArrayLengthExp.rewriteOpAssign(this); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
47 e = e.semantic(sc); |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
48 return e; |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
49 } |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
50 |
0 | 51 e1 = e1.modifiableLvalue(sc, e1); |
52 e1.checkScalar(); | |
53 e1.checkNoBool(); | |
54 type = e1.type; | |
55 typeCombine(sc); | |
56 e1.checkIntegral(); | |
57 e2 = e2.checkIntegral(); | |
58 e2 = e2.castTo(sc, Type.tshiftcnt); | |
59 return this; | |
60 } | |
61 | |
72 | 62 override Expression interpret(InterState istate) |
0 | 63 { |
117 | 64 return interpretAssignCommon(istate, &Ushr); |
0 | 65 } |
66 | |
72 | 67 override Identifier opId() /* For operator overloading */ |
0 | 68 { |
69 return Id.ushrass; | |
70 } | |
71 | |
72 | 72 override elem* toElem(IRState* irs) |
0 | 73 { |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
117
diff
changeset
|
74 return toElemBin(irs, OPER.OPshrass); |
0 | 75 } |
72 | 76 } |