Debian Codegraph @

gcc/testsuite/gm2/sets/run/pass/multisetrotate3.mod

raw
1 (* Copyright (C) 2019 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 multisetrotate3 ;
19
20 FROM libc IMPORT printf, exit ;
21 FROM SYSTEM IMPORT ROTATE, WORD, BITSPERLOC;
22
23 TYPE
24 multi = SET OF [0..SIZE (WORD) * 2 * BITSPERLOC-1] ;
25
26
27 (*
28 dump -
29 *)
30
31 PROCEDURE dump (s: multi) ;
32 VAR
33 bits, i: CARDINAL ;
34 BEGIN
35 bits := SIZE (multi) * BITSPERLOC -1;
36 FOR i := 0 TO bits DO
37 printf (" %2d", i)
38 END ;
39 printf ("\n") ;
40 FOR i := 0 TO bits DO
41 IF i IN s
42 THEN
43 printf (" X")
44 ELSE
45 printf (" ")
46 END
47 END ;
48 printf ("\n")
49 END dump ;
50
51
52 VAR
53 set : multi ;
54 bits: INTEGER ;
55 BEGIN
56 dump (multi {1}) ;
57 dump (multi {2}) ;
58 dump (multi {63}) ;
59 dump (multi {48}) ;
60 dump (multi {32}) ;
61 dump (multi {31}) ;
62 set := multi {1} ;
63 dump (set) ;
64 bits := SIZE (multi) * BITSPERLOC ;
65 printf ("bits in multi = %d, bytes in multi = %d\n", bits, SIZE (multi)) ;
66 dump (ROTATE (set, bits)) ;
67 IF ROTATE (set, bits) # multi {1}
68 THEN
69 exit (1)
70 END ;
71 IF ROTATE (set, -bits) # multi {1}
72 THEN
73 exit (2)
74 END ;
75 exit (0)
76 END multisetrotate3.