annotate dmd/ShlExp.d @ 162:438eaa11eed4

updated build script to use dmd2.039 some missing methods implemented
author korDen
date Tue, 21 Sep 2010 14:59:56 +0400
parents 6caaf0256da1
children e3afd1303184
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
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 class ShlExp : BinExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 this(Loc loc, Expression e1, Expression e2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 super(loc, TOK.TOKshl, ShlExp.sizeof, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
30 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 //printf("ShlExp.semantic(), type = %p\n", type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 BinExp.semanticp(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 e1 = e1.checkIntegral();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 e2 = e2.checkIntegral();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 e1 = e1.integralPromotions(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 e2 = e2.castTo(sc, Type.tshiftcnt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 type = e1.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
53 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 //printf("ShlExp::optimize(result = %d) %s\n", result, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 return shift_optimize(result, this, &Shl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
59 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 {
115
6caaf0256da1 + interpretation of (non-assign) binary expressions
Trass3r
parents: 114
diff changeset
61 return interpretCommon(istate, &Shl);
0
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 IntRange getIntRange()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
162
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
66 IntRange ir;
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
67 IntRange ir1 = e1.getIntRange();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
68 IntRange ir2 = e2.getIntRange();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
69
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
70 ir.imin = getMask(ir1.imin) << ir2.imin;
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
71 ir.imax = getMask(ir1.imax) << ir2.imax;
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
72
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
73 ir.imin &= type.sizemask();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
74 ir.imax &= type.sizemask();
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
75
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
76 //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
77 //e1.dump(0);
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
78
438eaa11eed4 updated build script to use dmd2.039
korDen
parents: 115
diff changeset
79 return ir;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
82 override Identifier opId()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 return Id.shl;
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_r()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 return Id.shl_r;
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 elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 return toElemBin(irs, OPER.OPshl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97