]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/mc/mcStack.def
75a3da8cc83e85eeed4e173e7b5d74c7ddab9739
[thirdparty/gcc.git] / gcc / m2 / mc / mcStack.def
1 (* mcStack.def provides a stack data type and associated procedures.
2
3 Copyright (C) 2015-2024 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 DEFINITION MODULE mcStack ;
23
24
25 FROM SYSTEM IMPORT ADDRESS ;
26
27 TYPE
28 stack ;
29
30
31 (*
32 init - create and return a stack.
33 *)
34
35 PROCEDURE init () : stack ;
36
37
38 (*
39 kill - deletes stack, s.
40 *)
41
42 PROCEDURE kill (VAR s: stack) ;
43
44
45 (*
46 push - an address, a, onto the stack, s.
47 It returns, a.
48 *)
49
50 PROCEDURE push (s: stack; a: ADDRESS) : ADDRESS ;
51
52
53 (*
54 pop - and return the top element from stack, s.
55 *)
56
57 PROCEDURE pop (s: stack) : ADDRESS ;
58
59
60 (*
61 replace - performs a pop; push (a); return a.
62 *)
63
64 PROCEDURE replace (s: stack; a: ADDRESS) : ADDRESS ;
65
66
67 (*
68 depth - returns the depth of the stack.
69 *)
70
71 PROCEDURE depth (s: stack) : CARDINAL ;
72
73
74 (*
75 access - returns the, i, th stack element.
76 The top of stack is defined by:
77
78 access (s, depth (s)).
79 *)
80
81 PROCEDURE access (s: stack; i: CARDINAL) : ADDRESS ;
82
83
84 END mcStack.