mirror of
https://github.com/russolsen/sallyforth
synced 2024-12-26 21:58:32 +01:00
Add proxy methods for functions to Vars.
This commit is contained in:
parent
4c03ea5388
commit
53fcafb4f1
1 changed files with 27 additions and 0 deletions
|
@ -8,6 +8,32 @@ class Var:
|
||||||
self.value = value
|
self.value = value
|
||||||
self.dynamic = dynamic
|
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):
|
def __str__(self):
|
||||||
return f'[[[[Var({self.name}/{self.dynamic}::{self.value})]]]'
|
return f'[[[[Var({self.name}/{self.dynamic}::{self.value})]]]'
|
||||||
|
|
||||||
|
@ -77,6 +103,7 @@ class Namespace:
|
||||||
return self.contents.__iter__()
|
return self.contents.__iter__()
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
#print("getitem:", key)
|
||||||
return self.contents.__getitem__(key)
|
return self.contents.__getitem__(key)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in a new issue