[pypy-commit] pypy translation-cleanup: Flowspacify stack manipulation methods
rlamy
noreply at buildbot.pypy.org
Tue Oct 16 15:45:08 CEST 2012
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r58129:0e6cc47af479
Date: 2012-10-16 11:29 +0100
http://bitbucket.org/pypy/pypy/changeset/0e6cc47af479/
Log: Flowspacify stack manipulation methods
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -261,6 +261,32 @@
self.valuestackdepth = code.co_nlocals
self.locals_stack_w = [None] * (code.co_stacksize + code.co_nlocals)
+ def pushvalue(self, w_object):
+ depth = self.valuestackdepth
+ self.locals_stack_w[depth] = w_object
+ self.valuestackdepth = depth + 1
+
+ def popvalue(self):
+ depth = self.valuestackdepth - 1
+ assert depth >= self.pycode.co_nlocals, "pop from empty value stack"
+ w_object = self.locals_stack_w[depth]
+ self.locals_stack_w[depth] = None
+ self.valuestackdepth = depth
+ return w_object
+
+ def peekvalue(self, index_from_top=0):
+ # NOTE: top of the stack is peekvalue(0).
+ index = self.valuestackdepth + ~index_from_top
+ assert index >= self.pycode.co_nlocals, (
+ "peek past the bottom of the stack")
+ return self.locals_stack_w[index]
+
+ def settopvalue(self, w_object, index_from_top=0):
+ index = self.valuestackdepth + ~index_from_top
+ assert index >= self.pycode.co_nlocals, (
+ "settop past the bottom of the stack")
+ self.locals_stack_w[index] = w_object
+
def dropvaluesuntil(self, finaldepth):
for n in range(finaldepth, self.valuestackdepth):
self.locals_stack_w[n] = None
More information about the pypy-commit
mailing list