Commit 20f266d1 authored by Juergen Nickelsen's avatar Juergen Nickelsen

finished describe/method revamp

parent 554c145a
......@@ -165,9 +165,9 @@ class Error(Object):
def __repr__(self):
return str(self)
def describe(self):
a = super().describe()
a.update(self.e.__dict__)
return a
attrs = super().describe()
attrs.update(self.e.__dict__)
return attrs
_gensym_counter = 8385
......@@ -267,9 +267,10 @@ class Symbol(Object):
else:
raise PyleArgTypeError(self, 'cxr', 'list')
def describe(self):
a = super(Symbol, self).describe()
a["props"] = self._props
return a
attrs = super().describe()
attrs["props"] = self._props
return attrs
def init_symbol():
global Nil, T, ImmutableSymbol, FunctionSymbol, NamePropSymbol, IdPropSymbol
......@@ -335,13 +336,18 @@ class Macro(Function):
finally:
backtoEnvironment(savedEnv)
def describe(self):
return p2l({ "type": self.__class__.__name__, "id": id(self),
"name": self.name, "params": self.params,
"minargs": Number(self.minargs),
"maxargs": Number(self.maxargs),
"synopsis": self.synopsis(),
"docstring": self._docstring, "body": self.body,
attrs = super().describe()
attrs.update({
"name": self.name,
"params": self.params,
"minargs": Number(self.minargs),
"maxargs": Number(self.maxargs),
"synopsis": self.synopsis(),
"docstring": self._docstring,
"body": self.body,
})
return attrs
# this is used for parameter bindings on function calls and variable
# bindings in let/let*; destructuring binds will go here, too
......@@ -434,14 +440,19 @@ class Form(Function):
finally:
backtoEnvironment(savedEnv)
def describe(self):
return p2l({ "type": self.__class__.__name__, "id": id(self),
"env": self.env, "name": self.name, "params": self.params,
"minargs": Number(self.minargs),
"maxargs": Number(self.maxargs),
"synopsis": self.synopsis(),
"special": p2l(self.special),
"docstring": self._docstring, "body": self.body,
attrs = super().describe()
attrs.update({
"env": self.env,
"name": self.name,
"params": self.params,
"minargs": Number(self.minargs),
"maxargs": Number(self.maxargs),
"synopsis": self.synopsis(),
"special": p2l(self.special),
"docstring": self._docstring,
"body": self.body,
})
return attrs
class Builtin(Function):
def __init__(self, name, code, minargs, maxargs, special):
......@@ -467,14 +478,16 @@ class Builtin(Function):
def synopsis(self):
return self._synopsis
def describe(self):
return p2l({ "type": self.__class__.__name__, "id": id(self),
"name": self.name,
"minargs": Number(self.minargs),
"maxargs": Number(self.maxargs),
"synopsis": self._synopsis,
"special": p2l(self.special),
"docstring": self._docstring,
})
attrs = super().describe()
attrs.update({
"name": self.name,
"minargs": Number(self.minargs),
"maxargs": Number(self.maxargs),
"synopsis": self._synopsis,
"special": p2l(self.special),
"docstring": self._docstring,
})
return attrs
envcount = 0
......@@ -531,10 +544,13 @@ class Environment(Object):
def level(self):
return self._level
def describe(self):
return p2l({ "type": self.__class__.__name__, "id": id(self),
"level": self._level, "parent": self._parent,
"vars": p2l(self._map),
attrs = super().describe()
attrs.update({
"level": self._level,
"parent": self._parent,
"vars": p2l(self._map),
})
return attrs
symbolTable = {}
......@@ -613,9 +629,9 @@ class Number(Object):
def numValue(self):
return self._value
def describe(self):
return p2l({ "type": self.__class__.__name__, "id": id(self),
"value": self,
})
attrs = super().describe()
attrs["value"] = self
return attrs
escapeSpecials = {
"\a": "\\a", "\b": "\\b", "\f": "\\f", "\n": "\\n",
......@@ -651,9 +667,9 @@ class String(Object):
def strValue(self):
return self._value
def describe(self):
return p2l({ "type": self.__class__.__name__, "id": id(self),
"value": self,
})
attrs = super().describe()
attrs["value"] = self
return attrs
class Pair(Object):
def __init__(self, car, cdr):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment