Add alloc command

This commit is contained in:
rmgr 2022-06-29 16:49:38 +09:30
parent d806b00b3f
commit 9b90f3fa33
1 changed files with 9 additions and 1 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/python3
import argparse
stack = []
heap = [0] * 10
heap = [0] * 20
next_heap = 0
compiling = False
words = {}
@ -64,6 +64,8 @@ def parse_input(input_string, say_ok=True):
fetch()
elif string == "heap":
dump_heap()
elif string == "alloc":
alloc()
else:
if string == ";":
stop_compiling()
@ -76,6 +78,12 @@ def parse_input(input_string, say_ok=True):
def dump_heap():
print(heap)
def alloc():
global next_heap
heap[next_heap] = 0
stack.insert(0, next_heap)
next_heap += 1
def store():
k = stack.pop(0)
v = stack.pop(0)