[pypy-svn] r15284 - in pypy/dist/pypy: interpreter lib/_stablecompiler
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Jul 28 20:22:43 CEST 2005
Author: cfbolz
Date: Thu Jul 28 20:22:40 2005
New Revision: 15284
Added:
pypy/dist/pypy/lib/_stablecompiler/
- copied from r15281, pypy/dist/pypy/interpreter/stablecompiler/
Modified:
pypy/dist/pypy/interpreter/pycompiler.py
pypy/dist/pypy/lib/_stablecompiler/future.py
pypy/dist/pypy/lib/_stablecompiler/pyassem.py
pypy/dist/pypy/lib/_stablecompiler/pycodegen.py
pypy/dist/pypy/lib/_stablecompiler/symbols.py
pypy/dist/pypy/lib/_stablecompiler/syntax.py
pypy/dist/pypy/lib/_stablecompiler/transformer.py
pypy/dist/pypy/lib/_stablecompiler/visitor.py
Log:
(cfbolz, arigo)
Copied the stablecompiler to lib/ and made it purely app-level.
Started to remove calls to eval().
Modified: pypy/dist/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycompiler.py (original)
+++ pypy/dist/pypy/interpreter/pycompiler.py Thu Jul 28 20:22:40 2005
@@ -242,11 +242,11 @@
debug_print("importing the 'compiler' package at app-level...",
newline=False)
self.w_applevelcompile = space.appexec([], r'''():
- from compiler.misc import set_filename
- from compiler.pycodegen import ModuleCodeGenerator
- from compiler.pycodegen import InteractiveCodeGenerator
- from compiler.pycodegen import ExpressionCodeGenerator
- from compiler.transformer import Transformer
+ from _stablecompiler.misc import set_filename
+ from _stablecompiler.pycodegen import ModuleCodeGenerator
+ from _stablecompiler.pycodegen import InteractiveCodeGenerator
+ from _stablecompiler.pycodegen import ExpressionCodeGenerator
+ from _stablecompiler.transformer import Transformer
def applevelcompile(tuples, filename, mode):
transformer = Transformer()
Modified: pypy/dist/pypy/lib/_stablecompiler/future.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/future.py (original)
+++ pypy/dist/pypy/lib/_stablecompiler/future.py Thu Jul 28 20:22:40 2005
@@ -2,7 +2,8 @@
"""
-from pypy.interpreter.stablecompiler import ast, walk
+import ast
+from visitor import walk
def is_future(stmt):
"""Return true if statement is a well-formed future statement"""
@@ -61,7 +62,7 @@
if __name__ == "__main__":
import sys
- from pypy.interpreter.stablecompiler import parseFile, walk
+ import parseFile, walk
for file in sys.argv[1:]:
print file
Modified: pypy/dist/pypy/lib/_stablecompiler/pyassem.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/pyassem.py (original)
+++ pypy/dist/pypy/lib/_stablecompiler/pyassem.py Thu Jul 28 20:22:40 2005
@@ -5,9 +5,8 @@
import sys
import types
-from pypy.interpreter.stablecompiler import misc
-from pypy.interpreter.stablecompiler.consts \
- import CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS
+import misc
+from consts import CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS
class FlowGraph:
def __init__(self):
Modified: pypy/dist/pypy/lib/_stablecompiler/pycodegen.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/pycodegen.py (original)
+++ pypy/dist/pypy/lib/_stablecompiler/pycodegen.py Thu Jul 28 20:22:40 2005
@@ -6,13 +6,14 @@
import types
from cStringIO import StringIO
-from pypy.interpreter.stablecompiler import ast, parse, walk, syntax
-from pypy.interpreter.stablecompiler import pyassem, misc, future, symbols
-from pypy.interpreter.stablecompiler.consts import SC_LOCAL, SC_GLOBAL, \
- SC_FREE, SC_CELL
-from pypy.interpreter.stablecompiler.consts import CO_VARARGS, CO_VARKEYWORDS, \
+import ast, syntax
+from transformer import parse
+from visitor import walk
+import pyassem, misc, future, symbols
+from consts import SC_LOCAL, SC_GLOBAL, SC_FREE, SC_CELL
+from consts import CO_VARARGS, CO_VARKEYWORDS, \
CO_NEWLOCALS, CO_NESTED, CO_GENERATOR, CO_GENERATOR_ALLOWED, CO_FUTURE_DIVISION
-from pypy.interpreter.stablecompiler.pyassem import TupleArg
+from pyassem import TupleArg
# XXX The version-specific code can go, since this code only works with 2.x.
# Do we have Python 1.x or Python 2.x?
Modified: pypy/dist/pypy/lib/_stablecompiler/symbols.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/symbols.py (original)
+++ pypy/dist/pypy/lib/_stablecompiler/symbols.py Thu Jul 28 20:22:40 2005
@@ -1,9 +1,8 @@
"""Module symbol-table generator"""
-from pypy.interpreter.stablecompiler import ast
-from pypy.interpreter.stablecompiler.consts import SC_LOCAL, SC_GLOBAL, \
- SC_FREE, SC_CELL, SC_UNKNOWN
-from pypy.interpreter.stablecompiler.misc import mangle
+import ast
+from consts import SC_LOCAL, SC_GLOBAL, SC_FREE, SC_CELL, SC_UNKNOWN
+from misc import mangle
import types
@@ -420,7 +419,7 @@
if __name__ == "__main__":
import sys
- from pypy.interpreter.stablecompiler import parseFile, walk
+ import parseFile, walk
import symtable
def get_names(syms):
Modified: pypy/dist/pypy/lib/_stablecompiler/syntax.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/syntax.py (original)
+++ pypy/dist/pypy/lib/_stablecompiler/syntax.py Thu Jul 28 20:22:40 2005
@@ -9,7 +9,8 @@
errors.
"""
-from pypy.interpreter.stablecompiler import ast, walk
+import ast
+from visitor import walk
def check(tree, multi=None):
v = SyntaxErrorChecker(multi)
Modified: pypy/dist/pypy/lib/_stablecompiler/transformer.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/transformer.py (original)
+++ pypy/dist/pypy/lib/_stablecompiler/transformer.py Thu Jul 28 20:22:40 2005
@@ -25,12 +25,10 @@
# http://www.opensource.org/licenses/bsd-license.html
# and replace OWNER, ORGANIZATION, and YEAR as appropriate.
-# make sure we import the parser with the correct grammar
-import pypy.interpreter.pyparser.pythonparse
-from pypy.interpreter.stablecompiler.ast import *
+from ast import *
import parser
-import pypy.interpreter.pyparser.pysymbol as symbol
-import pypy.interpreter.pyparser.pytoken as token
+import symbol
+import token
import sys
class WalkerError(StandardError):
@@ -715,7 +713,15 @@
def atom_number(self, nodelist):
### need to verify this matches compile.c
- k = eval(nodelist[0][1])
+ s = nodelist[0][1]
+ if 'j' in s or 'J' in s:
+ k = complex(s)
+ elif '.' in s or 'e' in s or 'E' in s:
+ k = float(s)
+ elif 'l' in s or 'L' in s:
+ k = long(s)
+ else:
+ k = int(s)
return Const(k, lineno=nodelist[0][2])
def decode_literal(self, lit):
@@ -725,9 +731,10 @@
# tokenizer.c must be reflected here.
if self.encoding not in ['utf-8', 'iso-8859-1']:
lit = unicode(lit, 'utf-8').encode(self.encoding)
+ #XXX no clue what the following line does
return eval("# coding: %s\n%s" % (self.encoding, lit))
else:
- return eval(lit)
+ return parser.decode_string_literal(lit)
def atom_string(self, nodelist):
k = ''
Modified: pypy/dist/pypy/lib/_stablecompiler/visitor.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/visitor.py (original)
+++ pypy/dist/pypy/lib/_stablecompiler/visitor.py Thu Jul 28 20:22:40 2005
@@ -1,4 +1,4 @@
-from pypy.interpreter.stablecompiler import ast
+import ast
# XXX should probably rename ASTVisitor to ASTWalker
# XXX can it be made even more generic?
More information about the Pypy-commit
mailing list