annotate run/o/odd_bug_15_A.d @ 1503:276623518fb1

[Issue 1150] Compiler creates wrong code <niqbmozgvx@mailinator.com> 2007-04-15 http://d.puremagic.com/issues/show_bug.cgi?id=1150
author thomask
date Mon, 23 Apr 2007 18:00:36 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1503
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
1 // $HeadURL$
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
2 // $Date$
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
3 // $Author$
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
4
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
5 // @author@ <niqbmozgvx@mailinator.com>
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
6 // @date@ 2007-04-15
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
7 // @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1150
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
8 // @desc@ [Issue 1150] Compiler creates wrong code
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
9
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
10 module dstress.run.o.odd_bug_15_A;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
11
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
12 class RangeCoder {
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
13 uint[258] cumCount;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
14 uint lower;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
15 uint upper;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
16 ulong range;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
17
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
18 this() {
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
19 for (int i=0; i < cumCount.length; i++){
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
20 cumCount[i] = i;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
21 }
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
22 lower = 0;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
23 upper = 0xffffffff;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
24 range = 0x100000000;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
25 }
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
26
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
27 void encode(uint symbol) {
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
28 uint total = cumCount[length - 1];
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
29 upper = lower + cast(uint)((cumCount[symbol+1] * range) / total) - 1;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
30 lower = lower + cast(uint)((cumCount[symbol] * range) / total);
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
31 }
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
32
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
33 }
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
34
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
35 int main() {
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
36 RangeCoder rc = new RangeCoder();
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
37 rc.encode(77);
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
38 return 0;
276623518fb1 [Issue 1150] Compiler creates wrong code
thomask
parents:
diff changeset
39 }