[pypy-svn] r17384 - pypy/dist/pypy/interpreter/astcompiler
pedronis at codespeak.net
pedronis at codespeak.net
Thu Sep 8 18:43:39 CEST 2005
Author: pedronis
Date: Thu Sep 8 18:43:38 2005
New Revision: 17384
Modified:
pypy/dist/pypy/interpreter/astcompiler/pycodegen.py
pypy/dist/pypy/interpreter/astcompiler/symbols.py
Log:
use the space for checking for false if tests.
targetastcompiler annotation finishes!
Modified: pypy/dist/pypy/interpreter/astcompiler/pycodegen.py
==============================================================================
--- pypy/dist/pypy/interpreter/astcompiler/pycodegen.py (original)
+++ pypy/dist/pypy/interpreter/astcompiler/pycodegen.py Thu Sep 8 18:43:38 2005
@@ -128,9 +128,9 @@
mtime = struct.pack('<i', mtime)
return self.MAGIC + mtime
-def is_constant_false(node):
+def is_constant_false(space, node):
if isinstance(node, ast.Const):
- if not node.value:
+ if not space.is_true(node.value):
return 1
return 0
@@ -215,7 +215,7 @@
return name
def parseSymbols(self, tree):
- s = symbols.SymbolVisitor()
+ s = symbols.SymbolVisitor(self.space)
walk(tree, s)
return s.scopes
@@ -384,7 +384,7 @@
def visitIf(self, node):
end = self.newBlock()
for test, suite in node.tests:
- if is_constant_false(test):
+ if is_constant_false(self.space, test):
# XXX will need to check generator stuff here
continue
self.set_lineno(test)
Modified: pypy/dist/pypy/interpreter/astcompiler/symbols.py
==============================================================================
--- pypy/dist/pypy/interpreter/astcompiler/symbols.py (original)
+++ pypy/dist/pypy/interpreter/astcompiler/symbols.py Thu Sep 8 18:43:38 2005
@@ -213,7 +213,8 @@
self.__super_init(name, module, name)
class SymbolVisitor(ast.ASTVisitor):
- def __init__(self):
+ def __init__(self, space):
+ self.space = space
self.scopes = {}
self.klass = None
self.scope_stack = []
@@ -447,22 +448,10 @@
# prune if statements if tests are false
- _const_types = types.StringType, types.IntType, types.FloatType
-
def visitIf(self, node ):
for test, body in node.tests:
if isinstance(test, ast.Const):
- # XXX: Shouldn't come here anymore
- if type(test.value) in self._const_types:
- if not test.value:
- continue
- if isinstance(test, ast.NumberConst):
- if not test.number_value:
- continue
- if isinstance(test, ast.NoneConst):
- continue
- if isinstance(test, ast.StringConst):
- if not test.string_value:
+ if not self.space.is_true(test.value):
continue
test.accept( self )
body.accept( self )
More information about the Pypy-commit
mailing list