1. Pypy
  2. Untitled project
  3. pypy

Commits

Ronan Lamy  committed d0ba87d

kill FSFrame.do_operation()

  • Participants
  • Parent commits b5e9fab
  • Branches less-stringly-ops

Comments (0)

Files changed (4)

File rpython/flowspace/flowcontext.py

View file
             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:
     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)
         # 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):
 
     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):

File rpython/flowspace/generator.py

View file
         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)

File rpython/flowspace/objspace.py

View file
     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

File rpython/flowspace/operation.py

View file
 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'