retroforth/vm/nga-python/IntegerStack.py
crc 4e78a4ef15 nga-python: IntegerStack now derives from list (#20)
FossilOrigin-Name: 9cebb1e22b77545581e67fa6224286cba01a526684340452a858aa795b42af8c
2020-12-17 19:47:17 +00:00

24 lines
421 B
Python

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