| 1 |
(* M2StackWord.def provides a generic stack for WORD sized objects. |
| 2 |
|
| 3 |
Copyright (C) 2001-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 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 |
DEFINITION MODULE M2StackWord ; |
| 23 |
|
| 24 |
(* |
| 25 |
Title : M2StackWord |
| 26 |
Author : Gaius Mulley |
| 27 |
System : UNIX (GNU Modula-2) |
| 28 |
Date : Fri Oct 12 17:26:50 2001 |
| 29 |
Revision : $Version$ |
| 30 |
Description: provides a generic stack for WORD sized objects. |
| 31 |
*) |
| 32 |
|
| 33 |
FROM SYSTEM IMPORT WORD ; |
| 34 |
EXPORT QUALIFIED StackOfWord, InitStackWord, KillStackWord, PushWord, |
| 35 |
ReduceWord, RemoveTop, PopWord, PeepWord, IsEmptyWord, |
| 36 |
NoOfItemsInStackWord ; |
| 37 |
|
| 38 |
TYPE |
| 39 |
StackOfWord ; |
| 40 |
|
| 41 |
|
| 42 |
(* |
| 43 |
InitStackWord - creates and returns a new stack. |
| 44 |
*) |
| 45 |
|
| 46 |
PROCEDURE InitStackWord () : StackOfWord ; |
| 47 |
|
| 48 |
|
| 49 |
(* |
| 50 |
KillStackWord - destroys a stack, returning NIL. |
| 51 |
*) |
| 52 |
|
| 53 |
PROCEDURE KillStackWord (s: StackOfWord) : StackOfWord ; |
| 54 |
|
| 55 |
|
| 56 |
(* |
| 57 |
PushWord - pushes a word, w, onto, s. |
| 58 |
*) |
| 59 |
|
| 60 |
PROCEDURE PushWord (s: StackOfWord; w: WORD) ; |
| 61 |
|
| 62 |
|
| 63 |
(* |
| 64 |
PopWord - pops an element from stack, s. |
| 65 |
*) |
| 66 |
|
| 67 |
PROCEDURE PopWord (s: StackOfWord) : WORD ; |
| 68 |
|
| 69 |
|
| 70 |
(* |
| 71 |
IsEmptyWord - returns TRUE if stack, s, is empty. |
| 72 |
*) |
| 73 |
|
| 74 |
PROCEDURE IsEmptyWord (s: StackOfWord) : BOOLEAN ; |
| 75 |
|
| 76 |
|
| 77 |
(* |
| 78 |
PeepWord - returns the element at, n, items below in the stack. |
| 79 |
Top of stack can be seen via Peep(s, 1) |
| 80 |
*) |
| 81 |
|
| 82 |
PROCEDURE PeepWord (s: StackOfWord; n: CARDINAL) : WORD ; |
| 83 |
|
| 84 |
|
| 85 |
(* |
| 86 |
ReduceWord - reduce the stack by n elements. |
| 87 |
*) |
| 88 |
|
| 89 |
PROCEDURE ReduceWord (s: StackOfWord; n: CARDINAL) ; |
| 90 |
|
| 91 |
|
| 92 |
(* |
| 93 |
RemoveTop - throw away the top element of the stack. |
| 94 |
*) |
| 95 |
|
| 96 |
PROCEDURE RemoveTop (s: StackOfWord) ; |
| 97 |
|
| 98 |
|
| 99 |
(* |
| 100 |
NoOfItemsInStackWord - returns the number of items held in the stack, s. |
| 101 |
*) |
| 102 |
|
| 103 |
PROCEDURE NoOfItemsInStackWord (s: StackOfWord) : CARDINAL ; |
| 104 |
|
| 105 |
|
| 106 |
END M2StackWord. |