nga-python: use Python int() function in override for s:to-number (#20)

FossilOrigin-Name: 27e48826a02a254fab1e4ecc342a8f78b8ab2dff5769b96ae85e5147b04338fd
This commit is contained in:
crc 2020-12-16 19:25:52 +00:00
parent 97f1ad6319
commit 93290ac28d

View file

@ -51,6 +51,7 @@ class Retro:
self.Cached["interpreter"] = self.map_in("interpret")
self.Cached["not_found"] = self.map_in("err:notfound")
self.Cached["s:eq?"] = self.map_in("s:eq?")
self.Cached["s:to-number"] = self.map_in("s:to-number")
self.Cached["d:lookup"] = self.map_in("d:lookup")
self.instructions = [
@ -439,6 +440,10 @@ class Retro:
self.stack.push(header)
self.memory.store(header, self.Cached["d:lookup"] - 20) # "which"
self.ip = self.address.pop()
elif self.ip == self.Cached["s:to-number"]:
n = self.extract_string(self.stack.pop())
self.stack.push(int(n))
self.ip = self.address.pop()
else:
if self.ip == notfound:
print("ERROR: word not found!")