-
Notifications
You must be signed in to change notification settings - Fork 1
/
struct.fs
77 lines (57 loc) · 1 KB
/
struct.fs
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
\
\ Structures
\
: struct ( x -- ) constant ;
: field ( x x -- x )
over + swap create , does> @ + ;
0
cell field >next
struct list
: l_add ( na ha -- ) \ add node to list
2dup @ swap ! ! ;
: l_rm ( ha -- ) \ remove node from list
dup @ @ swap ! ;
: l_find ( xt ha -- na ) \ interate through list until xt returns true
begin @ dup while 2dup push push swap exec
if pull drop pull exit then
pull pull repeat nip exit ;
list
cell field >prev
struct dlist
: dl_add ( na ha -- ) \ add node to list
2dup @ >prev @ swap >prev !
single add:
head = n
n.next = 1
double add:
head = n
n.next = 1
n.prev = 1.prev
1.prev = n
1.prev.next = n
queue -
add to head
remove from tail
stack -
add to head
remove from head
names
single list
dynmem
single list
vocabs
single list
compile areas
extends
local names
single list
filesystems
double list
mounts
double list
files
double list
input stack
single list
processes
double list