summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/pyassem.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-09-14 22:49:08 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-09-14 22:49:08 (GMT)
commit1e99a77120d7bf3509eb283dde871b89ad7f6007 (patch)
treeb770bd191fa0f98e1e5be46cd3cff16cb63959fc /Lib/compiler/pyassem.py
parent652a22437a973dddef7f82d0cc8271d60da7de36 (diff)
downloadcpython-1e99a77120d7bf3509eb283dde871b89ad7f6007.zip
cpython-1e99a77120d7bf3509eb283dde871b89ad7f6007.tar.gz
cpython-1e99a77120d7bf3509eb283dde871b89ad7f6007.tar.bz2
Various sundry changes for 2.2 compatibility
Remove the option to have nested scopes or old LGB scopes. This has a large impact on the code base, by removing the need for two variants of each CodeGenerator. Add a get_module() method to CodeGenerator objects, used to get the future features for the current module. Set CO_GENERATOR, CO_GENERATOR_ALLOWED, and CO_FUTURE_DIVISION flags as appropriate. Attempt to fix the value of nlocals in newCodeObject(), assuming that nlocals is 0 if CO_NEWLOCALS is not defined.
Diffstat (limited to 'Lib/compiler/pyassem.py')
-rw-r--r--Lib/compiler/pyassem.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py
index c3fa7b7..d9d294b 100644
--- a/Lib/compiler/pyassem.py
+++ b/Lib/compiler/pyassem.py
@@ -361,6 +361,10 @@ class PyFlowGraph(FlowGraph):
if flag == CO_VARARGS:
self.argcount = self.argcount - 1
+ def checkFlag(self, flag):
+ if self.flags & flag:
+ return 1
+
def setFreeVars(self, names):
self.freevars = list(names)
@@ -564,7 +568,7 @@ class PyFlowGraph(FlowGraph):
def newCodeObject(self):
assert self.stage == DONE
- if self.flags == 0:
+ if (self.flags & CO_NEWLOCALS) == 0:
nlocals = 0
else:
nlocals = len(self.varnames)
@@ -761,9 +765,6 @@ class StackDepthTracker:
('LOAD_', 1),
]
- # special cases:
- # UNPACK_SEQUENCE, BUILD_TUPLE,
- # BUILD_LIST, CALL_FUNCTION, MAKE_FUNCTION, BUILD_SLICE
def UNPACK_SEQUENCE(self, count):
return count-1
def BUILD_TUPLE(self, count):