retroforth/vm/nga-python/IntegerStack.py
crc 9c48935d22 nga-python: implement Memory class, switch to this; complete updates to using IntegerStack class
FossilOrigin-Name: f3d9ce597322e35c5f32a97d198e6ae0c3e1231d64edb50188488ca49a321044
2020-11-18 21:03:45 +00:00

30 lines
595 B
Python

class IntegerStack():
def __init__(self):
self.stack = [] * 128
def depth(self):
return len(self.stack)
def tos(self):
return self.stack[-1]
def push(self, v):
self.stack.append(v)
def append(self, v):
self.stack.append(v)
def pop(self):
return self.stack.pop()
def dup(self):
self.stack.append(self.stack[-1])
def drop(self):
self.stack.pop()
def swap(self):
a = self.stack[-2]
self.stack[-2] = self.stack[-1]
self.stack[-1] = a