[pypy-svn] r13602 - in pypy/dist/pypy/translator/llvm2: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Sun Jun 19 14:38:23 CEST 2005
Author: cfbolz
Date: Sun Jun 19 14:38:23 2005
New Revision: 13602
Modified:
pypy/dist/pypy/translator/llvm2/funcnode.py
pypy/dist/pypy/translator/llvm2/structnode.py
pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
Log:
(cfbolz, hpk)
make nested tuples work + test
Modified: pypy/dist/pypy/translator/llvm2/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/funcnode.py (original)
+++ pypy/dist/pypy/translator/llvm2/funcnode.py Sun Jun 19 14:38:23 2005
@@ -181,7 +181,8 @@
arg = op.args[0]
assert (isinstance(arg, Constant) and
isinstance(arg.value, lltype.Struct))
- type = "%" + arg.value._name
+ #XXX unclean
+ type = self.db.obj2node[arg.value].ref
self.codewriter.malloc(targetvar, type)
def getfield(self, op):
Modified: pypy/dist/pypy/translator/llvm2/structnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/structnode.py (original)
+++ pypy/dist/pypy/translator/llvm2/structnode.py Sun Jun 19 14:38:23 2005
@@ -5,12 +5,14 @@
class StructNode(object):
_issetup = False
+ struct_counter = 0
def __init__(self, db, struct):
self.db = db
self.struct = struct
- self.ref = "%" + struct._name
-
+ self.ref = "%%st.%s.%s" % (struct._name, StructNode.struct_counter)
+ StructNode.struct_counter += 1
+
def __str__(self):
return "<StructNode %r>" %(self.ref,)
Modified: pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/test_genllvm.py Sun Jun 19 14:38:23 2005
@@ -79,8 +79,15 @@
assert f(0, 2) == 3
def test_tuple_getitem():
- def list_getitem(i):
+ def tuple_getitem(i):
l = (1,2,i)
return l[1]
- f = compile_function(list_getitem, [int])
+ f = compile_function(tuple_getitem, [int])
assert f(1) == 2
+
+def test_nested_tuple():
+ def nested_tuple(i):
+ l = (1,(1,2,i),i)
+ return l[1][2]
+ f = compile_function(nested_tuple, [int])
+ assert f(4) == 4
More information about the Pypy-commit
mailing list