1.1 --- a/simplified.py Sun Oct 22 00:18:01 2006 +0200
1.2 +++ b/simplified.py Sun Oct 22 00:19:39 2006 +0200
1.3 @@ -107,6 +107,12 @@
1.4 results.append(self.dispatch(node, *args))
1.5 return results
1.6
1.7 + def dispatch_dict(self, d, *args):
1.8 + results = {}
1.9 + for name, node in d.items():
1.10 + results[name] = self.dispatch(node, *args)
1.11 + return results
1.12 +
1.13 # Simplified program nodes.
1.14
1.15 class Node:
1.16 @@ -248,8 +254,10 @@
1.17 if hasattr(self, "nstype"):
1.18 self._pprint(indent + 2, "", self.nstype, stream=stream)
1.19 if hasattr(self, "args"):
1.20 - for arg in self.args:
1.21 + for arg in self.pos_args:
1.22 arg.pprint(indent + 2, "( ", stream=stream)
1.23 + for name, arg in self.kw_args.items():
1.24 + arg.pprint(indent + 2, "( %s=" % name, stream=stream)
1.25 if hasattr(self, "star") and self.star:
1.26 self.star.pprint(indent + 2, "( ", stream=stream)
1.27 if hasattr(self, "dstar") and self.dstar:
1.28 @@ -307,7 +315,7 @@
1.29 "Sort the 'args' into positional and keyword arguments."
1.30
1.31 self.pos_args = []
1.32 - self.kw_args = []
1.33 + self.kw_args = {}
1.34 add_kw = 0
1.35 for arg in args:
1.36 if not add_kw:
1.37 @@ -317,7 +325,7 @@
1.38 add_kw = 1
1.39 if add_kw:
1.40 if isinstance(arg, Keyword):
1.41 - self.kw_args.append(arg)
1.42 + self.kw_args[arg.name] = arg
1.43 else:
1.44 raise TypeError, "Positional argument appears after keyword arguments in '%s'." % self
1.45
1.46 @@ -340,7 +348,7 @@
1.47 "A Python module."
1.48
1.49 def full_name(self):
1.50 - return self.name
1.51 + return "module %s" % self.name
1.52
1.53 class Subprogram(Node, WithName):
1.54
1.55 @@ -363,6 +371,9 @@
1.56 WithName.__init__(self)
1.57 self.instances = []
1.58
1.59 + def full_name(self):
1.60 + return "class %s" % self._full_name
1.61 +
1.62 class Instance(Structure):
1.63
1.64 "An instance."
1.65 @@ -370,7 +381,7 @@
1.66 def full_name(self):
1.67 # NOTE: Wrap the result in a call to name(self, ...) where multiple
1.68 # NOTE: instances per class can occur.
1.69 - return self.namespace.load("__class__")[0].type.full_name()
1.70 + return self.namespace.load("__class__")[0].type._full_name
1.71
1.72 def __repr__(self):
1.73 return "Instance of type '%s'" % self.full_name()