annotate dmd/expression/Shr.d @ 157:b7b61140701d

* added all missing default cases in switch statements + Lexer.getDocComment + Lexer.combineComments
author trass3r
date Thu, 16 Sep 2010 01:34:10 +0200
parents e28b18c23469
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.expression.Shr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 0
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 Expression Shr(Type type, Expression e1, Expression e2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 Loc loc = e1.loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 long value = e1.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 uint count = cast(uint)e2.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 switch (e1.type.toBasetype().ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 case TY.Tint8:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 value = cast(byte)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 case TY.Tuns8:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 value = cast(ubyte)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 case TY.Tint16:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 value = cast(short)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 case TY.Tuns16:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 value = cast(ushort)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 case TY.Tint32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 value = cast(int)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 case TY.Tuns32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 value = cast(uint)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 case TY.Tint64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 value = cast(long)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 case TY.Tuns64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 value = cast(ulong)(value) >> count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 break;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 114
diff changeset
50
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 114
diff changeset
51 default:
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 114
diff changeset
52 assert(0);
0
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 new IntegerExp(loc, value, type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }