-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstack.c
More file actions
56 lines (46 loc) · 1.23 KB
/
stack.c
File metadata and controls
56 lines (46 loc) · 1.23 KB
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
49
50
51
52
53
54
55
56
#include "stack.h"
#include "malloc.h"
void push_stack_frame(struct stack_frame **f) {
struct stack_frame *p = alloc_stack_frame(*f);
*f = p;
}
void pop_stack_frame(struct stack_frame **f) {
/* we do not free, because bwd-gc says it will be more efficient */
*f = (*f)->prev;
}
int append_stack(struct stack_frame *f, struct exp *p, int *dot) {
struct pair *new;
if (*dot && f->dot_list)
return 1; /* error */
else if (*dot) {
new = (struct pair *)p;
f->dot_list = 1;
*dot = 0;
} else
new = alloc_pair(p, NULL);
*(f->tail) = new;
f->tail = (struct pair **)&new->cdr;
return 0;
}
void push_quote_stack(struct quote_stack **top) {
*top = alloc_quote_stack(*top);
}
void push_dot_stack(struct dot_stack **top) {
*top = alloc_dot_stack(*top);
}
void pop_dot_stack(struct dot_stack **top) {
/* we do not free, because bwd-gc says it will be more efficient */
*top = (*top)->prev;
}
void pop_quote_stack(struct quote_stack **top) {
/* we do not free, because bwd-gc says it will be more efficient */
*top = (*top)->prev;
}
void push_stack(struct stack **f) {
struct stack *p = alloc_stack(*f);
*f = p;
}
void pop_stack(struct stack **f) {
/* we do not free, because bwd-gc says it will be more efficient */
*f = (*f)->prev;
}