1 /* do not edit automatically generated by mc from mcStack. */
2 /* This file is part of GNU Modula-2.
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3. If not see
16 <http://www.gnu.org/licenses/>. */
21 # if !defined (PROC_D)
23 typedef void (*PROC_t
) (void);
24 typedef struct { PROC_t proc
; } PROC
;
27 # include "GStorage.h"
29 #if defined(__cplusplus)
36 # include "GStorage.h"
37 # include "GIndexing.h"
40 typedef struct mcStack__T1_r mcStack__T1
;
42 typedef mcStack__T1
*mcStack_stack__opaque
;
44 struct mcStack__T1_r
{
51 init - create and return a stack.
54 extern "C" mcStack_stack
mcStack_init (void);
57 kill - deletes stack, s.
60 extern "C" void mcStack_kill (mcStack_stack
*s
);
63 push - an address, a, onto the stack, s.
67 extern "C" void * mcStack_push (mcStack_stack s
, void * a
);
70 pop - and return the top element from stack, s.
73 extern "C" void * mcStack_pop (mcStack_stack s
);
76 replace - performs a pop; push (a); return a.
79 extern "C" void * mcStack_replace (mcStack_stack s
, void * a
);
82 depth - returns the depth of the stack.
85 extern "C" unsigned int mcStack_depth (mcStack_stack s
);
88 access - returns the, i, th stack element.
89 The top of stack is defined by:
91 access (s, depth (s)).
94 extern "C" void * mcStack_access (mcStack_stack s
, unsigned int i
);
98 init - create and return a stack.
101 extern "C" mcStack_stack
mcStack_init (void)
103 mcStack_stack__opaque s
;
105 Storage_ALLOCATE ((void **) &s
, sizeof (mcStack__T1
));
106 s
->list
= Indexing_InitIndex (1);
108 return static_cast<mcStack_stack
> (s
);
109 /* static analysis guarentees a RETURN statement will be used before here. */
110 __builtin_unreachable ();
115 kill - deletes stack, s.
118 extern "C" void mcStack_kill (mcStack_stack
*s
)
120 static_cast<mcStack_stack__opaque
> ((*s
))->list
= Indexing_KillIndex (static_cast<mcStack_stack__opaque
> ((*s
))->list
);
121 Storage_DEALLOCATE ((void **) &(*s
), sizeof (mcStack__T1
));
122 (*s
) = static_cast<mcStack_stack
> (NULL
);
127 push - an address, a, onto the stack, s.
131 extern "C" void * mcStack_push (mcStack_stack s
, void * a
)
133 if (static_cast<mcStack_stack__opaque
> (s
)->count
== 0)
135 Indexing_PutIndice (static_cast<mcStack_stack__opaque
> (s
)->list
, Indexing_LowIndice (static_cast<mcStack_stack__opaque
> (s
)->list
), a
);
139 Indexing_PutIndice (static_cast<mcStack_stack__opaque
> (s
)->list
, (Indexing_HighIndice (static_cast<mcStack_stack__opaque
> (s
)->list
))+1, a
);
141 static_cast<mcStack_stack__opaque
> (s
)->count
+= 1;
143 /* static analysis guarentees a RETURN statement will be used before here. */
144 __builtin_unreachable ();
149 pop - and return the top element from stack, s.
152 extern "C" void * mcStack_pop (mcStack_stack s
)
156 if (static_cast<mcStack_stack__opaque
> (s
)->count
== 0)
159 __builtin_unreachable ();
163 static_cast<mcStack_stack__opaque
> (s
)->count
-= 1;
164 a
= Indexing_GetIndice (static_cast<mcStack_stack__opaque
> (s
)->list
, Indexing_HighIndice (static_cast<mcStack_stack__opaque
> (s
)->list
));
165 Indexing_DeleteIndice (static_cast<mcStack_stack__opaque
> (s
)->list
, Indexing_HighIndice (static_cast<mcStack_stack__opaque
> (s
)->list
));
168 ReturnException ("../../gcc/m2/mc/mcStack.def", 20, 1);
169 __builtin_unreachable ();
174 replace - performs a pop; push (a); return a.
177 extern "C" void * mcStack_replace (mcStack_stack s
, void * a
)
182 return mcStack_push (s
, a
);
183 /* static analysis guarentees a RETURN statement will be used before here. */
184 __builtin_unreachable ();
189 depth - returns the depth of the stack.
192 extern "C" unsigned int mcStack_depth (mcStack_stack s
)
194 return static_cast<mcStack_stack__opaque
> (s
)->count
;
195 /* static analysis guarentees a RETURN statement will be used before here. */
196 __builtin_unreachable ();
201 access - returns the, i, th stack element.
202 The top of stack is defined by:
204 access (s, depth (s)).
207 extern "C" void * mcStack_access (mcStack_stack s
, unsigned int i
)
209 if ((i
> static_cast<mcStack_stack__opaque
> (s
)->count
) || (i
== 0))
212 __builtin_unreachable ();
216 return Indexing_GetIndice (static_cast<mcStack_stack__opaque
> (s
)->list
, i
);
218 ReturnException ("../../gcc/m2/mc/mcStack.def", 20, 1);
219 __builtin_unreachable ();
222 extern "C" void _M2_mcStack_init (__attribute__((unused
)) int argc
, __attribute__((unused
)) char *argv
[], __attribute__((unused
)) char *envp
[])
226 extern "C" void _M2_mcStack_fini (__attribute__((unused
)) int argc
, __attribute__((unused
)) char *argv
[], __attribute__((unused
)) char *envp
[])