From e002be77a858caf430c72836c219dfffc268f433 Mon Sep 17 00:00:00 2001 From: crc Date: Wed, 16 Dec 2020 20:33:37 +0000 Subject: [PATCH] nga-python: reading files working now FossilOrigin-Name: 23d2f2ffab871713281137c1645f797493aea0cbd450a00f86c550ce93a5a59e --- vm/nga-python/retro.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/vm/nga-python/retro.py b/vm/nga-python/retro.py index eb8b4f2..09f2f7f 100644 --- a/vm/nga-python/retro.py +++ b/vm/nga-python/retro.py @@ -345,12 +345,22 @@ class Retro: 29: lambda: stack.push(afloats.depth()), # alt. depth } + def file_open_params(self): + mode = self.stack.pop() + name = self.extract_string(self.stack.pop()) + return name, mode + + def file_write_params(self): + slot = self.stack.pop() + char = self.stack.pop() + return slot, char + def setup_devices(self): self.files_instr = { - 0: lambda: self.stack.push(self.files.open()), + 0: lambda: self.stack.push(self.files.open(self.file_open_params())), 1: lambda: self.files.close(self.stack.pop()), 2: lambda: self.stack.push(self.files.read(self.stack.pop())), - 3: lambda: self.files.write(), + 3: lambda: self.files.write(self.file_write_params()), 4: lambda: self.stack.push(self.files.pos(self.stack.pop())), 5: lambda: self.files.seek(), 6: lambda: self.stack.push(self.files.size(self.stack.pop())),