[pypy-commit] pypy less-stringly-ops: kill FSFrame.do_operation()

rlamy noreply at buildbot.pypy.org
Mon Sep 23 20:04:23 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: less-stringly-ops
Changeset: r67072:d0ba87deddde
Date: 2013-09-23 05:43 +0100
http://bitbucket.org/pypy/pypy/changeset/d0ba87deddde/

Log:	kill FSFrame.do_operation()

diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -419,11 +419,6 @@
             return w_condition.value
         return self.recorder.guessbool(self, w_condition)
 
-    def do_operation(self, name, *args_w):
-        spaceop = SpaceOperation(name, args_w, Variable())
-        self.record(spaceop)
-        return spaceop.result
-
     def record(self, spaceop):
         recorder = self.recorder
         if getattr(recorder, 'final_state', None) is not None:
@@ -704,7 +699,7 @@
     def YIELD_VALUE(self, _):
         assert self.pycode.is_generator
         w_result = self.popvalue()
-        self.do_operation('yield', w_result)
+        self.space.yield_(w_result)
         # XXX yield expressions not supported. This will blow up if the value
         # isn't popped straightaway.
         self.pushvalue(None)
@@ -916,7 +911,7 @@
         # This opcode was added with pypy-1.8.  Here is a simpler
         # version, enough for annotation.
         last_val = self.popvalue()
-        self.pushvalue(self.space.newlist([]))
+        self.pushvalue(self.space.newlist())
         self.pushvalue(last_val)
 
     def call_function(self, oparg, w_star=None, w_starstar=None):
@@ -1082,12 +1077,12 @@
 
     def BUILD_TUPLE(self, itemcount):
         items = self.popvalues(itemcount)
-        w_tuple = self.space.newtuple(items)
+        w_tuple = self.space.newtuple(*items)
         self.pushvalue(w_tuple)
 
     def BUILD_LIST(self, itemcount):
         items = self.popvalues(itemcount)
-        w_list = self.space.newlist(items)
+        w_list = self.space.newlist(*items)
         self.pushvalue(w_list)
 
     def BUILD_MAP(self, itemcount):
diff --git a/rpython/flowspace/generator.py b/rpython/flowspace/generator.py
--- a/rpython/flowspace/generator.py
+++ b/rpython/flowspace/generator.py
@@ -128,7 +128,7 @@
         assert block is not stopblock
         for index in range(len(block.operations)-1, -1, -1):
             op = block.operations[index]
-            if op.opname == 'yield':
+            if op.opname == 'yield_':
                 [v_yielded_value] = op.args
                 del block.operations[index]
                 newlink = split_block(None, block, index)
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -60,25 +60,6 @@
     def build_flow(self, func):
         return build_flow(func, self)
 
-    is_ = None     # real version added by add_operations()
-    id  = None     # real version added by add_operations()
-
-    def newdict(self, module="ignored"):
-        return self.frame.do_operation('newdict')
-
-    def newtuple(self, args_w):
-        if all(isinstance(w_arg, Constant) for w_arg in args_w):
-            content = [w_arg.value for w_arg in args_w]
-            return Constant(tuple(content))
-        else:
-            return self.frame.do_operation('newtuple', *args_w)
-
-    def newlist(self, args_w, sizehint=None):
-        return self.frame.do_operation('newlist', *args_w)
-
-    def newslice(self, w_start, w_stop, w_step):
-        return self.frame.do_operation('newslice', w_start, w_stop, w_step)
-
     def newbool(self, b):
         if b:
             return self.w_True
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -300,6 +300,12 @@
 add_operator('delete', 2, pyfunc=delete)
 add_operator('userdel', 1, pyfunc=userdel)
 add_operator('buffer', 1, pyfunc=buffer, pure=True)   # see buffer.py
+add_operator('yield_', 1)
+add_operator('newdict', 0)
+add_operator('newtuple', None, pure=True, pyfunc=lambda *args:args)
+add_operator('newlist', None)
+add_operator('newslice', 3)
+
 
 class Pow(PureOperation):
     opname = 'pow'


More information about the pypy-commit mailing list