[pypy-svn] r17368 - in pypy/dist/pypy/interpreter: . astcompiler pyparser pyparser/test
ac at codespeak.net
ac at codespeak.net
Thu Sep 8 15:43:06 CEST 2005
Author: ac
Date: Thu Sep 8 15:43:04 2005
New Revision: 17368
Modified:
pypy/dist/pypy/interpreter/astcompiler/pyassem.py
pypy/dist/pypy/interpreter/pycode.py
pypy/dist/pypy/interpreter/pyparser/grammar.py
pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py
Log:
Fix code-object generation.
Modified: pypy/dist/pypy/interpreter/astcompiler/pyassem.py
==============================================================================
--- pypy/dist/pypy/interpreter/astcompiler/pyassem.py (original)
+++ pypy/dist/pypy/interpreter/astcompiler/pyassem.py Thu Sep 8 15:43:04 2005
@@ -797,13 +797,14 @@
return PyCode(self.space)._code_new_w( argcount, nlocals,
self.stacksize, self.flags,
self.lnotab.getCode(),
- tuple(self.getConsts()),
- tuple(self.names),
- tuple(self.varnames),
- self.filename, self.name, self.lnotab.firstline,
+ self.getConsts(),
+ self.names,
+ self.varnames,
+ self.filename, self.name,
+ self.lnotab.firstline,
self.lnotab.getTable(),
- tuple(self.freevars),
- tuple(self.cellvars)
+ self.freevars,
+ self.cellvars
)
def getConsts(self):
Modified: pypy/dist/pypy/interpreter/pycode.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycode.py (original)
+++ pypy/dist/pypy/interpreter/pycode.py Thu Sep 8 15:43:04 2005
@@ -186,35 +186,22 @@
# with a lot of boring asserts to enforce type knowledge
# XXX get rid of that ASAP with a real compiler!
import types
- x = argcount; assert isinstance(x, int)
- self.co_argcount = x
- x = nlocals; assert isinstance(x, int)
- self.co_nlocals = x
- x = stacksize; assert isinstance(x, int)
- self.co_stacksize = x
- x = flags; assert isinstance(x, int)
- self.co_flags = x
- x = code; assert isinstance(x, str)
- self.co_code = x
+ self.co_argcount = argcount
+ self.co_nlocals = nlocals
+ self.co_stacksize = stacksize
+ self.co_flags = flags
+ self.co_code = code
## for w in consts:
## assert isinstance(w,W_Root)
self.co_consts_w = consts
- x = names; assert isinstance(x, tuple)
- self.co_names = [ str(n) for n in x ]
- x = varnames; assert isinstance(x, tuple)
- self.co_varnames = [ str(n) for n in x ]
- x = freevars; assert isinstance(x, tuple)
- self.co_freevars = [ str(n) for n in x ]
- x = cellvars; assert isinstance(x, tuple)
- self.co_cellvars = [ str(n) for n in x ]
- x = filename; assert isinstance(x, str)
- self.co_filename = x
- x = name; assert isinstance(x, str)
- self.co_name = x
- x = firstlineno; assert isinstance(x, int)
- self.co_firstlineno = x
- x = lnotab; assert isinstance(x, str)
- self.co_lnotab = x
+ self.co_names = names
+ self.co_varnames = varnames
+ self.co_freevars = freevars
+ self.co_cellvars = cellvars
+ self.co_filename = filename
+ self.co_name = name
+ self.co_firstlineno = firstlineno
+ self.co_lnotab = lnotab
# recursively _from_code()-ify the code objects in code.co_consts
space = self.space
return self
Modified: pypy/dist/pypy/interpreter/pyparser/grammar.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/grammar.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/grammar.py Thu Sep 8 15:43:04 2005
@@ -93,7 +93,10 @@
"""Abstract base class for builder objects"""
def __init__(self, rules=None, debug=0, symbols={} ):
# a dictionary of grammar rules for debug/reference
- self.rules = rules or {}
+ if rules is not None:
+ self.rules = rules
+ else:
+ self.rules = {}
# This attribute is here for convenience
self.debug = debug
self.symbols = symbols # mapping from codename to symbols
Modified: pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py Thu Sep 8 15:43:04 2005
@@ -113,7 +113,7 @@
rcode.co_stacksize,
rcode.co_flags,
rcode.co_code,
- rcode.co_consts_w,
+ tuple(rcode.co_consts_w),
tuple(rcode.co_names),
tuple(rcode.co_varnames),
rcode.co_filename,
More information about the Pypy-commit
mailing list