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