Author: Ronan Lamy <[email protected]>
Branch: translation-cleanup
Changeset: r56995:84b08aeef6a0
Date: 2012-08-12 00:38 +0100
http://bitbucket.org/pypy/pypy/changeset/84b08aeef6a0/
Log: Add property HostCode.is_generator
diff --git a/pypy/objspace/flow/bytecode.py b/pypy/objspace/flow/bytecode.py
--- a/pypy/objspace/flow/bytecode.py
+++ b/pypy/objspace/flow/bytecode.py
@@ -4,6 +4,7 @@
from pypy.interpreter.pycode import PyCode, BytecodeCorruption
from pypy.tool.stdlib_opcode import (host_bytecode_spec, EXTENDED_ARG,
HAVE_ARGUMENT)
+from pypy.interpreter.astcompiler.consts import CO_GENERATOR
class HostCode(PyCode):
"""
@@ -40,3 +41,7 @@
opname = self.opnames[opcode]
return next_instr, opname, oparg
+
+ @property
+ def is_generator(self):
+ return bool(self.co_flags & CO_GENERATOR)
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
@@ -4,7 +4,6 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter import pyframe, nestedscope
from pypy.interpreter.argument import ArgumentsForTranslation
-from pypy.interpreter.astcompiler.consts import CO_GENERATOR
from pypy.interpreter.pyopcode import (Return, Yield, SuspendedUnroller,
SReturnValue, BytecodeCorruption)
from pypy.objspace.flow import operation
@@ -346,7 +345,6 @@
class FlowSpaceFrame(pyframe.CPythonFrame):
def __init__(self, space, code, func, constargs=None):
- self.is_generator = bool(code.co_flags & CO_GENERATOR)
w_globals = Constant(func.func_globals)
class outerfunc: pass # hack
if func.func_closure is not None:
@@ -375,7 +373,7 @@
name = name.replace(c, '_')
initialblock = SpamBlock(self.getstate())
- if self.is_generator:
+ if self.pycode.is_generator:
initialblock.operations.append(
SpaceOperation('generator_mark', [], Variable()))
graph = FunctionGraph(name, initialblock)
@@ -385,7 +383,7 @@
# itself
graph.signature = self.pycode.signature()
graph.defaults = func.func_defaults or ()
- graph.is_generator = self.is_generator
+ graph.is_generator = self.pycode.is_generator
return graph
def getstate(self):
@@ -477,7 +475,7 @@
return jumpto
def YIELD_VALUE(self, _, next_instr):
- assert self.is_generator
+ assert self.pycode.is_generator
w_result = self.popvalue()
self.space.do_operation('yield', w_result)
# XXX yield expressions not supported. This will blow up if the value
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit