]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/m2/gm2-compiler/FifoQueue.mod
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / gm2-compiler / FifoQueue.mod
CommitLineData
1eee94d3
GM
1(* FifoQueue.mod provides a simple fifo queue.
2
83ffe9cd 3Copyright (C) 2001-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 FifoQueue ;
23
24FROM Lists IMPORT List, InitList, PutItemIntoList, GetItemFromList ;
25
26TYPE
27 Fifo = RECORD
28 Queue: List ;
29 Out : CARDINAL ;
30 END ;
31
32VAR
33 const,
34 subrange,
35 enumeration,
36 constructor: Fifo ;
37
38
39(*
40 PutInto - places a CARDINAL number, c, into a fifo queue.
41*)
42
43PROCEDURE PutInto (VAR f: Fifo; c: CARDINAL) ;
44BEGIN
45 WITH f DO
46 PutItemIntoList(Queue, c)
47 END
48END PutInto ;
49
50
51(*
52 GetFrom - retrieves a CARDINAL number, c, from a fifo queue.
53*)
54
55PROCEDURE GetFrom (VAR f: Fifo; VAR c: CARDINAL) ;
56BEGIN
57 WITH f DO
58 INC(Out) ;
59 c := GetItemFromList(Queue, Out)
60 END
61END GetFrom ;
62
63
64(*
65 PutEnumerationIntoFifoQueue - places an enumeration symbol, c,
66 into a fifo queue.
67*)
68
69PROCEDURE PutEnumerationIntoFifoQueue (c: CARDINAL) ;
70BEGIN
71 PutInto(enumeration, c)
72END PutEnumerationIntoFifoQueue ;
73
74
75(*
76 GetEnumerationFromFifoQueue - retrieves an enumeration symbol,
77 c, from a fifo queue.
78*)
79
80PROCEDURE GetEnumerationFromFifoQueue (VAR c: CARDINAL) ;
81BEGIN
82 GetFrom(enumeration, c)
83END GetEnumerationFromFifoQueue ;
84
85
86(*
87 PutSubrangeIntoFifoQueue - places a subrange symbol into a fifo
88 queue.
89*)
90
91PROCEDURE PutSubrangeIntoFifoQueue (c: CARDINAL) ;
92BEGIN
93 PutInto(subrange, c)
94END PutSubrangeIntoFifoQueue ;
95
96
97(*
98 GetSubrangeFromFifoQueue - retrieves a subrange symbol from a
99 fifo queue.
100*)
101
102PROCEDURE GetSubrangeFromFifoQueue (VAR c: CARDINAL) ;
103BEGIN
104 GetFrom(subrange, c)
105END GetSubrangeFromFifoQueue ;
106
107
108(*
109 PutConstructorIntoFifoQueue - places a constructor symbol
110 into a fifo queue.
111*)
112
113PROCEDURE PutConstructorIntoFifoQueue (c: CARDINAL) ;
114BEGIN
115 PutInto(constructor, c)
116END PutConstructorIntoFifoQueue ;
117
118
119(*
120 GetConstructorFromFifoQueue - retrieves a constructor symbol
121 from a fifo queue.
122*)
123
124PROCEDURE GetConstructorFromFifoQueue (VAR c: CARDINAL) ;
125BEGIN
126 GetFrom(constructor, c)
127END GetConstructorFromFifoQueue ;
128
129
130(*
131 PutConstIntoFifoQueue - places a constant symbol
132 into a fifo queue.
133*)
134
135PROCEDURE PutConstIntoFifoQueue (c: CARDINAL) ;
136BEGIN
137 PutInto(const, c)
138END PutConstIntoFifoQueue ;
139
140
141(*
142 GetConstFromFifoQueue - retrieves a const symbol
143 from a fifo queue.
144*)
145
146PROCEDURE GetConstFromFifoQueue (VAR c: CARDINAL) ;
147BEGIN
148 GetFrom(const, c)
149END GetConstFromFifoQueue ;
150
151
152(*
153 Init - initialize the fifo queue.
154*)
155
156PROCEDURE Init (VAR f: Fifo) ;
157BEGIN
158 WITH f DO
159 InitList(Queue) ;
160 Out := 0
161 END
162END Init ;
163
164
165BEGIN
166 Init(const) ;
167 Init(enumeration) ;
168 Init(subrange) ;
169 Init(constructor)
170END FifoQueue.