1.1 --- a/annotate.py Sun Dec 03 23:47:41 2006 +0100
1.2 +++ b/annotate.py Wed Dec 06 00:48:29 2006 +0100
1.3 @@ -122,7 +122,7 @@
1.4 Raise, ReleaseTemp, ReturnFromBlock, ReturnFromFunction, StoreAttr,
1.5 StoreName, StoreTemp, Subprogram, Try.
1.6
1.7 - Missing: Keyword, Global, Import.
1.8 + Missing: Global, Import.
1.9 """
1.10
1.11 def __init__(self):
1.12 @@ -698,6 +698,7 @@
1.13 writes = {}
1.14 non_writes = []
1.15 for attr in self.namespace.types:
1.16 + # NOTE: Impose "atomic" constraints on certain types.
1.17 if attr is None:
1.18 if not attr in non_writes:
1.19 non_writes.append(attr)
1.20 @@ -851,6 +852,16 @@
1.21 context = None
1.22 target = attribute.type
1.23
1.24 + # Test to see if anything has changed.
1.25 +
1.26 + if hasattr(invoke, "syscount") and invoke.syscount == self.system.count:
1.27 + return
1.28 +
1.29 + # Remember the state of the system.
1.30 +
1.31 + else:
1.32 + invoke.syscount = self.system.count
1.33 +
1.34 # Provide the correct namespace for the invocation.
1.35
1.36 if getattr(invoke, "share_locals", 0):
1.37 @@ -866,16 +877,6 @@
1.38 namespace.merge_items(items)
1.39 using_module_namespace = 0
1.40
1.41 - # Test to see if anything has changed.
1.42 -
1.43 - if hasattr(invoke, "syscount") and invoke.syscount == self.system.count:
1.44 - return
1.45 -
1.46 - # Remember the state of the system.
1.47 -
1.48 - else:
1.49 - invoke.syscount = self.system.count
1.50 -
1.51 # Process the subprogram.
1.52 # In order to keep global accesses working, the module namespace must be
1.53 # adjusted.
1.54 @@ -965,7 +966,11 @@
1.55 pos_args = [Self(context)] + invocation.pos_args
1.56 else:
1.57 pos_args = invocation.pos_args
1.58 - kw_args = invocation.kw_args
1.59 +
1.60 + # Duplicate the keyword arguments - we remove them in processing below.
1.61 +
1.62 + kw_args = {}
1.63 + kw_args.update(invocation.kw_args)
1.64
1.65 # Sort the arguments into positional and keyword arguments.
1.66
1.67 @@ -1038,9 +1043,9 @@
1.68 raise AnnotationMessage, "Invocation provides unwanted *args."
1.69 elif subprogram.star is not None:
1.70 param, default = subprogram.star
1.71 - if not hasattr(arg, "types"):
1.72 - arg = self.dispatch(default) # NOTE: Review reprocessing.
1.73 - items.append((param, arg.types))
1.74 + if not hasattr(default, "types"):
1.75 + subprogram.star = param, self.dispatch(default) # NOTE: Review reprocessing.
1.76 + items.append((param, default.types))
1.77
1.78 if dstar_types is not None:
1.79 if subprogram.dstar is not None:
1.80 @@ -1050,9 +1055,9 @@
1.81 raise AnnotationMessage, "Invocation provides unwanted **args."
1.82 elif subprogram.dstar is not None:
1.83 param, default = subprogram.dstar
1.84 - if not hasattr(arg, "types"):
1.85 - arg = self.dispatch(default) # NOTE: Review reprocessing.
1.86 - items.append((param, arg.types))
1.87 + if not hasattr(default, "types"):
1.88 + subprogram.dstar = param, self.dispatch(default) # NOTE: Review reprocessing.
1.89 + items.append((param, default.types))
1.90
1.91 # Record the parameter types.
1.92
2.1 --- a/simplified.py Sun Dec 03 23:47:41 2006 +0100
2.2 +++ b/simplified.py Wed Dec 06 00:48:29 2006 +0100
2.3 @@ -360,7 +360,7 @@
2.4 add_kw = 1
2.5 if add_kw:
2.6 if isinstance(arg, Keyword):
2.7 - self.kw_args[arg.name] = arg
2.8 + self.kw_args[arg.name] = arg.expr
2.9 else:
2.10 raise TypeError, "Positional argument appears after keyword arguments in '%s'." % self
2.11
3.1 --- a/simplify.py Sun Dec 03 23:47:41 2006 +0100
3.2 +++ b/simplify.py Wed Dec 06 00:48:29 2006 +0100
3.3 @@ -582,9 +582,10 @@
3.4 return result
3.5
3.6 def visitConst(self, const):
3.7 - if not self.constants.has_key(const.value):
3.8 - self.constants[const.value] = Constant(name=repr(const.value), value=const.value)
3.9 - result = LoadRef(const, 1, ref=self.constants[const.value])
3.10 + key = "%s-%s" % (const.value.__class__.__name__, const.value)
3.11 + if not self.constants.has_key(key):
3.12 + self.constants[key] = Constant(name=repr(const.value), value=const.value)
3.13 + result = LoadRef(const, 1, ref=self.constants[key])
3.14 return result
3.15
3.16 def visitContinue(self, continue_):
4.1 --- a/viewer.py Sun Dec 03 23:47:41 2006 +0100
4.2 +++ b/viewer.py Wed Dec 06 00:48:29 2006 +0100
4.3 @@ -589,7 +589,7 @@
4.4 self.stream.write("</span>\n")
4.5
4.6 def visitKeyword(self, node):
4.7 - self.stream.write("<span class='keyword'>\n")
4.8 + self.stream.write("<span class='keyword-arg'>\n")
4.9 self.stream.write(node.name)
4.10 self.stream.write("=")
4.11 self.dispatch(node.expr)