From 53fcafb4f1f6b4c2ec4dc3d1222192269d23d207 Mon Sep 17 00:00:00 2001 From: Russ Olsen Date: Fri, 22 May 2020 15:07:40 -0400 Subject: [PATCH] Add proxy methods for functions to Vars. --- sallyforth/namespace.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sallyforth/namespace.py b/sallyforth/namespace.py index dd9cc6b..3a2063b 100644 --- a/sallyforth/namespace.py +++ b/sallyforth/namespace.py @@ -8,6 +8,32 @@ class Var: self.value = value self.dynamic = dynamic + def __call__(self, forth): + #print("indirect call on", self.name) + return self.value(forth) + + @property + def forth_immediate(self): + return self.value.forth_immediate + + @property + def forth_contents(self): + #print("indirect contents on", self.name) + return self.value.forth_contents + + @property + def forth_primitive(self): + return self.value.forth_primitive + + @property + def forth_name(self): + #print("indirect name on", self.name) + return self.value.forth_name + + @property + def forth_inline(self): + return self.value.forth_inline + def __str__(self): return f'[[[[Var({self.name}/{self.dynamic}::{self.value})]]]' @@ -77,6 +103,7 @@ class Namespace: return self.contents.__iter__() def __getitem__(self, key): + #print("getitem:", key) return self.contents.__getitem__(key) def __str__(self):