]> gcc.gnu.org Git - gcc.git/blob - gcc/m2/gm2-compiler/M2Bitset.mod
Year date changes for Modula-2 source tree.
[gcc.git] / gcc / m2 / gm2-compiler / M2Bitset.mod
1 (* M2Bitset.mod provides the BITSET type.
2
3 Copyright (C) 2003-2022 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
21
22 IMPLEMENTATION MODULE M2Bitset ;
23
24
25 FROM M2Debug IMPORT Assert ;
26 FROM m2tree IMPORT Tree ;
27 FROM m2linemap IMPORT BuiltinsLocation ;
28 FROM m2type IMPORT GetWordType ;
29 FROM m2decl IMPORT GetBitsPerBitset ;
30 FROM m2expr IMPORT GetSizeOf ;
31 FROM M2ALU IMPORT PushCard, PushIntegerTree ;
32 FROM NameKey IMPORT MakeKey ;
33 FROM M2System IMPORT Word ;
34 FROM M2Base IMPORT Cardinal ;
35 FROM M2LexBuf IMPORT BuiltinTokenNo ;
36
37 FROM SymbolTable IMPORT NulSym,
38 MakeConstLit,
39 MakeConstVar,
40 MakeSet,
41 MakeSubrange,
42 PutSet,
43 PutSubrange,
44 PopValue,
45 PopSize ;
46
47
48 VAR
49 MinBitset, MaxBitset : CARDINAL ;
50
51
52 (*
53 MakeBitset - creates and declares the type BITSET.
54 *)
55
56 PROCEDURE MakeBitset ;
57 BEGIN
58 Bitset := MakeSet (BuiltinTokenNo, MakeKey('BITSET')) ; (* Base Type *)
59
60 (* MinBitset *)
61 MinBitset := MakeConstLit (BuiltinTokenNo, MakeKey('0'), Cardinal) ;
62
63 (* MaxBitset *)
64 MaxBitset := MakeConstVar (BuiltinTokenNo, MakeKey('MaxBitset')) ;
65 PushCard (GetBitsPerBitset()-1) ;
66 PopValue (MaxBitset) ;
67
68 Assert (Word#NulSym) ;
69 Bitnum := MakeSubrange (BuiltinTokenNo, MakeKey('BITNUM')) ;
70 PutSubrange (Bitnum, MinBitset, MaxBitset, Cardinal) ;
71 PutSet (Bitset, Bitnum, FALSE) ;
72
73 PushIntegerTree (GetSizeOf(BuiltinsLocation(), GetWordType())) ;
74 PopSize (Bitset)
75 END MakeBitset ;
76
77
78 (*
79 GetBitsetMinMax - assigns min and max to the minimum and maximum values of BITSET.
80 *)
81
82 PROCEDURE GetBitsetMinMax (VAR min, max: CARDINAL) ;
83 BEGIN
84 min := MinBitset ;
85 max := MaxBitset
86 END GetBitsetMinMax ;
87
88
89 END M2Bitset.
This page took 0.041213 seconds and 5 git commands to generate.