annotate dmd/ShlExp.d @ 192:eb38fdcb3e62 default tip

updated to compile with dmd2.062
author korDen
date Sat, 02 Mar 2013 01:25:52 -0800
parents b0d41ff5e0df
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
1 module dmd.ShlExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
4 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
5 import dmd.Identifier;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
6 import dmd.backend.elem;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
7 import dmd.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
8 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
9 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
10 import dmd.IntRange;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
11 import dmd.IRState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
12 import dmd.BinExp;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.expression.shift_optimize;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.expression.Shl;
162
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
19 import dmd.expression.Util;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
21 import dmd.backend.OPER;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
22
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
23 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
24
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 class ShlExp : BinExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
27 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
28
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 this(Loc loc, Expression e1, Expression e2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 162
diff changeset
31 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 super(loc, TOK.TOKshl, ShlExp.sizeof, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
35 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 //printf("ShlExp.semantic(), type = %p\n", type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 BinExp.semanticp(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 e1 = e1.checkIntegral();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 e2 = e2.checkIntegral();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 e1 = e1.integralPromotions(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 e2 = e2.castTo(sc, Type.tshiftcnt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 type = e1.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
58 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 //printf("ShlExp::optimize(result = %d) %s\n", result, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 return shift_optimize(result, this, &Shl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
64 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
115
6caaf0256da1 + interpretation of (non-assign) binary expressions
Trass3r
parents: 114
diff changeset
66 return interpretCommon(istate, &Shl);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
69 override IntRange getIntRange()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 {
162
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
71 IntRange ir;
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
72 IntRange ir1 = e1.getIntRange();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
73 IntRange ir2 = e2.getIntRange();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
74
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
75 ir.imin = getMask(ir1.imin) << ir2.imin;
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
76 ir.imax = getMask(ir1.imax) << ir2.imax;
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
77
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
78 ir.imin &= type.sizemask();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
79 ir.imax &= type.sizemask();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
80
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
81 //printf("ShlExp: imin = x%llx, imax = x%llx\n", ir.imin, ir.imax);
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
82 //e1.dump(0);
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
83
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
84 return ir;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
87 override Identifier opId()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 return Id.shl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
92 override Identifier opId_r()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 return Id.shl_r;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
97 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 return toElemBin(irs, OPER.OPshl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102