1.1 --- a/simplify.py Fri Feb 23 01:29:50 2007 +0100
1.2 +++ b/simplify.py Sun Feb 25 01:50:23 2007 +0100
1.3 @@ -202,8 +202,7 @@
1.4
1.5 # Make an invocation of the subprogram.
1.6
1.7 - result = InvokeBlock(and_, 1, produces_result=1)
1.8 - result.expr = LoadRef(ref=subprogram)
1.9 + result = InvokeRef(and_, 1, produces_result=1, ref=subprogram)
1.10 return result
1.11
1.12 def visitAssert(self, assert_):
1.13 @@ -543,8 +542,7 @@
1.14
1.15 # Make an invocation of the subprogram.
1.16
1.17 - result = InvokeBlock(bitand, 1, produces_result=1)
1.18 - result.expr = LoadRef(ref=subprogram)
1.19 + result = InvokeRef(bitand, 1, produces_result=1, ref=subprogram)
1.20 return result
1.21
1.22 def visitBreak(self, break_):
1.23 @@ -597,10 +595,10 @@
1.24 name=class_.name,
1.25 expr=LoadRef(ref=structure)
1.26 ),
1.27 - InvokeBlock(
1.28 + InvokeRef(
1.29 class_,
1.30 - share_locals=0, # override the local sharing usually in InvokeBlock
1.31 - expr=LoadRef(ref=subprogram)
1.32 + share_locals=0, # override the local sharing usually in InvokeRef
1.33 + ref=subprogram
1.34 )
1.35 ]
1.36 )
1.37 @@ -631,7 +629,7 @@
1.38
1.39 ...to:
1.40
1.41 - InvokeBlock -> Subprogram -> Conditional (test) -> (body)
1.42 + InvokeRef -> Subprogram -> Conditional (test) -> (body)
1.43 (else) -> Conditional (test) -> (body)
1.44 (else) -> ...
1.45 """
1.46 @@ -755,8 +753,7 @@
1.47
1.48 # Make an invocation of the subprogram.
1.49
1.50 - result = InvokeBlock(compare, 1, produces_result=1)
1.51 - result.expr = LoadRef(ref=subprogram)
1.52 + result = InvokeRef(compare, 1, produces_result=1, ref=subprogram)
1.53 return result
1.54
1.55 def visitConst(self, const):
1.56 @@ -767,9 +764,7 @@
1.57 return result
1.58
1.59 def visitContinue(self, continue_):
1.60 - result = InvokeBlock(continue_, 1,
1.61 - expr=LoadRef(ref=self.current_subprograms[-1])
1.62 - )
1.63 + result = InvokeRef(continue_, 1, ref=self.current_subprograms[-1])
1.64 return result
1.65
1.66 def visitDict(self, dict):
1.67 @@ -838,9 +833,9 @@
1.68 ReleaseTemp()
1.69 ])
1.70 ] + body_stmt + [
1.71 - InvokeBlock(
1.72 + InvokeRef(
1.73 node,
1.74 - expr=LoadRef(ref=subprogram)
1.75 + ref=subprogram
1.76 )
1.77 ],
1.78 handler=[
1.79 @@ -880,7 +875,7 @@
1.80 )
1.81 )
1.82 ),
1.83 - InvokeBlock(node, expr=LoadRef(ref=subprogram)),
1.84 + InvokeRef(node, ref=subprogram),
1.85 ReleaseTemp()
1.86 ]
1.87 )
1.88 @@ -1122,7 +1117,61 @@
1.89 return LoadRef(lambda_, 1, ref=subprogram)
1.90
1.91 def visitList(self, list):
1.92 - return self._visitBuiltin(list, "list")
1.93 +
1.94 + # Make a subprogram for the list construction and record it outside the
1.95 + # main tree.
1.96 +
1.97 + subprogram = Subprogram(list, name=None, module=self.module, internal=0, returns_value=1, star=None, dstar=None, original_def=list)
1.98 + self.current_subprograms.append(subprogram)
1.99 +
1.100 + # Make nice annotations for the viewer.
1.101 +
1.102 + list._subprogram = subprogram
1.103 +
1.104 + subprogram.code=[
1.105 + StoreTemp(
1.106 + expr=InvokeFunction(
1.107 + list,
1.108 + expr=LoadName(
1.109 + name="list"
1.110 + ),
1.111 + args=[],
1.112 + star=None,
1.113 + dstar=None
1.114 + )
1.115 + )
1.116 + ]
1.117 +
1.118 + for node in list.nodes:
1.119 + subprogram.code.append(
1.120 + InvokeFunction(
1.121 + list,
1.122 + expr=LoadAttr(
1.123 + expr=LoadTemp(),
1.124 + name="append"
1.125 + ),
1.126 + args=[self.dispatch(node)],
1.127 + star=None,
1.128 + dstar=None
1.129 + )
1.130 + )
1.131 +
1.132 + subprogram.code.append(
1.133 + ReturnFromBlock(
1.134 + expr=LoadTemp(release=1)
1.135 + )
1.136 + )
1.137 +
1.138 + self.current_subprograms.pop()
1.139 + self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
1.140 +
1.141 + # Make an invocation of the subprogram.
1.142 +
1.143 + result = InvokeRef(list, 1,
1.144 + produces_result=1,
1.145 + ref=subprogram
1.146 + )
1.147 + return result
1.148
1.149 def visitListComp(self, listcomp):
1.150
1.151 @@ -1164,9 +1213,9 @@
1.152
1.153 # Make an invocation of the subprogram.
1.154
1.155 - result = InvokeBlock(listcomp, 1,
1.156 + result = InvokeRef(listcomp, 1,
1.157 produces_result=1,
1.158 - expr=LoadRef(ref=subprogram)
1.159 + ref=subprogram
1.160 )
1.161 return result
1.162
1.163 @@ -1302,9 +1351,9 @@
1.164
1.165 # Make an invocation of the subprogram.
1.166
1.167 - result = InvokeBlock(or_, 1,
1.168 + result = InvokeRef(or_, 1,
1.169 produces_result=1,
1.170 - expr=LoadRef(ref=subprogram)
1.171 + ref=subprogram
1.172 )
1.173 return result
1.174
1.175 @@ -1652,9 +1701,9 @@
1.176 name="__bool__"),
1.177 ),
1.178 body=self.dispatch(while_.body) + [
1.179 - InvokeBlock(
1.180 + InvokeRef(
1.181 while_,
1.182 - expr=LoadRef(ref=subprogram)
1.183 + ref=subprogram
1.184 ),
1.185 ReturnFromBlock()
1.186 ],
1.187 @@ -1675,9 +1724,7 @@
1.188
1.189 # Make an invocation of the subprogram.
1.190
1.191 - result = InvokeBlock(while_, 1,
1.192 - expr=LoadRef(ref=subprogram)
1.193 - )
1.194 + result = InvokeRef(while_, 1, ref=subprogram)
1.195
1.196 # Make nice annotations for the viewer.
1.197
1.198 @@ -1704,7 +1751,7 @@
1.199 """
1.200 Emulate the current mechanisms by producing nodes as follows:
1.201
1.202 - InvokeBlock -> Subprogram -> StoreTemp (expr) -> x.__lt__(y)
1.203 + InvokeRef -> Subprogram -> StoreTemp (expr) -> x.__lt__(y)
1.204 Conditional (test) -> __is__(LoadTemp, NotImplemented)
1.205 (body) -> ReleaseTemp
1.206 StoreTemp (expr) -> y.__gt__(x)
1.207 @@ -1775,10 +1822,10 @@
1.208 self.current_subprograms.pop()
1.209 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
1.210
1.211 - result = InvokeBlock(
1.212 + result = InvokeRef(
1.213 binary,
1.214 produces_result=1,
1.215 - expr=LoadRef(ref=subprogram)
1.216 + ref=subprogram
1.217 )
1.218
1.219 # Make nice annotations for the viewer.
1.220 @@ -1793,7 +1840,7 @@
1.221 """
1.222 Emulate the current mechanisms by producing nodes as follows:
1.223
1.224 - InvokeBlock -> Subprogram -> Try (body) -> ReturnFromBlock (expr) -> x.__add__(y)
1.225 + InvokeRef -> Subprogram -> Try (body) -> ReturnFromBlock (expr) -> x.__add__(y)
1.226 (else)
1.227 (handler) -> Conditional (test) -> CheckType (expr) -> LoadExc
1.228 (choices) -> LoadName TypeError
1.229 @@ -1840,10 +1887,10 @@
1.230 self.current_subprograms.pop()
1.231 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
1.232
1.233 - result = InvokeBlock(
1.234 + result = InvokeRef(
1.235 binary,
1.236 produces_result=1,
1.237 - expr=LoadRef(ref=subprogram)
1.238 + ref=subprogram
1.239 )
1.240
1.241 # Make nice annotations for the viewer.