hacked this over lunch
This commit is contained in:
parent
4f5bc16508
commit
a1af08819d
@ -18,9 +18,10 @@ def _fn(obj):
|
|||||||
for i in range(0, len(sig)):
|
for i in range(0, len(sig)):
|
||||||
name = sig[i]
|
name = sig[i]
|
||||||
value = args[i]
|
value = args[i]
|
||||||
obj.local_namespace[name] = value
|
meth.local_namespace[name] = value
|
||||||
|
|
||||||
return meth(*args, **kwargs)
|
ret = meth(*args, **kwargs)
|
||||||
|
return ret
|
||||||
return _
|
return _
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@ class HYExpression(list, HYObject):
|
|||||||
|
|
||||||
things = []
|
things = []
|
||||||
for child in self.get_children():
|
for child in self.get_children():
|
||||||
things.append(child())
|
c = child.copy()
|
||||||
|
things.append(c())
|
||||||
|
print c, things
|
||||||
|
|
||||||
ret = self.lookup(fn)(*things, **kwargs)
|
ret = self.lookup(fn)(*things, **kwargs)
|
||||||
return ret
|
return ret
|
||||||
|
@ -7,7 +7,7 @@ class HYObject(object):
|
|||||||
self.local_namespace = nns
|
self.local_namespace = nns
|
||||||
|
|
||||||
for c in self.get_children():
|
for c in self.get_children():
|
||||||
c.set_namespace(ns, ls=nns)
|
c.set_namespace(ns, nns)
|
||||||
|
|
||||||
def get_children(self):
|
def get_children(self):
|
||||||
return []
|
return []
|
||||||
@ -19,11 +19,12 @@ class HYObject(object):
|
|||||||
callee = None
|
callee = None
|
||||||
if fn in self.local_namespace:
|
if fn in self.local_namespace:
|
||||||
callee = self.local_namespace[fn]
|
callee = self.local_namespace[fn]
|
||||||
|
print "%s = %s (ls %s)" % (fn, callee, id(self.local_namespace))
|
||||||
|
|
||||||
if callee is None and fn in self.namespace:
|
elif callee is None and fn in self.namespace:
|
||||||
callee = self.namespace[fn]
|
callee = self.namespace[fn]
|
||||||
|
|
||||||
if callee is None and "." in fn:
|
elif callee is None and "." in fn:
|
||||||
lon, short = fn.rsplit(".", 1)
|
lon, short = fn.rsplit(".", 1)
|
||||||
holder = self.lookup(lon)
|
holder = self.lookup(lon)
|
||||||
callee = getattr(holder, short)
|
callee = getattr(holder, short)
|
||||||
@ -37,3 +38,8 @@ class HYObject(object):
|
|||||||
for node in self.get_children():
|
for node in self.get_children():
|
||||||
node.eval(*args, **kwargs)
|
node.eval(*args, **kwargs)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def copy(self):
|
||||||
|
new = type(self)(self)
|
||||||
|
new.set_namespace(self.namespace, self.local_namespace)
|
||||||
|
return new
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from hy.lang.hyobj import HYObject
|
from hy.lang.hyobj import HYObject
|
||||||
|
|
||||||
|
|
||||||
class HYNumber(int, HYObject):
|
class HYNumber(HYObject, int):
|
||||||
def __init__(self, number):
|
def __new__(cls, number, *args, **kwargs):
|
||||||
if isinstance(number, HYObject):
|
if isinstance(number, HYObject):
|
||||||
number = number.eval()
|
number = number.eval()
|
||||||
number = int(number)
|
number = int(number)
|
||||||
self = number
|
return super(HYNumber, cls).__new__(cls, number)
|
||||||
|
|
||||||
def eval(self, *args, **kwargs):
|
def eval(self, *args, **kwargs):
|
||||||
return int(self)
|
return int(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user