feat: blackbox call

This commit is contained in:
Dan Chen
2024-03-21 15:59:35 +08:00
parent 726b926d98
commit 11e1659e22
12 changed files with 49 additions and 13 deletions

View File

@ -4,7 +4,8 @@ class Runtime:
self.parent = parent
self.records = records
def run(self, ast):
def run(self, ast, records={}):
self.records.update(records)
if ast["type"] == "Program":
return self.program(ast)
@ -44,6 +45,8 @@ class Runtime:
for arg in args:
unquoted_args.append(self.unquote(arg))
fu = self.records.get(id)
if fu == None:
raise Exception("Function not found: " + id)
return fu(*unquoted_args)
def unquote(self, ast):