[pypy-svn] r14273 - in pypy/dist/pypy/translator/llvm2: . test
rxe at codespeak.net
rxe at codespeak.net
Tue Jul 5 13:29:36 CEST 2005
Author: rxe
Date: Tue Jul 5 13:29:34 2005
New Revision: 14273
Modified:
pypy/dist/pypy/translator/llvm2/arraynode.py
pypy/dist/pypy/translator/llvm2/database.py
pypy/dist/pypy/translator/llvm2/genllvm.py
pypy/dist/pypy/translator/llvm2/structnode.py
pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
Log:
A wip checkin - really just as way to sync up code bases.
Modified: pypy/dist/pypy/translator/llvm2/arraynode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/arraynode.py (original)
+++ pypy/dist/pypy/translator/llvm2/arraynode.py Tue Jul 5 13:29:34 2005
@@ -97,10 +97,10 @@
# Create a dummy constant hack XXX
c = Constant(item, T)
self.db.prepare_arg(c)
-
self._issetup = True
def getall(self):
+ "Returns the type and value for this node. "
arraylen = len(self.value.items)
res = []
@@ -112,14 +112,16 @@
# Create a dummy constant hack XXX
value = self.db.repr_arg(Constant(value, T))
else:
- value = repr(value)
+ if isinstance(value, str):
+ value = ord(value)
+
+ value = str(value)
res.append((typval, value))
- arrayvalues = ", ".join(["%s %s" % (t, v) for t, v in res])
-
- type_ = "{ int, [%s x %s] }" % (len(self.value.items),
+ type_ = "{ int, [%s x %s] }" % (arraylen,
self.db.repr_arg_type(self.value._TYPE.OF))
+ arrayvalues = ", ".join(["%s %s" % (t, v) for t, v in res])
value = "int %s, [%s x %s] [ %s ]" % (arraylen,
arraylen,
typval,
Modified: pypy/dist/pypy/translator/llvm2/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/database.py (original)
+++ pypy/dist/pypy/translator/llvm2/database.py Tue Jul 5 13:29:34 2005
@@ -84,7 +84,6 @@
if isinstance(ct, lltype.Struct):
if ct._arrayfld:
- assert False, "HERE"
self.addpending(const_or_var, StructVarsizeNode(self, value))
else:
self.addpending(const_or_var, StructNode(self, value))
Modified: pypy/dist/pypy/translator/llvm2/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm2/genllvm.py Tue Jul 5 13:29:34 2005
@@ -1,6 +1,9 @@
from os.path import exists
use_boehm_gc = exists('/usr/lib/libgc.so') or exists('/usr/lib/libgc.a')
+#XXXTmp
+use_boehm_gc = False
+
import py
from pypy.translator.llvm2 import build_llvm_module
from pypy.translator.llvm2.database import Database
Modified: pypy/dist/pypy/translator/llvm2/structnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/structnode.py (original)
+++ pypy/dist/pypy/translator/llvm2/structnode.py Tue Jul 5 13:29:34 2005
@@ -59,15 +59,17 @@
indices_to_array = [("int", 0)]
s = self.struct
while isinstance(s, lltype.Struct):
- last_pos = len(self.struct._names_without_voids()) - 1
+ last_pos = len(s._names_without_voids()) - 1
indices_to_array.append(("uint", last_pos))
- s = s._flds.values()[-1]
+ s = s._flds[s._names_without_voids()[-1]]
+
+ arraytype = self.db.repr_arg_type(s)
# Into array and length
indices = indices_to_array + [("uint", 1), ("int", "%len")]
codewriter.getelementptr("%size", self.ref + "*",
"null", *indices)
-
+
#XXX is this ok for 64bit?
codewriter.cast("%sizeu", arraytype + "*", "%size", "uint")
codewriter.malloc("%resulttmp", "sbyte", "%sizeu", atomic=is_atomic(self))
@@ -127,6 +129,8 @@
if not isinstance(T, lltype.Primitive):
# Create a dummy constant hack XXX
c = Constant(value, T)
+
+ # Needs some sanitisation
x = self.db.obj2node[c]
value = self.db.repr_arg(c)
t, v = x.getall()
@@ -149,10 +153,10 @@
return "<StructVarsizeNode %r>" %(self.ref,)
def getall(self):
-
res = []
- for name in self.value._TYPE._names_without_voids()[:-1]:
- T = self.value._TYPE._flds[name]
+ type_ = self.value._TYPE
+ for name in type_._names_without_voids()[:-1]:
+ T = type_._flds[name]
value = getattr(self.value, name)
if not isinstance(T, lltype.Primitive):
# Create a dummy constant hack XXX
@@ -162,16 +166,19 @@
res.append((self.db.repr_arg_type(T), value))
# Special case for varsized arrays
- self.value._TYPE._names_without_voids()[-1]
- x = self.db.obj2node[Constant(value, T)]
- t, v = x.get_values()
- res.append((t, "{%s}" % v))
-
- s = self.value._TYPE
- fields = [getattr(s, name) for name in s._names_without_voids()[-1]]
- l = [self.db.repr_arg_type(field) for field in fields]
- l += t
- typestr = "{ %s }" % ", ".join(l)
+ name = type_._names_without_voids()[-1]
+ T = type_._flds[name]
+ assert not isinstance(T, lltype.Primitive)
+ value = getattr(self.value, name)
+ c = Constant(value, T)
+ x = self.db.obj2node[c]
+ t, v = x.getall()
+
+ #value = self.db.repr_arg(c)
+ value = cast_global(self.db.repr_arg_type(T), t, "{%s}" % v)
+ res.append((self.db.repr_arg_type(T), value))
+
+ typestr = self.db.repr_arg_type(type_)
values = ", ".join(["%s %s" % (t, v) for t, v in res])
return typestr, values
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 Tue Jul 5 13:29:34 2005
@@ -288,7 +288,7 @@
f = compile_function(list_getitem_pbc, [int])
assert f(0) == 1
assert f(1) == 2
-
+
def test_list_list_getitem_pbc():
l = [[0, 1], [0, 1]]
def list_list_getitem_pbc(i):
@@ -316,9 +316,9 @@
def Xtest_string_getitem1():
l = "Hello, World"
- def string_test(i):
+ def string_getitem1(i):
return l[i]
- f = compile_function(string_test, [int], view=True)
+ f = compile_function(string_getitem1, [int], view=True)
assert f(0) == ord("H")
def DONOT_test_string_getitem2():
More information about the Pypy-commit
mailing list