-
Notifications
You must be signed in to change notification settings - Fork 20
/
yla_stack.h
48 lines (33 loc) · 1.41 KB
/
yla_stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
Int stack header file
This file is part of YLA VM (Yet another Language for Academic purpose: Virtual Machine).
YLA VM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Foobar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _yla_stack_h
#define _yla_stack_h
#include <stddef.h>
#include "yla_type.h"
typedef struct {
int *ptr;
size_t size;
size_t count;
} yla_stack;
void yla_stack_init(yla_stack* stack, size_t size);
void yla_stack_done(yla_stack* stack);
int yla_stack_push(yla_stack* stack, yla_int_type value);
int yla_stack_pull(yla_stack* stack, yla_int_type *result);
int yla_stack_set_deep(yla_stack* stack, size_t index, yla_int_type value);
int yla_stack_get_deep(yla_stack* stack, size_t index, yla_int_type *result);
int yla_stack_top(yla_stack* stack, yla_int_type *result);
int yla_stack_is_empty(yla_stack* stack);
int yla_stack_is_full(yla_stack* stack);
#endif