Mercurial > projects > ddmd
annotate dmd/ShlAssignExp.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.ShlAssignExp; |
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.TOK; | |
12 import dmd.Id; | |
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; |
16 import dmd.backend.OPER; | |
117 | 17 import dmd.expression.Shl; |
0 | 18 import dmd.expression.Util; |
19 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
20 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
|
21 |
0 | 22 class ShlAssignExp : BinExp |
23 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 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
|
25 |
0 | 26 this(Loc loc, Expression e1, Expression e2) |
27 { | |
178 | 28 register(); |
0 | 29 super(loc, TOK.TOKshlass, ShlAssignExp.sizeof, e1, e2); |
30 } | |
31 | |
72 | 32 override Expression semantic(Scope sc) |
0 | 33 { |
34 Expression e; | |
35 | |
36 //printf("ShlAssignExp.semantic()\n"); | |
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, &Shl); |
0 | 65 } |
66 | |
72 | 67 override Identifier opId() /* For operator overloading */ |
0 | 68 { |
69 return Id.shlass; | |
70 } | |
71 | |
72 | 72 override elem* toElem(IRState* irs) |
0 | 73 { |
74 return toElemBin(irs,OPshlass); | |
75 } | |
72 | 76 } |