Skip to content
← Back

src/source/location_stack.ghul

1
namespace Source is
2
class LOCATION_STACK is
3
_stack: Collections.STACK[LOCATION]
4
5
init() is
6
_stack = Collections.STACK[LOCATION]()
7
si
8
9
is_empty: bool => _stack.count == 0
10
11
current: LOCATION? =>
12
if _stack.count > 0 then
13
_stack.peek()
14
else
15
null
16
fi
17
18
push(location: LOCATION) is
19
_stack.push(location)
20
si
21
22
pop() is
23
assert _stack.count > 0
24
_stack.pop()
25
si
26
si
27
si