Debian Codegraph @

gcc/testsuite/gm2/pim/pass/largeset2.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 largeset2 ;
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 PROCEDURE TestIn (i: CARDINAL) ;
30 VAR
31 j: CARDINAL ;
32 BEGIN
33 IF NOT (i IN b)
34 THEN
35 exit(3)
36 END ;
37 FOR j := 0 TO MAX(LargeBitset) DO
38 IF (i#j) AND (j IN b)
39 THEN
40 exit(4)
41 END
42 END
43 END TestIn ;
44
45
46 (*
47 GetAddr -
48 *)
49
50 PROCEDURE GetAddr (i: CARDINAL) : ADDRESS ;
51 BEGIN
52 CASE i OF
53
54 0..31 : RETURN( ADR(b) ) |
55 32..63 : RETURN( ADR(b)+ADDRESS(4) ) |
56 64..95 : RETURN( ADR(b)+ADDRESS(8) ) |
57 96..127: RETURN( ADR(b)+ADDRESS(12) )
58
59 ELSE
60 HALT
61 END
62 END GetAddr ;
63
64
65 VAR
66 b: LargeBitset ;
67 p: POINTER TO CARDINAL ;
68 i, j: CARDINAL ;
69 BEGIN
70 j := 1 ;
71 b := LargeBitset{} ;
72 FOR i := 0 TO MAX(LargeBitset) DO
73 WriteString('index = ') ; WriteCard(i, 3) ; WriteLn ;
74 INCL(b, i) ;
75 p := GetAddr(i) ;
76 IF p^#j
77 THEN
78 exit(1)
79 END ;
80 TestIn(i) ;
81 EXCL(b, i) ;
82 IF b#LargeBitset{}
83 THEN
84 exit(2)
85 END ;
86 IF i MOD 32 = 31
87 THEN
88 j := 1
89 ELSE
90 j := j*2
91 END
92 END
93 END largeset2.