Debian Codegraph @

gcc/testsuite/gm2/pim/pass/largeset1.mod

raw
1 (* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17
18 MODULE largeset1 ;
19
20 FROM SYSTEM IMPORT ADR, ADDRESS ;
21 FROM libc IMPORT exit ;
22 FROM NumberIO IMPORT WriteCard ;
23 FROM StrIO IMPORT WriteString, WriteLn ;
24
25 TYPE
26 LargeBitset = SET OF [0..127] ;
27
28
29 (*
30 GetAddr -
31 *)
32
33 PROCEDURE GetAddr (i: CARDINAL) : ADDRESS ;
34 BEGIN
35 CASE i OF
36
37 0..31 : RETURN( ADR(b) ) |
38 32..63 : RETURN( ADR(b)+ADDRESS(4) ) |
39 64..95 : RETURN( ADR(b)+ADDRESS(8) ) |
40 96..127: RETURN( ADR(b)+ADDRESS(12) )
41
42 ELSE
43 HALT
44 END
45 END GetAddr ;
46
47
48 VAR
49 b: LargeBitset ;
50 p: POINTER TO CARDINAL ;
51 i, j: CARDINAL ;
52 BEGIN
53 j := 1 ;
54 b := LargeBitset{} ;
55 FOR i := 0 TO MAX(LargeBitset) DO
56 WriteString('index = ') ; WriteCard(i, 3) ; WriteLn ;
57 INCL(b, i) ;
58 p := GetAddr(i) ;
59 IF p^#j
60 THEN
61 exit(1)
62 END ;
63 EXCL(b, i) ;
64 IF b#LargeBitset{}
65 THEN
66 exit(2)
67 END ;
68 IF i MOD 32 = 31
69 THEN
70 j := 1
71 ELSE
72 j := j*2
73 END
74 END
75 END largeset1.