1.1 --- a/annotate.py Fri Feb 23 01:29:50 2007 +0100
1.2 +++ b/annotate.py Sun Feb 25 01:50:23 2007 +0100
1.3 @@ -131,7 +131,7 @@
1.4 types possible when the means of constructing the namespace may depend on
1.5 run-time behaviour.
1.6
1.7 - Covered: Assign, CheckType, Conditional, Global, Import, InvokeBlock,
1.8 + Covered: Assign, CheckType, Conditional, Global, Import, InvokeRef,
1.9 InvokeFunction, LoadAttr, LoadExc, LoadName, LoadRef, LoadTemp,
1.10 Module, Not, Pass, Raise, ReleaseTemp, ReturnFromBlock,
1.11 ReturnFromFunction, StoreAttr, StoreName, StoreTemp, Subprogram,
1.12 @@ -160,6 +160,7 @@
1.13 self.subprograms = []
1.14 self.current_subprograms = []
1.15 self.current_namespaces = []
1.16 + self.rerun_subprograms = {}
1.17 self.namespace = None
1.18 self.module = module
1.19
1.20 @@ -188,6 +189,14 @@
1.21 mutate nodes in the original program.
1.22 """
1.23
1.24 + # Recursion test.
1.25 +
1.26 + if node in self.current_subprograms:
1.27 + if not self.rerun_subprograms.has_key(node):
1.28 + self.rerun_subprograms[node] = []
1.29 + self.rerun_subprograms[node].append(locals)
1.30 + return node
1.31 +
1.32 # Record the current subprogram and namespace.
1.33
1.34 self.current_subprograms.append(node)
1.35 @@ -215,6 +224,15 @@
1.36
1.37 node.namespace = self.namespace
1.38 result = self.dispatch(node)
1.39 +
1.40 + while self.rerun_subprograms.has_key(node):
1.41 + all_rerun_locals = self.rerun_subprograms[node]
1.42 + del self.rerun_subprograms[node]
1.43 + for rerun_locals in all_rerun_locals:
1.44 + print "Re-running", node, "with", rerun_locals
1.45 + node.namespace = self.namespace = rerun_locals
1.46 + result = self.dispatch(node)
1.47 +
1.48 result.namespace = self.namespace
1.49 if not hasattr(result, "raises"):
1.50 result.raises = []
1.51 @@ -479,6 +497,10 @@
1.52 if attribute is not None:
1.53 attribute = Attribute(instance, attribute.type)
1.54
1.55 + # Request an instance-specific initialiser.
1.56 +
1.57 + attribute = attr.type.get_attribute_for_instance(attribute, instance)
1.58 +
1.59 # Skip cases where no callable is found.
1.60
1.61 if attribute is not None:
1.62 @@ -516,15 +538,25 @@
1.63 self.namespace.set_types(getattr(invoke, "types", []))
1.64 return invoke
1.65
1.66 - def visitInvokeBlock(self, invoke):
1.67 + def visitInvokeRef(self, invoke):
1.68
1.69 """
1.70 Return the processed 'invoke' node, first finding the callables
1.71 - indicated by the expression.
1.72 + indicated by the reference.
1.73 """
1.74
1.75 - invoke.expr = self.dispatch(invoke.expr)
1.76 - invocation_types = self.namespace.types
1.77 + # Where the invocation belongs to an instance but the invoked subprogram
1.78 + # does not, request a special copy.
1.79 +
1.80 + instance = getattr(invoke, "instance", None)
1.81 + if instance is not None and getattr(invoke.ref, "instance", None) is None:
1.82 + if invoke.ref.copies.has_key(instance):
1.83 + invoke.ref = invoke.ref.copies[instance]
1.84 + else:
1.85 + invoke.ref = invoke.ref.copy(instance)
1.86 + print "Created", invoke.ref, "for", getattr(invoke.ref, "instance", None)
1.87 + invoke.ref.module.simplifier.subnames[invoke.ref.full_name()] = invoke.ref
1.88 + invocation_types = [Attribute(None, invoke.ref)]
1.89 return self._visitInvoke(invoke, invocation_types, have_args=0)
1.90
1.91 def visitInvokeFunction(self, invoke):
1.92 @@ -1169,12 +1201,18 @@
1.93 invocation.stars = {}
1.94
1.95 if not invocation.stars.has_key(subprogram.full_name()):
1.96 + instance = getattr(invocation, "instance", None)
1.97 +
1.98 code=[
1.99 StoreTemp(
1.100 + instance=instance,
1.101 expr=InvokeFunction(
1.102 invocation.original,
1.103 + instance=instance,
1.104 expr=LoadAttr(
1.105 + instance=instance,
1.106 expr=LoadRef(
1.107 + instance=instance,
1.108 ref=self.builtins
1.109 ),
1.110 name="list",
1.111 @@ -1191,8 +1229,12 @@
1.112 code.append(
1.113 InvokeFunction(
1.114 invocation.original,
1.115 + instance=instance,
1.116 expr=LoadAttr(
1.117 - expr=LoadTemp(),
1.118 + instance=instance,
1.119 + expr=LoadTemp(
1.120 + instance=instance
1.121 + ),
1.122 name="append"
1.123 ),
1.124 args=[arg],
1.125 @@ -1202,21 +1244,27 @@
1.126 )
1.127
1.128 code += [
1.129 - Return(expr=LoadTemp(release=1))
1.130 + Return(
1.131 + instance=instance,
1.132 + expr=LoadTemp(
1.133 + instance=instance,
1.134 + release=1
1.135 + )
1.136 + )
1.137 ]
1.138
1.139 - invocation.stars[subprogram.full_name()] = InvokeBlock(
1.140 + invocation.stars[subprogram.full_name()] = InvokeRef(
1.141 invocation.original,
1.142 + instance=instance,
1.143 produces_result=1,
1.144 - expr=LoadRef(
1.145 - ref=Subprogram(
1.146 - name=None,
1.147 - returns_value=1,
1.148 - params=[],
1.149 - star=None,
1.150 - dstar=None,
1.151 - code=code
1.152 - )
1.153 + ref=Subprogram(
1.154 + instance=instance,
1.155 + name=None,
1.156 + returns_value=1,
1.157 + params=[],
1.158 + star=None,
1.159 + dstar=None,
1.160 + code=code
1.161 )
1.162 )
1.163
1.164 @@ -1233,12 +1281,18 @@
1.165 invocation.dstars = {}
1.166
1.167 if not invocation.dstars.has_key(subprogram.full_name()):
1.168 + instance = getattr(invocation, "instance", None)
1.169 +
1.170 code=[
1.171 StoreTemp(
1.172 + instance=instance,
1.173 expr=InvokeFunction(
1.174 invocation.original,
1.175 + instance=instance,
1.176 expr=LoadAttr(
1.177 + instance=instance,
1.178 expr=LoadRef(
1.179 + instance=instance,
1.180 ref=self.builtins
1.181 ),
1.182 name="dict",
1.183 @@ -1252,22 +1306,31 @@
1.184
1.185 # NOTE: Constant not added to table.
1.186
1.187 - constant = Constant(name=repr(arg), value=arg, namespace=Namespace())
1.188 + constant = Constant(
1.189 + instance=instance,
1.190 + name=repr(arg), value=arg, namespace=Namespace()
1.191 + )
1.192 #constant.namespace.store("__class__", self.get_builtin_instances(invocation, constant.typename))
1.193 code += [
1.194 StoreTemp(
1.195 + instance=instance,
1.196 expr=LoadRef(
1.197 + instance=instance,
1.198 ref=constant
1.199 ),
1.200 index="const"
1.201 ),
1.202 StoreAttr(
1.203 + instance=instance,
1.204 lvalue=LoadTemp(
1.205 + instance=instance,
1.206 index="const"
1.207 ),
1.208 name="__class__",
1.209 expr=LoadAttr(
1.210 + instance=instance,
1.211 expr=LoadRef(
1.212 + instance=instance,
1.213 ref=self.builtins
1.214 ),
1.215 name=constant.typename,
1.216 @@ -1276,12 +1339,17 @@
1.217 ),
1.218 InvokeFunction(
1.219 invocation.original,
1.220 + instance=instance,
1.221 expr=LoadAttr(
1.222 - expr=LoadTemp(),
1.223 + instance=instance,
1.224 + expr=LoadTemp(
1.225 + instance=instance
1.226 + ),
1.227 name="__setitem__"
1.228 ),
1.229 args=[
1.230 LoadTemp(
1.231 + instance=instance,
1.232 index="const",
1.233 release=1
1.234 ),
1.235 @@ -1291,21 +1359,27 @@
1.236 ]
1.237
1.238 code += [
1.239 - Return(expr=LoadTemp(release=1))
1.240 + Return(
1.241 + instance=instance,
1.242 + expr=LoadTemp(
1.243 + instance=instance,
1.244 + release=1
1.245 + )
1.246 + )
1.247 ]
1.248
1.249 - invocation.dstars[subprogram.full_name()] = InvokeBlock(
1.250 + invocation.dstars[subprogram.full_name()] = InvokeRef(
1.251 invocation.original,
1.252 + instance=instance,
1.253 produces_result=1,
1.254 - expr=LoadRef(
1.255 - ref=Subprogram(
1.256 - name=None,
1.257 - returns_value=1,
1.258 - params=[],
1.259 - star=None,
1.260 - dstar=None,
1.261 - code=code
1.262 - )
1.263 + ref=Subprogram(
1.264 + instance=instance,
1.265 + name=None,
1.266 + returns_value=1,
1.267 + params=[],
1.268 + star=None,
1.269 + dstar=None,
1.270 + code=code
1.271 )
1.272 )
1.273
2.1 --- a/fixnames.py Fri Feb 23 01:29:50 2007 +0100
2.2 +++ b/fixnames.py Sun Feb 25 01:50:23 2007 +0100
2.3 @@ -396,14 +396,14 @@
2.4
2.5 return self.default(invoke)
2.6
2.7 - def visitInvokeBlock(self, invoke):
2.8 + def visitInvokeRef(self, invoke):
2.9
2.10 "Transform the 'invoke' node, performing processing on subprograms."
2.11
2.12 # The special case of internal subprogram invocation is addressed by
2.13 # propagating namespace information to the subprogram and processing it.
2.14
2.15 - subprogram = self.process_node(invoke.expr.ref, self.namespace)
2.16 + subprogram = self.process_node(invoke.ref, self.namespace)
2.17 if subprogram is not None:
2.18 self.subprograms.append(subprogram)
2.19 return invoke
3.1 --- a/lib/builtins.py Fri Feb 23 01:29:50 2007 +0100
3.2 +++ b/lib/builtins.py Sun Feb 25 01:50:23 2007 +0100
3.3 @@ -458,9 +458,10 @@
3.4 return self != 0
3.5
3.6 class list:
3.7 - def __init__(self, *args):
3.8 - for arg in args:
3.9 - self.append(arg)
3.10 + def __init__(self, args=None):
3.11 + if args is not None:
3.12 + for arg in args:
3.13 + self.append(arg)
3.14
3.15 def __getitem__(self, index):
3.16 if -len(self) <= index < len(self):
4.1 --- a/simplified.py Fri Feb 23 01:29:50 2007 +0100
4.2 +++ b/simplified.py Sun Feb 25 01:50:23 2007 +0100
4.3 @@ -163,7 +163,8 @@
4.4 """
4.5
4.6 common_attributes = "name", "index", "value", "nstype", "internal", "returns_value", "is_method", "ref", "module", "structures", "original"
4.7 - expression_attributes = "expr", "lvalue", "test", "star", "dstar"
4.8 + expression_attributes = "expr", "lvalue", "test"
4.9 + argument_attributes = "star", "dstar"
4.10 invocation_attributes = "params", # not "args" - see "pos_args", "kw_args"
4.11 grouping_attributes = "code", "body", "else_", "handler", "finally_", "choices"
4.12
4.13 @@ -177,7 +178,7 @@
4.14
4.15 self.original = original
4.16 self.defining = defining
4.17 - self.copies = []
4.18 + self.copies = {}
4.19
4.20 if self.original is not None and defining:
4.21 self.original._node = self
4.22 @@ -301,15 +302,16 @@
4.23
4.24 "Return the active copies of this node or a list containing this node."
4.25
4.26 - return self.copies or [self]
4.27 + return self.copies.values() or [self]
4.28
4.29 # Node manipulation functions.
4.30
4.31 - def copy(self, new_name=None):
4.32 + def copy(self, instance=None, new_name=None):
4.33
4.34 """
4.35 - Perform a deep copy of the node, optionally specifying a 'new_name',
4.36 - returning a new unannotated copy.
4.37 + Perform a deep copy of the node, optionally specifying the 'instance'
4.38 + for whom the copy has been requested and a 'new_name' for the copied
4.39 + node. Return new unannotated copies of the node and its descendants.
4.40 """
4.41
4.42 # Copy the common attributes of this node.
4.43 @@ -319,6 +321,10 @@
4.44 if hasattr(self, attr):
4.45 common[attr] = getattr(self, attr)
4.46
4.47 + # Add new attributes specially for copies.
4.48 +
4.49 + common["instance"] = instance
4.50 +
4.51 if new_name is not None:
4.52 common["copy_of"] = self
4.53 common["name"] = new_name
4.54 @@ -330,7 +336,7 @@
4.55
4.56 # Add links to copies from originals.
4.57
4.58 - self.copies.append(node)
4.59 + self.copies[instance] = node
4.60
4.61 # Copy attributes of different types.
4.62
4.63 @@ -340,9 +346,20 @@
4.64 if n is None:
4.65 n2 = n
4.66 else:
4.67 - n2 = n.copy()
4.68 + n2 = n.copy(instance)
4.69 setattr(node, attr, n2)
4.70
4.71 + for attr in self.argument_attributes:
4.72 + if hasattr(self, attr):
4.73 + t = getattr(self, attr)
4.74 + if t is None:
4.75 + t2 = t
4.76 + else:
4.77 + name, n = t
4.78 + n2 = n.copy(instance)
4.79 + t2 = name, n2
4.80 + setattr(node, attr, t2)
4.81 +
4.82 for attr in self.invocation_attributes:
4.83 if hasattr(self, attr):
4.84 l = getattr(self, attr)
4.85 @@ -351,23 +368,23 @@
4.86 if n is None:
4.87 l2.append((name, n))
4.88 else:
4.89 - l2.append((name, n.copy()))
4.90 + l2.append((name, n.copy(instance)))
4.91 setattr(node, attr, l2)
4.92
4.93 for attr in self.grouping_attributes:
4.94 if hasattr(self, attr):
4.95 l = getattr(self, attr)
4.96 - setattr(node, attr, [n.copy() for n in l])
4.97 + setattr(node, attr, [n.copy(instance) for n in l])
4.98
4.99 # Arguments are usually processed further - "args" is useless.
4.100
4.101 if hasattr(self, "pos_args"):
4.102 - node.pos_args = [n.copy() for n in self.pos_args]
4.103 + node.pos_args = [n.copy(instance) for n in self.pos_args]
4.104
4.105 if hasattr(self, "kw_args"):
4.106 node.kw_args = {}
4.107 for name, n in self.kw_args.items():
4.108 - node.kw_args[name] = n.copy()
4.109 + node.kw_args[name] = n.copy(instance)
4.110
4.111 return node
4.112
4.113 @@ -482,7 +499,7 @@
4.114 else:
4.115 raise TypeError, "Positional argument appears after keyword arguments in '%s'." % self
4.116
4.117 -class InvokeBlock(Invoke):
4.118 +class InvokeRef(Invoke):
4.119
4.120 "A block or loop invocation."
4.121
4.122 @@ -574,12 +591,23 @@
4.123 # Attribute propagation.
4.124
4.125 def get_attribute_for_instance(self, attribute, instance):
4.126 +
4.127 + # Create specialised methods.
4.128 +
4.129 if isinstance(attribute.type, Subprogram):
4.130 subprogram = attribute.type
4.131 +
4.132 + # Each instance may have its own version of the subprogram.
4.133 +
4.134 key = (subprogram, instance)
4.135 if not self.attributes_for_instances.has_key(key):
4.136 - self.attributes_for_instances[key] = Attribute(attribute.context, subprogram.copy(subprogram.full_name()))
4.137 + self.attributes_for_instances[key] = Attribute(attribute.context, subprogram.copy(instance, subprogram.full_name()))
4.138 + print "New subprogram", self.attributes_for_instances[key].type, "for", key
4.139 +
4.140 return self.attributes_for_instances[key]
4.141 +
4.142 + # The original nodes are returned for other attributes.
4.143 +
4.144 else:
4.145 return attribute
4.146
4.147 @@ -593,6 +621,44 @@
4.148 else:
4.149 return MultipleInstanceClass._get_key(self, node)
4.150
4.151 +class ProlificMultipleInstanceClass(MultipleInstanceClass):
4.152 +
4.153 + """
4.154 + A Python class which provides multiple instances for different versions of
4.155 + methods. In order to avoid unbounded instance production (since new
4.156 + instances cause new copies of methods which in turn would cause new
4.157 + instances),
4.158 + """
4.159 +
4.160 + def __init__(self, *args, **kw):
4.161 + MultipleInstanceClass.__init__(self, *args, **kw)
4.162 + self.instance_relations = {}
4.163 +
4.164 + def _get_key(self, node):
4.165 + if self.namespace.has_key("__atomic__"):
4.166 + return id(self)
4.167 + else:
4.168 + return id(node)
4.169 +
4.170 + def has_instance(self, node):
4.171 + requesting_instance = getattr(node, "instance", None)
4.172 + return requesting_instance is not None and requesting_instance.get_class() is self or \
4.173 + self.instance_relations.has_key(requesting_instance) or self.instances.has_key(self._get_key(node))
4.174 +
4.175 + def add_instance(self, node, instance):
4.176 + requesting_instance = getattr(node, "instance", None)
4.177 + print "New instance", instance, "for", id(node), requesting_instance
4.178 + self.instances[self._get_key(node)] = instance
4.179 + if requesting_instance is not None:
4.180 + self.instance_relations[requesting_instance] = instance
4.181 + requesting_instance.get_class().instance_relations[instance] = requesting_instance
4.182 +
4.183 + def get_instance(self, node):
4.184 + requesting_instance = getattr(node, "instance", None)
4.185 + if requesting_instance is not None and requesting_instance.get_class() is self:
4.186 + return requesting_instance
4.187 + return self.instance_relations.get(requesting_instance) or self.instances[self._get_key(node)]
4.188 +
4.189 class Instance(Structure):
4.190
4.191 "An instance."
4.192 @@ -686,4 +752,8 @@
4.193 global Class
4.194 Class = SelectiveMultipleInstanceClass
4.195
4.196 +def set_prolific_multiple_instance_mode():
4.197 + global Class
4.198 + Class = ProlificMultipleInstanceClass
4.199 +
4.200 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/simplify.py Fri Feb 23 01:29:50 2007 +0100
5.2 +++ b/simplify.py Sun Feb 25 01:50:23 2007 +0100
5.3 @@ -202,8 +202,7 @@
5.4
5.5 # Make an invocation of the subprogram.
5.6
5.7 - result = InvokeBlock(and_, 1, produces_result=1)
5.8 - result.expr = LoadRef(ref=subprogram)
5.9 + result = InvokeRef(and_, 1, produces_result=1, ref=subprogram)
5.10 return result
5.11
5.12 def visitAssert(self, assert_):
5.13 @@ -543,8 +542,7 @@
5.14
5.15 # Make an invocation of the subprogram.
5.16
5.17 - result = InvokeBlock(bitand, 1, produces_result=1)
5.18 - result.expr = LoadRef(ref=subprogram)
5.19 + result = InvokeRef(bitand, 1, produces_result=1, ref=subprogram)
5.20 return result
5.21
5.22 def visitBreak(self, break_):
5.23 @@ -597,10 +595,10 @@
5.24 name=class_.name,
5.25 expr=LoadRef(ref=structure)
5.26 ),
5.27 - InvokeBlock(
5.28 + InvokeRef(
5.29 class_,
5.30 - share_locals=0, # override the local sharing usually in InvokeBlock
5.31 - expr=LoadRef(ref=subprogram)
5.32 + share_locals=0, # override the local sharing usually in InvokeRef
5.33 + ref=subprogram
5.34 )
5.35 ]
5.36 )
5.37 @@ -631,7 +629,7 @@
5.38
5.39 ...to:
5.40
5.41 - InvokeBlock -> Subprogram -> Conditional (test) -> (body)
5.42 + InvokeRef -> Subprogram -> Conditional (test) -> (body)
5.43 (else) -> Conditional (test) -> (body)
5.44 (else) -> ...
5.45 """
5.46 @@ -755,8 +753,7 @@
5.47
5.48 # Make an invocation of the subprogram.
5.49
5.50 - result = InvokeBlock(compare, 1, produces_result=1)
5.51 - result.expr = LoadRef(ref=subprogram)
5.52 + result = InvokeRef(compare, 1, produces_result=1, ref=subprogram)
5.53 return result
5.54
5.55 def visitConst(self, const):
5.56 @@ -767,9 +764,7 @@
5.57 return result
5.58
5.59 def visitContinue(self, continue_):
5.60 - result = InvokeBlock(continue_, 1,
5.61 - expr=LoadRef(ref=self.current_subprograms[-1])
5.62 - )
5.63 + result = InvokeRef(continue_, 1, ref=self.current_subprograms[-1])
5.64 return result
5.65
5.66 def visitDict(self, dict):
5.67 @@ -838,9 +833,9 @@
5.68 ReleaseTemp()
5.69 ])
5.70 ] + body_stmt + [
5.71 - InvokeBlock(
5.72 + InvokeRef(
5.73 node,
5.74 - expr=LoadRef(ref=subprogram)
5.75 + ref=subprogram
5.76 )
5.77 ],
5.78 handler=[
5.79 @@ -880,7 +875,7 @@
5.80 )
5.81 )
5.82 ),
5.83 - InvokeBlock(node, expr=LoadRef(ref=subprogram)),
5.84 + InvokeRef(node, ref=subprogram),
5.85 ReleaseTemp()
5.86 ]
5.87 )
5.88 @@ -1122,7 +1117,61 @@
5.89 return LoadRef(lambda_, 1, ref=subprogram)
5.90
5.91 def visitList(self, list):
5.92 - return self._visitBuiltin(list, "list")
5.93 +
5.94 + # Make a subprogram for the list construction and record it outside the
5.95 + # main tree.
5.96 +
5.97 + subprogram = Subprogram(list, name=None, module=self.module, internal=0, returns_value=1, star=None, dstar=None, original_def=list)
5.98 + self.current_subprograms.append(subprogram)
5.99 +
5.100 + # Make nice annotations for the viewer.
5.101 +
5.102 + list._subprogram = subprogram
5.103 +
5.104 + subprogram.code=[
5.105 + StoreTemp(
5.106 + expr=InvokeFunction(
5.107 + list,
5.108 + expr=LoadName(
5.109 + name="list"
5.110 + ),
5.111 + args=[],
5.112 + star=None,
5.113 + dstar=None
5.114 + )
5.115 + )
5.116 + ]
5.117 +
5.118 + for node in list.nodes:
5.119 + subprogram.code.append(
5.120 + InvokeFunction(
5.121 + list,
5.122 + expr=LoadAttr(
5.123 + expr=LoadTemp(),
5.124 + name="append"
5.125 + ),
5.126 + args=[self.dispatch(node)],
5.127 + star=None,
5.128 + dstar=None
5.129 + )
5.130 + )
5.131 +
5.132 + subprogram.code.append(
5.133 + ReturnFromBlock(
5.134 + expr=LoadTemp(release=1)
5.135 + )
5.136 + )
5.137 +
5.138 + self.current_subprograms.pop()
5.139 + self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
5.140 +
5.141 + # Make an invocation of the subprogram.
5.142 +
5.143 + result = InvokeRef(list, 1,
5.144 + produces_result=1,
5.145 + ref=subprogram
5.146 + )
5.147 + return result
5.148
5.149 def visitListComp(self, listcomp):
5.150
5.151 @@ -1164,9 +1213,9 @@
5.152
5.153 # Make an invocation of the subprogram.
5.154
5.155 - result = InvokeBlock(listcomp, 1,
5.156 + result = InvokeRef(listcomp, 1,
5.157 produces_result=1,
5.158 - expr=LoadRef(ref=subprogram)
5.159 + ref=subprogram
5.160 )
5.161 return result
5.162
5.163 @@ -1302,9 +1351,9 @@
5.164
5.165 # Make an invocation of the subprogram.
5.166
5.167 - result = InvokeBlock(or_, 1,
5.168 + result = InvokeRef(or_, 1,
5.169 produces_result=1,
5.170 - expr=LoadRef(ref=subprogram)
5.171 + ref=subprogram
5.172 )
5.173 return result
5.174
5.175 @@ -1652,9 +1701,9 @@
5.176 name="__bool__"),
5.177 ),
5.178 body=self.dispatch(while_.body) + [
5.179 - InvokeBlock(
5.180 + InvokeRef(
5.181 while_,
5.182 - expr=LoadRef(ref=subprogram)
5.183 + ref=subprogram
5.184 ),
5.185 ReturnFromBlock()
5.186 ],
5.187 @@ -1675,9 +1724,7 @@
5.188
5.189 # Make an invocation of the subprogram.
5.190
5.191 - result = InvokeBlock(while_, 1,
5.192 - expr=LoadRef(ref=subprogram)
5.193 - )
5.194 + result = InvokeRef(while_, 1, ref=subprogram)
5.195
5.196 # Make nice annotations for the viewer.
5.197
5.198 @@ -1704,7 +1751,7 @@
5.199 """
5.200 Emulate the current mechanisms by producing nodes as follows:
5.201
5.202 - InvokeBlock -> Subprogram -> StoreTemp (expr) -> x.__lt__(y)
5.203 + InvokeRef -> Subprogram -> StoreTemp (expr) -> x.__lt__(y)
5.204 Conditional (test) -> __is__(LoadTemp, NotImplemented)
5.205 (body) -> ReleaseTemp
5.206 StoreTemp (expr) -> y.__gt__(x)
5.207 @@ -1775,10 +1822,10 @@
5.208 self.current_subprograms.pop()
5.209 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
5.210
5.211 - result = InvokeBlock(
5.212 + result = InvokeRef(
5.213 binary,
5.214 produces_result=1,
5.215 - expr=LoadRef(ref=subprogram)
5.216 + ref=subprogram
5.217 )
5.218
5.219 # Make nice annotations for the viewer.
5.220 @@ -1793,7 +1840,7 @@
5.221 """
5.222 Emulate the current mechanisms by producing nodes as follows:
5.223
5.224 - InvokeBlock -> Subprogram -> Try (body) -> ReturnFromBlock (expr) -> x.__add__(y)
5.225 + InvokeRef -> Subprogram -> Try (body) -> ReturnFromBlock (expr) -> x.__add__(y)
5.226 (else)
5.227 (handler) -> Conditional (test) -> CheckType (expr) -> LoadExc
5.228 (choices) -> LoadName TypeError
5.229 @@ -1840,10 +1887,10 @@
5.230 self.current_subprograms.pop()
5.231 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
5.232
5.233 - result = InvokeBlock(
5.234 + result = InvokeRef(
5.235 binary,
5.236 produces_result=1,
5.237 - expr=LoadRef(ref=subprogram)
5.238 + ref=subprogram
5.239 )
5.240
5.241 # Make nice annotations for the viewer.
6.1 --- a/test.py Fri Feb 23 01:29:50 2007 +0100
6.2 +++ b/test.py Sun Feb 25 01:50:23 2007 +0100
6.3 @@ -12,6 +12,8 @@
6.4 simplified.set_multiple_instance_mode()
6.5 elif "-ms" in sys.argv:
6.6 simplified.set_selective_multiple_instance_mode()
6.7 + elif "-mp" in sys.argv:
6.8 + simplified.set_prolific_multiple_instance_mode()
6.9
6.10 import viewer
6.11 from annotate import AnnotationError, Importer, load