[pypy-svn] r11492 - in pypy/dist/pypy/translator/llvm: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Apr 26 21:45:21 CEST 2005


Author: cfbolz
Date: Tue Apr 26 21:45:20 2005
New Revision: 11492

Added:
   pypy/dist/pypy/translator/llvm/test/test_class.py
   pypy/dist/pypy/translator/llvm/test/test_seq.py
   pypy/dist/pypy/translator/llvm/test/test_snippet.py
Modified:
   pypy/dist/pypy/translator/llvm/class.ll
   pypy/dist/pypy/translator/llvm/classrepr.py
   pypy/dist/pypy/translator/llvm/funcrepr.py
   pypy/dist/pypy/translator/llvm/lazyattribute.py
   pypy/dist/pypy/translator/llvm/list.c
   pypy/dist/pypy/translator/llvm/list_template.ll
   pypy/dist/pypy/translator/llvm/make_runtime.py
   pypy/dist/pypy/translator/llvm/pbcrepr.py
   pypy/dist/pypy/translator/llvm/seqrepr.py
   pypy/dist/pypy/translator/llvm/test/llvmsnippet.py
   pypy/dist/pypy/translator/llvm/test/test_genllvm.py
Log:
*  Splitted the tests into more manageable chunks
*  Fixed newlist
*  Changed ListTypeRepr to enable recursive lists


Modified: pypy/dist/pypy/translator/llvm/class.ll
==============================================================================
--- pypy/dist/pypy/translator/llvm/class.ll	(original)
+++ pypy/dist/pypy/translator/llvm/class.ll	Tue Apr 26 21:45:20 2005
@@ -4,6 +4,7 @@
 %std.object = type {%std.class*}
 
 %std.list.sbyte = type {uint, sbyte*}
+%std.list.int = type {uint, int*}
 %std.exception = type {%std.class*, %std.list.sbyte*}
 %std.last_exception.type = internal global %std.class* null
 %std.last_exception.value = internal global %std.exception* null

Modified: pypy/dist/pypy/translator/llvm/classrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/classrepr.py	(original)
+++ pypy/dist/pypy/translator/llvm/classrepr.py	Tue Apr 26 21:45:20 2005
@@ -16,7 +16,8 @@
 from pypy.translator.llvm.funcrepr import VirtualMethodRepr
 from pypy.translator.llvm.memorylayout import MemoryLayout
 
-debug = False
+debug = True
+lazy_debug = True
 
 class ClassRepr(TypeRepr):
     l_classes = {}
@@ -106,6 +107,7 @@
         if self.l_base is not None:
             self.memlayout = self.l_base.memlayout.extend_layout(attribs,
                                                                  l_att_types)
+            self.dependencies.update(self.l_base.memlayout.l_types)
         else:
             attribs = ["__class__"] + attribs
             l_att_types = [SimpleTypeRepr("%std.class*", gen)] + l_att_types

Modified: pypy/dist/pypy/translator/llvm/funcrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/funcrepr.py	(original)
+++ pypy/dist/pypy/translator/llvm/funcrepr.py	Tue Apr 26 21:45:20 2005
@@ -14,7 +14,7 @@
 from pypy.translator.llvm.representation import debug, LLVMRepr, CompileError
 from pypy.translator.llvm.typerepr import TypeRepr, PointerTypeRepr
 
-debug = True
+debug = False
 
 INTRINSIC_OPS = ["lt", "le", "eq", "ne", "gt", "ge", "is_", "is_true", "len",
                  "neg", "pos", "invert", "add", "sub", "mul", "truediv",
@@ -23,8 +23,7 @@
                  "inplace_truediv", "inplace_floordiv", "inplace_div",
                  "inplace_mod", "inplace_pow", "inplace_lshift",
                  "inplace_rshift", "inplace_and", "inplace_or", "inplace_xor",
-                 "contains", "newlist", "newtuple", "alloc_and_set",
-                 "issubtype", "type", "ord"]
+                 "contains", "alloc_and_set", "issubtype", "type", "ord"]
 
 C_SIMPLE_TYPES = {annmodel.SomeChar: "char",
                   annmodel.SomeString: "char*",
@@ -232,15 +231,20 @@
 
     def create_op(self, opnumber, op):
         l_target = self.gen.get_repr(op.result)
+        self.l_func.dependencies.add(l_target)
+        if op.opname == "newtuple":
+            l_target.type.t_op_newtuple(l_target, op.args,
+                                        self.lblock, self.l_func)
+            return
+        if op.opname == "newlist":
+            l_target.type.t_op_newlist(l_target, op.args,
+                                       self.lblock, self.l_func)
+            return
         l_arg0 = self.gen.get_repr(op.args[0])
-        self.l_func.dependencies.update([l_arg0, l_target])
+        self.l_func.dependencies.add(l_arg0)
         l_op = getattr(l_arg0, "op_" + op.opname, None)
         if l_op is not None:
             l_op(l_target, op.args, self.lblock, self.l_func)
-        #XXX need to find more elegant solution for this special case
-        elif op.opname == "newtuple":
-            l_target.type.t_op_newtuple(l_target, op.args,
-                                        self.lblock, self.l_func)
         elif op.opname in INTRINSIC_OPS:
             l_args = [self.gen.get_repr(arg) for arg in op.args[1:]]
             self.l_func.dependencies.update(l_args)
@@ -477,7 +481,16 @@
     def cfuncdef(self):
         a = self.l_function.translator.annotator
         retv = self.l_function.graph.returnblock.inputargs[0]
-        rettype_c = C_SIMPLE_TYPES[a.binding(retv).__class__]
+        try:
+            rettype_c = C_SIMPLE_TYPES[a.binding(retv).__class__]
+            self.void = False
+        except KeyError:
+            l_retv = self.l_function.l_retvalue
+            if l_retv.llvmtype() == "%std.void*":
+                rettype_c = "void"
+                self.void = True
+            else:
+                raise CompileError, "Return value can't be converted to Python"
         args = self.l_function.graph.startblock.inputargs
         argtypes_c = [C_SIMPLE_TYPES[a.binding(v).__class__] for v in args]
         fd = "%s %s(%s)" % (rettype_c, self.name[1:],
@@ -501,14 +514,18 @@
         for i, a in enumerate(args):
             t += ["%s" % a]
         t = ", ".join(t)
-        s = """
-    result = %s(%s)
+        if not self.void:
+            s = "    result = %s(%s)" % (name, t)
+        else:
+            s = "    %s(%s)\n    result = None"  % (name, t)
+
+        s += """
     global pypy__uncaught_exception
     if pypy__uncaught_exception != 0:
         pypy__uncaught_exception = 0
         raise RuntimeError('An uncaught exception occured in the LLVM code.')
     else:
-        return result""" % (name, t)
+        return result"""
         self.pyrex_source.append(t + "):\n" + s)
         self.pyrex_source = "".join(self.pyrex_source)
         return self.pyrex_source

Modified: pypy/dist/pypy/translator/llvm/lazyattribute.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/lazyattribute.py	(original)
+++ pypy/dist/pypy/translator/llvm/lazyattribute.py	Tue Apr 26 21:45:20 2005
@@ -36,7 +36,7 @@
             cls.setup = setup
             c__init__ = cls.__init__
             def __init__(self, *args, **kwds):
-                ret = c__init__(self, *args, **kwds)
+                c__init__(self, *args, **kwds)
                 self.gen.lazy_objects.add(self)
                 self.__setup_called__ = False
             cls.__init__ = __init__

Modified: pypy/dist/pypy/translator/llvm/list.c
==============================================================================
--- pypy/dist/pypy/translator/llvm/list.c	(original)
+++ pypy/dist/pypy/translator/llvm/list.c	Tue Apr 26 21:45:20 2005
@@ -48,47 +48,6 @@
     return nlist;
 }
 
-//XXX implement a real newlist with an arbitrary number of args
-struct list* newlist_ALTERNATIVE1(struct item* value) {
-    struct list* nlist = malloc(sizeof(struct list));
-    nlist->length = 1;
-    nlist->data = malloc(sizeof(struct item*));
-    nlist->data[0] = value;
-    return nlist;
-}
-
-struct list* newlist_ALTERNATIVE2(struct item* v1, struct item* v2) {
-    struct list* nlist = malloc(sizeof(struct list));
-    nlist->length = 2;
-    nlist->data = malloc(sizeof(struct item*) * 2);
-    nlist->data[0] = v1;
-    nlist->data[1] = v2;
-    return nlist;
-}
-struct list* newlist_ALTERNATIVE3(struct item* v1, struct item* v2,
-				  struct item* v3) {
-    struct list* nlist = malloc(sizeof(struct list));
-    nlist->length = 3;
-    nlist->data = malloc(sizeof(struct item*) * 3);
-    nlist->data[0] = v1;
-    nlist->data[1] = v2;
-    nlist->data[2] = v3;
-    return nlist;
-}
-
-struct list* newlist_ALTERNATIVE4(struct item* v1, struct item* v2,
-				  struct item* v3, struct item* v4) {
-    struct list* nlist = malloc(sizeof(struct list));
-    nlist->length = 4;
-    nlist->data = malloc(sizeof(struct item*) * 4);
-    nlist->data[0] = v1;
-    nlist->data[1] = v2;
-    nlist->data[2] = v3;
-    nlist->data[3] = v4;
-    return nlist;
-}
-
-
 struct list* alloc_and_set(int length, struct item* init) {
     unsigned int i = 0;
     struct list* nlist = malloc(sizeof(struct list));

Modified: pypy/dist/pypy/translator/llvm/list_template.ll
==============================================================================
--- pypy/dist/pypy/translator/llvm/list_template.ll	(original)
+++ pypy/dist/pypy/translator/llvm/list_template.ll	Tue Apr 26 21:45:20 2005
@@ -19,21 +19,21 @@
 	ret void
 }
 
-internal int %std.len(%std.list.%(name)s* %l) {
+internal int %std.len(%(name)s* %l) {
 entry:
-	%tmp.1 = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.1 = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.2 = load uint* %tmp.1
 	%tmp.3 = cast uint %tmp.2 to int
 	ret int %tmp.3
 }
 
-internal int %std.valid_index(int %i, %std.list.%(name)s* %l) {
+internal int %std.valid_index(int %i, %(name)s* %l) {
 entry:
 	%tmp.1 = setlt int %i, 0
 	br bool %tmp.1, label %UnifiedReturnBlock, label %endif.0
 
 endif.0:
-	%tmp.1.i = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.1.i = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.2.i = load uint* %tmp.1.i
 	%tmp.3.i = cast uint %tmp.2.i to int
 	%not.tmp.6 = setgt int %tmp.3.i, %i
@@ -44,86 +44,23 @@
 	ret int 0
 }
 
-internal %std.list.%(name)s* %std.newlist() {
+internal %(name)s* %std.newlist() {
 entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
+	%tmp.0 = malloc %(name)s
+	%tmp.3 = getelementptr %(name)s* %tmp.0, int 0, uint 0
 	store uint 0, uint* %tmp.3
-	%tmp.5 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
+	%tmp.5 = getelementptr %(name)s* %tmp.0, int 0, uint 1
 	store %(item)s* null, %(item)s** %tmp.5
-	ret %std.list.%(name)s* %tmp.0
+	ret %(name)s* %tmp.0
 }
 
-internal %std.list.%(name)s* %std.newlist(%(item)s %value) {
+internal %(name)s* %std.alloc_and_set(int %length, %(item)s %init) {
 entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
-	store uint 1, uint* %tmp.3
-	%tmp.5 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
-	%tmp.6 = malloc %(item)s
-	store %(item)s* %tmp.6, %(item)s** %tmp.5
-	store %(item)s %value, %(item)s* %tmp.6
-	ret %std.list.%(name)s* %tmp.0
-}
-
-internal %std.list.%(name)s* %std.newlist(%(item)s %v1, %(item)s %v2) {
-entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
-	store uint 2, uint* %tmp.3
-	%tmp.5 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
-	%tmp.6 = malloc [2 x %(item)s]
-	%tmp.6.sub = getelementptr [2 x %(item)s]* %tmp.6, int 0, int 0
-	store %(item)s* %tmp.6.sub, %(item)s** %tmp.5
-	store %(item)s %v1, %(item)s* %tmp.6.sub
-	%tmp.16 = getelementptr [2 x %(item)s]* %tmp.6, int 0, int 1
-	store %(item)s %v2, %(item)s* %tmp.16
-	ret %std.list.%(name)s* %tmp.0
-}
-
-internal %std.list.%(name)s* %std.newlist(%(item)s %v1, %(item)s %v2, %(item)s %v3) {
-entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
-	store uint 3, uint* %tmp.3
-	%tmp.5 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
-	%tmp.6 = malloc [3 x %(item)s]
-	%tmp.6.sub = getelementptr [3 x %(item)s]* %tmp.6, int 0, int 0
-	store %(item)s* %tmp.6.sub, %(item)s** %tmp.5
-	store %(item)s %v1, %(item)s* %tmp.6.sub
-	%tmp.16 = getelementptr [3 x %(item)s]* %tmp.6, int 0, int 1
-	store %(item)s %v2, %(item)s* %tmp.16
-	%tmp.21 = getelementptr [3 x %(item)s]* %tmp.6, int 0, int 2
-	store %(item)s %v3, %(item)s* %tmp.21
-	ret %std.list.%(name)s* %tmp.0
-}
-
-internal %std.list.%(name)s* %std.newlist(%(item)s %v1, %(item)s %v2, %(item)s %v3, %(item)s %v4) {
-entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
-	store uint 4, uint* %tmp.3
-	%tmp.5 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
-	%tmp.6 = malloc [4 x %(item)s]
-	%tmp.6.sub = getelementptr [4 x %(item)s]* %tmp.6, int 0, int 0
-	store %(item)s* %tmp.6.sub, %(item)s** %tmp.5
-	store %(item)s %v1, %(item)s* %tmp.6.sub
-	%tmp.16 = getelementptr [4 x %(item)s]* %tmp.6, int 0, int 1
-	store %(item)s %v2, %(item)s* %tmp.16
-	%tmp.21 = getelementptr [4 x %(item)s]* %tmp.6, int 0, int 2
-	store %(item)s %v3, %(item)s* %tmp.21
-	%tmp.26 = getelementptr [4 x %(item)s]* %tmp.6, int 0, int 3
-	store %(item)s %v4, %(item)s* %tmp.26
-	ret %std.list.%(name)s* %tmp.0
-}
-
-internal %std.list.%(name)s* %std.alloc_and_set(int %length, %(item)s %init) {
-entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
+	%tmp.0 = malloc %(name)s
+	%tmp.3 = getelementptr %(name)s* %tmp.0, int 0, uint 0
 	%tmp.5 = cast int %length to uint
 	store uint %tmp.5, uint* %tmp.3
-	%tmp.7 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
+	%tmp.7 = getelementptr %(name)s* %tmp.0, int 0, uint 1
 	%tmp.8 = malloc %(item)s, uint %tmp.5
 	store %(item)s* %tmp.8, %(item)s** %tmp.7
 	%tmp.165 = seteq int %length, 0
@@ -139,17 +76,17 @@
 	br bool %tmp.16, label %no_exit, label %loopexit
 
 loopexit:
-	ret %std.list.%(name)s* %tmp.0
+	ret %(name)s* %tmp.0
 }
 
-internal %(item)s %std.getitem(%std.list.%(name)s* %l, int %index.1) {
+internal %(item)s %std.getitem(%(name)s* %l, int %index.1) {
 entry:
 	%tmp.1 = setlt int %index.1, 0
-	%tmp.11 = getelementptr %std.list.%(name)s* %l, int 0, uint 1
+	%tmp.11 = getelementptr %(name)s* %l, int 0, uint 1
 	br bool %tmp.1, label %then, label %endif
 
 then:
-	%tmp.4 = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.5 = load uint* %tmp.4
 	%tmp.5 = cast uint %tmp.5 to int
 	%tmp.9 = add int %tmp.5, %index.1
@@ -165,13 +102,13 @@
 	ret %(item)s %tmp.15
 }
 
-internal %(item)s %std.getitem.exc(%std.list.%(name)s* %l, int %index.1) {
+internal %(item)s %std.getitem.exc(%(name)s* %l, int %index.1) {
 entry:
 	%tmp.1 = setlt int %index.1, 0
 	br bool %tmp.1, label %then.0, label %endif.0.i
 
 then.0:
-	%tmp.4 = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.5 = load uint* %tmp.4
 	%tmp.5 = cast uint %tmp.5 to int
 	%tmp.9 = add int %tmp.5, %index.1
@@ -180,7 +117,7 @@
 
 endif.0.i:
 	%index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
-	%tmp.1.i.i = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.1.i.i = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.2.i.i = load uint* %tmp.1.i.i
 	%tmp.3.i.i = cast uint %tmp.2.i.i to int
 	%tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
@@ -190,7 +127,7 @@
 	store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
 	unwind
 endif.1:
-	%tmp.19 = getelementptr %std.list.%(name)s* %l, int 0, uint 1
+	%tmp.19 = getelementptr %(name)s* %l, int 0, uint 1
 	%tmp.20 = load %(item)s** %tmp.19
 	%tmp.22 = getelementptr %(item)s* %tmp.20, int %index_addr.0.0
 	%tmp.23 = load %(item)s* %tmp.22
@@ -198,14 +135,14 @@
 }
 
 
-internal void %std.setitem(%std.list.%(name)s* %l, int %index.1, %(item)s %value) {
+internal void %std.setitem(%(name)s* %l, int %index.1, %(item)s %value) {
 entry:
 	%tmp.1 = setlt int %index.1, 0
-	%tmp.11 = getelementptr %std.list.%(name)s* %l, int 0, uint 1
+	%tmp.11 = getelementptr %(name)s* %l, int 0, uint 1
 	br bool %tmp.1, label %then, label %endif
 
 then:
-	%tmp.4 = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.5 = load uint* %tmp.4
 	%tmp.5 = cast uint %tmp.5 to int
 	%tmp.9 = add int %tmp.5, %index.1
@@ -221,13 +158,13 @@
 	ret void
 }
 
-internal void %std.setitem.exc(%std.list.%(name)s* %l, int %index.1, %(item)s %value) {
+internal void %std.setitem.exc(%(name)s* %l, int %index.1, %(item)s %value) {
 entry:
 	%tmp.1 = setlt int %index.1, 0
 	br bool %tmp.1, label %then.0, label %endif.0.i
 
 then.0:
-	%tmp.4 = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.5 = load uint* %tmp.4
 	%tmp.5 = cast uint %tmp.5 to int
 	%tmp.9 = add int %tmp.5, %index.1
@@ -236,7 +173,7 @@
 
 endif.0.i:
 	%index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
-	%tmp.1.i.i = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+	%tmp.1.i.i = getelementptr %(name)s* %l, int 0, uint 0
 	%tmp.2.i.i = load uint* %tmp.1.i.i
 	%tmp.3.i.i = cast uint %tmp.2.i.i to int
 	%tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
@@ -246,27 +183,27 @@
 	store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
 	unwind
 endif.1:
-	%tmp.17 = getelementptr %std.list.%(name)s* %l, int 0, uint 1
+	%tmp.17 = getelementptr %(name)s* %l, int 0, uint 1
 	%tmp.18 = load %(item)s** %tmp.17
 	%tmp.20 = getelementptr %(item)s* %tmp.18, int %index_addr.0.0
 	store %(item)s %value, %(item)s* %tmp.20
 	ret void
 }
 
-internal %std.list.%(name)s* %std.add(%std.list.%(name)s* %a, %std.list.%(name)s* %b) {
+internal %(name)s* %std.add(%(name)s* %a, %(name)s* %b) {
 entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.0 = malloc %(name)s
+	%tmp.3 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.4 = load uint* %tmp.3
-	%tmp.6 = getelementptr %std.list.%(name)s* %b, int 0, uint 0
+	%tmp.6 = getelementptr %(name)s* %b, int 0, uint 0
 	%tmp.7 = load uint* %tmp.6
 	%tmp.8 = add uint %tmp.7, %tmp.4
-	%tmp.10 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
+	%tmp.10 = getelementptr %(name)s* %tmp.0, int 0, uint 0
 	store uint %tmp.8, uint* %tmp.10
-	%tmp.13 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
+	%tmp.13 = getelementptr %(name)s* %tmp.0, int 0, uint 1
 	%tmp.14 = malloc %(item)s, uint %tmp.8
 	store %(item)s* %tmp.14, %(item)s** %tmp.13
-	%tmp.19 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+	%tmp.19 = getelementptr %(name)s* %a, int 0, uint 1
 	%tmp.20 = load %(item)s** %tmp.19
 	%tmp.2.i14 = seteq uint %tmp.4, 0
 	br bool %tmp.2.i14, label %copy.entry, label %no_exit.i
@@ -282,7 +219,7 @@
 	br bool %tmp.2.i, label %no_exit.i, label %copy.entry
 
 copy.entry:
-	%tmp.28 = getelementptr %std.list.%(name)s* %b, int 0, uint 1
+	%tmp.28 = getelementptr %(name)s* %b, int 0, uint 1
 	%tmp.29 = load %(item)s** %tmp.28
 	%tmp.42 = sub uint %tmp.8, %tmp.4
 	%tmp.2.i319 = seteq uint %tmp.8, %tmp.4
@@ -300,26 +237,26 @@
 	br bool %tmp.2.i3, label %no_exit.i4, label %copy.entry9
 
 copy.entry9:
-	ret %std.list.%(name)s* %tmp.0
+	ret %(name)s* %tmp.0
 }
 
-internal %std.list.%(name)s* %std.mul(%std.list.%(name)s* %a, int %times) {
+internal %(name)s* %std.mul(%(name)s* %a, int %times) {
 entry:
-	%tmp.0 = malloc %std.list.%(name)s
-	%tmp.3 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.0 = malloc %(name)s
+	%tmp.3 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.4 = load uint* %tmp.3
 	%tmp.6 = cast int %times to uint
 	%tmp.7 = mul uint %tmp.4, %tmp.6
-	%tmp.9 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 0
+	%tmp.9 = getelementptr %(name)s* %tmp.0, int 0, uint 0
 	store uint %tmp.7, uint* %tmp.9
-	%tmp.12 = getelementptr %std.list.%(name)s* %tmp.0, int 0, uint 1
+	%tmp.12 = getelementptr %(name)s* %tmp.0, int 0, uint 1
 	%tmp.13 = malloc %(item)s, uint %tmp.7
 	store %(item)s* %tmp.13, %(item)s** %tmp.12
 	%tmp.194 = setgt int %times, 0
 	br bool %tmp.194, label %no_exit.preheader, label %loopexit
 
 no_exit.preheader:
-	%tmp.22 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+	%tmp.22 = getelementptr %(name)s* %a, int 0, uint 1
 	br label %no_exit
 
 no_exit:
@@ -350,18 +287,18 @@
 	br bool %tmp.19, label %no_exit, label %loopexit
 
 loopexit:
-	ret %std.list.%(name)s* %tmp.0
+	ret %(name)s* %tmp.0
 }
 
-internal %std.list.%(name)s* %std.inplace_add(%std.list.%(name)s* %a, %std.list.%(name)s* %b) {
+internal %(name)s* %std.inplace_add(%(name)s* %a, %(name)s* %b) {
 entry:
-	%tmp.2 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.2 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.3 = load uint* %tmp.2
-	%tmp.5 = getelementptr %std.list.%(name)s* %b, int 0, uint 0
+	%tmp.5 = getelementptr %(name)s* %b, int 0, uint 0
 	%tmp.6 = load uint* %tmp.5
 	%tmp.7 = add uint %tmp.6, %tmp.3
 	%tmp.0 = malloc %(item)s, uint %tmp.7
-	%tmp.11 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+	%tmp.11 = getelementptr %(name)s* %a, int 0, uint 1
 	%tmp.12 = load %(item)s** %tmp.11
 	%tmp.2.i14 = seteq uint %tmp.3, 0
 	br bool %tmp.2.i14, label %copy.entry, label %no_exit.i
@@ -377,7 +314,7 @@
 	br bool %tmp.2.i, label %no_exit.i, label %copy.entry
 
 copy.entry:
-	%tmp.18 = getelementptr %std.list.%(name)s* %b, int 0, uint 1
+	%tmp.18 = getelementptr %(name)s* %b, int 0, uint 1
 	%tmp.19 = load %(item)s** %tmp.18
 	%tmp.2.i319 = seteq uint %tmp.6, 0
 	br bool %tmp.2.i319, label %copy.entry9, label %no_exit.i4
@@ -397,18 +334,18 @@
 	store uint %tmp.7, uint* %tmp.2
 	free %(item)s* %tmp.12
 	store %(item)s* %tmp.0, %(item)s** %tmp.11
-	ret %std.list.%(name)s* %a
+	ret %(name)s* %a
 }
 
-internal void %std.append(%std.list.%(name)s* %a, %(item)s %value) {
+internal void %std.append(%(name)s* %a, %(item)s %value) {
 entry:
-	%tmp.2 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.2 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.3 = load uint* %tmp.2
 	%tmp.3-off = add uint %tmp.3, 1
 	%tmp.0 = malloc %(item)s, uint %tmp.3-off
 	%tmp.12 = getelementptr %(item)s* %tmp.0, uint %tmp.3
 	store %(item)s %value, %(item)s* %tmp.12
-	%tmp.15 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+	%tmp.15 = getelementptr %(name)s* %a, int 0, uint 1
 	%tmp.16 = load %(item)s** %tmp.15
 	%tmp.2.i5 = seteq uint %tmp.3, 0
 	br bool %tmp.2.i5, label %copy.entry, label %no_exit.i
@@ -430,13 +367,13 @@
 	ret void
 }
 
-internal %(item)s %std.pop(%std.list.%(name)s* %a, int %index.1) {
+internal %(item)s %std.pop(%(name)s* %a, int %index.1) {
 entry:
 	%tmp.1 = setlt int %index.1, 0
 	br bool %tmp.1, label %then, label %endif
 
 then:
-	%tmp.4 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.4 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.5 = load uint* %tmp.4
 	%tmp.5 = cast uint %tmp.5 to int
 	%tmp.9 = add int %tmp.5, %index.1
@@ -444,11 +381,11 @@
 
 endif:
 	%index_addr.0 = phi int [ %tmp.9, %then ], [ %index.1, %entry ]
-	%tmp.11 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+	%tmp.11 = getelementptr %(name)s* %a, int 0, uint 1
 	%tmp.12 = load %(item)s** %tmp.11
 	%tmp.14 = getelementptr %(item)s* %tmp.12, int %index_addr.0
 	%tmp.15 = load %(item)s* %tmp.14
-	%tmp.18 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.18 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.19 = load uint* %tmp.18
 	%tmp.19-off = add uint %tmp.19, 1073741823
 	%tmp.16 = malloc %(item)s, uint %tmp.19-off
@@ -493,13 +430,13 @@
 	ret %(item)s %tmp.15
 }
 
-internal %(item)s %std.pop.exc(%std.list.%(name)s* %a, int %index.1) {
+internal %(item)s %std.pop.exc(%(name)s* %a, int %index.1) {
 entry:
 	%tmp.1 = setlt int %index.1, 0
 	br bool %tmp.1, label %then.0, label %endif.0.i
 
 then.0:
-	%tmp.4 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.4 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.5 = load uint* %tmp.4
 	%tmp.5 = cast uint %tmp.5 to int
 	%tmp.9 = add int %tmp.5, %index.1
@@ -508,7 +445,7 @@
 
 endif.0.i:
 	%index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
-	%tmp.1.i.i = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.1.i.i = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.2.i.i = load uint* %tmp.1.i.i
 	%tmp.3.i.i = cast uint %tmp.2.i.i to int
 	%tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
@@ -518,7 +455,7 @@
 	store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
 	unwind
 endif.1:
-	%tmp.19 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+	%tmp.19 = getelementptr %(name)s* %a, int 0, uint 1
 	%tmp.20 = load %(item)s** %tmp.19
 	%tmp.22 = getelementptr %(item)s* %tmp.20, int %index_addr.0.0
 	%tmp.23 = load %(item)s* %tmp.22
@@ -565,25 +502,25 @@
 	ret %(item)s %tmp.23
 }
 
-internal %(item)s %std.pop(%std.list.%(name)s* %a) {
+internal %(item)s %std.pop(%(name)s* %a) {
 entry:
-	%tmp.3 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.3 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.4 = load uint* %tmp.3
 	%tmp.4 = cast uint %tmp.4 to int
 	%tmp.6 = add int %tmp.4, -1
-	%tmp.0 = call %(item)s %std.pop( %std.list.%(name)s* %a, int %tmp.6 )
+	%tmp.0 = call %(item)s %std.pop( %(name)s* %a, int %tmp.6 )
 	ret %(item)s %tmp.0
 }
 
-internal void %std.reverse(%std.list.%(name)s* %a) {
+internal void %std.reverse(%(name)s* %a) {
 entry:
-	%tmp.1 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+	%tmp.1 = getelementptr %(name)s* %a, int 0, uint 0
 	%tmp.2 = load uint* %tmp.1
 	%tmp.610 = seteq uint %tmp.2, 1
 	br bool %tmp.610, label %return, label %no_exit.preheader
 
 no_exit.preheader:
-	%tmp.9 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+	%tmp.9 = getelementptr %(name)s* %a, int 0, uint 1
 	br label %no_exit
 
 no_exit:

Modified: pypy/dist/pypy/translator/llvm/make_runtime.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/make_runtime.py	(original)
+++ pypy/dist/pypy/translator/llvm/make_runtime.py	Tue Apr 26 21:45:20 2005
@@ -118,7 +118,7 @@
 def make_list_template():
     code = get_llvm_code("list.c")
     code = cleanup_code(code)
-    code = code.replace("%struct.list", "%std.list.%(name)s")
+    code = code.replace("%struct.list", "%(name)s")
     code = code.replace("%struct.item*", "%(item)s")
     f = open(autopath.this_dir + "/list_template.ll", "w")
     print (autopath.this_dir + "/list_template.ll")

Modified: pypy/dist/pypy/translator/llvm/pbcrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/pbcrepr.py	(original)
+++ pypy/dist/pypy/translator/llvm/pbcrepr.py	Tue Apr 26 21:45:20 2005
@@ -16,7 +16,7 @@
 from pypy.translator.llvm.funcrepr import VirtualMethodRepr
 from pypy.translator.llvm.memorylayout import MemoryLayout
 
-debug = True
+debug = False
 
 class PBCTypeRepr(TypeRepr):
     def get(obj, gen):

Modified: pypy/dist/pypy/translator/llvm/seqrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/seqrepr.py	(original)
+++ pypy/dist/pypy/translator/llvm/seqrepr.py	Tue Apr 26 21:45:20 2005
@@ -7,7 +7,7 @@
 
 from pypy.translator.llvm.representation import debug, LLVMRepr
 from pypy.translator.llvm.typerepr import TypeRepr, IntTypeRepr
-from pypy.translator.llvm.typerepr import PointerTypeRepr
+from pypy.translator.llvm.typerepr import SimpleTypeRepr, PointerTypeRepr
 from pypy.translator.llvm.funcrepr import BoundMethodRepr
 
 
@@ -89,13 +89,20 @@
 
     def __init__(self, obj, gen):
         if debug:
-            print "ListTypeRepr: %s, %s" % (obj, listitem(obj))
+            print "ListTypeRepr:"
+        self.obj = obj
         self.gen = gen
-        self.l_itemtype = gen.get_repr(listitem(obj))
-        self.dependencies = sets.Set([self.l_itemtype])
+        self.dependencies = sets.Set()
+        self.name = self.gen.get_global_tmp("list")
+
+
+    lazy_attributes = ['definition', 'l_itemtype']
+
+    def setup(self):
+        self.l_itemtype = self.gen.get_repr(listitem(self.obj))
+        self.dependencies.add(self.l_itemtype)
         itemtype = self.l_itemtype.typename()
-        self.name = "%%std.list.%s" % itemtype.strip("%").replace("*", "")
-        self.definition = self.name + " = type {uint, %s*}" % itemtype
+        self.definition = self.name + " = type {uint, %s*}" % itemtype        
 
     def get_functions(self):
         f = file(autopath.this_dir + "/list_template.ll", "r")
@@ -103,7 +110,7 @@
         f.close()
         itemtype = self.l_itemtype.typename()
         s = s.replace("%(item)s", self.l_itemtype.typename())
-        s = s.replace("%(name)s", itemtype.strip("%").replace("*", ""))
+        s = s.replace("%(name)s", self.name)
         if isinstance(self.l_itemtype, IntTypeRepr):
             f1 = file(autopath.this_dir + "/int_list.ll", "r")
             s += f1.read()
@@ -136,6 +143,39 @@
         else:
             raise CompileError, "List method %s not supported." % args[1].value
 
+    def t_op_newlist(self, l_target, args, lblock, l_func):
+        l_args = [self.gen.get_repr(arg) for arg in args]
+        l_func.dependencies.update(l_args)
+        lblock.malloc(l_target)
+        l_ptrarray = self.gen.get_local_tmp(PointerTypeRepr(
+            self.l_itemtype.typename() + "*", self.gen), l_func)
+        l_ptrlength = self.gen.get_local_tmp(PointerTypeRepr("uint", self.gen),
+                                             l_func)
+        l_func.dependencies.update([l_ptrlength, l_ptrarray])
+        lblock.getelementptr(l_ptrlength, l_target, [0, 0])
+        lblock.instruction("store uint %d, uint* %s" %
+                           (len(args), l_ptrlength.llvmname()))
+        lblock.getelementptr(l_ptrarray, l_target, [0, 1])
+        if len(args) == 0:
+            lblock.instruction("store %s null, %s" %
+                               (l_ptrarray.llvmtype()[:-1],
+                                l_ptrarray.typed_name()))
+            return
+        l_arraytype = SimpleTypeRepr(
+            "[%d x %s]*" % (len(args), self.l_itemtype.typename()), self.gen)
+        l_array = self.gen.get_local_tmp(l_arraytype, l_func)
+        l_func.dependencies.update([l_arraytype, l_array])
+        lblock.malloc(l_array)
+        l_ptrs = [self.gen.get_local_tmp(
+            PointerTypeRepr(self.l_itemtype.typename(), self.gen), l_func)
+                  for a in args]
+        l_func.dependencies.update(l_ptrs)
+        for i, l_a in enumerate(l_args):         
+            lblock.getelementptr(l_ptrs[i], l_array, [0, i])
+            if i == 0:
+                lblock.store(l_ptrs[i], l_ptrarray)
+            lblock.store(l_a, l_ptrs[i])
+
 
 class TupleRepr(LLVMRepr):
     def get(obj, gen):

Modified: pypy/dist/pypy/translator/llvm/test/llvmsnippet.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/llvmsnippet.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/llvmsnippet.py	Tue Apr 26 21:45:20 2005
@@ -59,6 +59,9 @@
 def call_list_default_argument(i1):
     return list_default_argument(i1)
 
+def return_none():
+    pass
+
 #float snippets
 
 def float_f1(x):
@@ -143,6 +146,14 @@
     a = [0, 1, 2, 3]
     return a.pop() + len(a) + a[i]
 
+def newlist_zero_arg(i):
+    a = []
+    a.append(i)
+    return len(a) + a[0]
+
+def big_array(i):
+    return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17][i]
+
 glob_array = [[i] * 5 for i in range(5)]
 
 def access_global_array(x, y, z):
@@ -150,6 +161,14 @@
     glob_array[x][y] = z
     return result
 
+def circular_list(n):
+    lst = []
+    i = 0
+    while i < n:
+        i += 1
+        lst = [lst]
+    return len(lst)
+
 
 #class snippets
 
@@ -218,6 +237,27 @@
     ggg.a = x
     return previous + d + previous1
 
+def degrading_func(obj):
+    if isinstance(obj, C):
+        return obj.a + obj.b
+    elif isinstance(obj, B):
+        return obj.a
+    return -90
+
+def call_degrading_func(flag):
+    if flag:
+        return degrading_func(C(-37))
+    else:
+        return degrading_func(B())
+
+circular_instance = GGG()
+circular_instance.x = circular_instance
+circular_instance.b = 10
+
+def circular_classdef():
+    return circular_instance.x.x.x.x.x.x.x.b
+
+
 #simple inheritance snippets
 class AAA(object):
     def __init__(self):

Added: pypy/dist/pypy/translator/llvm/test/test_class.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/test/test_class.py	Tue Apr 26 21:45:20 2005
@@ -0,0 +1,76 @@
+from __future__ import division
+import autopath
+import py
+
+from pypy.translator.translator import Translator
+from pypy.translator.llvm.genllvm import LLVMGenerator
+from pypy.translator.llvm.test import llvmsnippet
+from pypy.translator.llvm.test.test_genllvm import compile_function, is_on_path
+from pypy.objspace.flow.model import Constant, Variable
+
+def setup_module(mod): 
+    mod.llvm_found = is_on_path("llvm-as")
+
+
+class TestClass(object):
+    def setup_method(self, method):
+        if not llvm_found:
+            py.test.skip("llvm-as not found on path.")
+
+    def test_classsimple(self):
+        f = compile_function(llvmsnippet.class_simple, [])
+        assert f() == 14
+
+    def test_classsimple1(self):
+        f = compile_function(llvmsnippet.class_simple1, [int])
+        assert f(2) == 10
+
+    def test_id_int(self):
+        f = compile_function(llvmsnippet.id_int, [int])
+        for i in range(1, 20):
+            assert f(i) == i
+
+    def test_classsimple2(self):
+        f = compile_function(llvmsnippet.class_simple2, [int])
+        assert f(2) == 10
+
+    def test_method_of_base_class(self):
+        f = compile_function(llvmsnippet.method_of_base_class, [])
+        assert f() == 14
+
+    def test_attribute_from_base_class(self):
+        f = compile_function(llvmsnippet.attribute_from_base_class, [])
+        assert f() == 4
+
+    def test_direct_call_of_virtual_method(self):
+        f = compile_function(llvmsnippet.direct_call_of_virtual_method, [])
+        assert f() == 14
+
+    def test_flow_type(self):
+        f = compile_function(llvmsnippet.flow_type, [])
+        assert f() == 16
+
+    def test_merge_class(self):
+        f = compile_function(llvmsnippet.merge_classes, [bool])
+        assert f(True) == 1
+        assert f(False) == 2
+
+    def test_attribute_instance(self):
+        f = compile_function(llvmsnippet.attribute_instance, [bool])
+        assert f(True) == 1
+        assert f(False) == 2
+
+    def test_global_instance(self):
+        f = compile_function(llvmsnippet.global_instance, [int])
+        assert f(-1) == 41
+        for i in range(20):
+            assert f(i) == 2 * i
+
+    def test_call_degrading_func(self):
+        f = compile_function(llvmsnippet.call_degrading_func, [bool])
+        assert f(True) == -36
+        assert f(False) == 14
+    
+    def test_circular_classdef(self):
+        f = compile_function(llvmsnippet.circular_classdef, [])
+        assert f() == 10

Modified: pypy/dist/pypy/translator/llvm/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_genllvm.py	Tue Apr 26 21:45:20 2005
@@ -2,12 +2,9 @@
 import autopath
 import py
 
-import StringIO
-
 from pypy.translator.translator import Translator
 from pypy.translator.llvm.genllvm import LLVMGenerator
 from pypy.translator.llvm.test import llvmsnippet
-from pypy.translator.test import snippet as test
 from pypy.objspace.flow.model import Constant, Variable
 
 def setup_module(mod): 
@@ -34,24 +31,13 @@
         if not llvm_found:
             py.test.skip("llvm-as not found on path")
 
-    def DONOT_test_simple1(self):
+    def test_simple1(self):
         t = Translator(llvmsnippet.simple1)
         a = t.annotate([])
         gen = LLVMGenerator(t)
         l_repr = gen.get_repr(t.getflowgraph().startblock.exits[0].args[0])
         assert l_repr.llvmname() == "1"
         assert l_repr.typed_name() == "int 1"
-        print gen.l_entrypoint.get_functions()
-        assert gen.l_entrypoint.get_functions() == """\
-int %simple1() {
-block0:
-\tbr label %block1
-block1:
-\t%v0 = phi int [1, %block0]
-\tret int %v0
-}
-
-"""
 
     def test_simple2(self):
         t = Translator(llvmsnippet.simple2)
@@ -63,26 +49,6 @@
         assert l_repr.llvmname() == "false"
         assert l_repr.typed_name() == "bool false"
 
-    def DONOT_test_typerepr(self):
-        t = Translator(llvmsnippet.simple1)
-        a = t.annotate([])
-        gen = LLVMGenerator(t)
-        l_repr = gen.get_repr(str)
-        assert l_repr.llvmname() == "%std.string*"
-
-    def DONOT_test_stringrepr(self):
-        t = Translator(llvmsnippet.simple3)
-        a = t.annotate([])
-        gen = LLVMGenerator(t)
-        l_repr1 = gen.get_repr(t.getflowgraph().startblock.exits[0].args[0])
-        l_repr2 = gen.get_repr(t.getflowgraph().startblock.exits[0].args[0])
-        assert l_repr1 is l_repr2
-        assert l_repr1.typed_name() == "%std.string* %glb.StringRepr.2"
-        assert l_repr2.get_globals() == """%glb.StringRepr.1 = \
-internal constant [13 x sbyte] c"Hello, Stars!"
-%glb.StringRepr.2 = internal constant %std.string {uint 13,\
-sbyte* getelementptr ([13 x sbyte]* %glb.StringRepr.1, uint 0, uint 0)}"""
-
 class TestGenLLVM(object):
     def setup_method(self,method):
         if not llvm_found:
@@ -127,6 +93,10 @@
         for i in range(20):
             assert f(i) == llvmsnippet.call_list_default_argument(i)
 
+    def test_return_none(self):
+        f = compile_function(llvmsnippet.return_none, [])
+        assert f() is None
+
 class TestFloat(object):
     def setup_method(self, method):
         if not llvm_found:
@@ -140,136 +110,7 @@
         f = compile_function(llvmsnippet.float_int_bool, [float])
         assert f(3.0) == 9.0
 
-class TestLLVMArray(object):
-    def setup_method(self, method):
-        if not llvm_found:
-            py.test.skip("llvm-as not found on path.")
-
-    def test_array(self):
-        f = compile_function(llvmsnippet.array_simple, [])
-        assert f() == 42
-
-    def test_array1(self):
-        f = compile_function(llvmsnippet.array_simple1, [int])
-        assert f(1) == 10
-        assert f(-42) == -420
-
-    def test_array_setitem(self):
-        f = compile_function(llvmsnippet.array_setitem, [int])
-        print f(1), f(2), f(3)
-        assert f(1) == 12
-        assert f(2) == 13
-        assert f(3) == 3
-
-    def test_array_add(self):
-        f = compile_function(llvmsnippet.array_add, [int, int, int, int, int])
-        assert f(1,2,3,4,0) == 1
-        assert f(1,2,3,4,1) == 2
-        assert f(1,2,3,4,2) == 3
-        assert f(1,2,5,6,3) == 6
-
-    def test_array_double(self):
-        f = compile_function(llvmsnippet.double_array, [])
-        assert f() == 15
-
-    def test_bool_array(self):
-        f = compile_function(llvmsnippet.bool_array, [])
-        assert f() == 1
-
-    def test_array_arg(self):
-        f = compile_function(llvmsnippet.array_arg, [int])
-        assert f(5) == 0
-
-    def test_array_len(self):
-        f = compile_function(llvmsnippet.array_len, [])
-        assert f() == 10
-
-    def test_array_append(self):
-        f = compile_function(llvmsnippet.array_append, [int])
-        for i in range(3):
-            assert f(i) == 0
-        assert f(3) == 10
-
-    def test_array_reverse(self):
-        f = compile_function(llvmsnippet.array_reverse, [int])
-        assert f(0) == 1
-        assert f(1) == 0
-
-    def test_range(self):
-        f = compile_function(llvmsnippet.rangetest, [int])
-        for i in range(10):
-            assert f(i) == i
-
-    def test_array_pop(self):
-        f = compile_function(llvmsnippet.array_pop, [int])
-        assert f(0) == 6
-        assert f(1) == 7
-        assert f(2) == 8
-
-    def test_access_global_array(self):
-        f = compile_function(llvmsnippet.access_global_array, [int, int, int])
-        for i in range(5):
-            for j in range(5):
-                assert f(i, j, i + j) == i
-        for i in range(5):
-            for j in range(5):
-                assert f(i, j, 0) == i + j
-        
-
-class TestClass(object):
-    def setup_method(self, method):
-        if not llvm_found:
-            py.test.skip("llvm-as not found on path.")
-
-    def test_classsimple(self):
-        f = compile_function(llvmsnippet.class_simple, [])
-        assert f() == 14
-
-    def test_classsimple1(self):
-        f = compile_function(llvmsnippet.class_simple1, [int])
-        assert f(2) == 10
-
-    def test_id_int(self):
-        f = compile_function(llvmsnippet.id_int, [int])
-        for i in range(1, 20):
-            assert f(i) == i
-
-    def test_classsimple2(self):
-        f = compile_function(llvmsnippet.class_simple2, [int])
-        assert f(2) == 10
-
-    def test_method_of_base_class(self):
-        f = compile_function(llvmsnippet.method_of_base_class, [])
-        assert f() == 14
-
-    def test_attribute_from_base_class(self):
-        f = compile_function(llvmsnippet.attribute_from_base_class, [])
-        assert f() == 4
 
-    def test_direct_call_of_virtual_method(self):
-        f = compile_function(llvmsnippet.direct_call_of_virtual_method, [])
-        assert f() == 14
-
-    def test_flow_type(self):
-        f = compile_function(llvmsnippet.flow_type, [])
-        assert f() == 16
-
-    def test_merge_class(self):
-        f = compile_function(llvmsnippet.merge_classes, [bool])
-        assert f(True) == 1
-        assert f(False) == 2
-
-    def test_attribute_instance(self):
-        f = compile_function(llvmsnippet.attribute_instance, [bool])
-        assert f(True) == 1
-        assert f(False) == 2
-
-    def test_global_instance(self):
-        f = compile_function(llvmsnippet.global_instance, [int])
-        assert f(-1) == 41
-        for i in range(20):
-            assert f(i) == 2 * i
-    
 class TestString(object):
     def setup_method(self, method):
         if not llvm_found:
@@ -279,26 +120,6 @@
         f = compile_function(llvmsnippet.string_f2, [int, int])
         assert chr(f(1, 0)) == "a"
 
-class TestTuple(object):
-    def setup_method(self, method):
-        if not llvm_found:
-            py.test.skip("llvm-as not found on path.")
-
-    def test_f1(self):
-        f = compile_function(llvmsnippet.tuple_f1, [int])
-        assert f(10) == 10
-        assert f(15) == 15
-
-    def test_f3(self):
-        f = compile_function(llvmsnippet.tuple_f3, [int])
-        assert f(10) == 10
-        assert f(15) == 15
-        assert f(30) == 30
-
-    def test_constant_tuple(self):
-        f = compile_function(llvmsnippet.constant_tuple, [int])
-        for i in range(3, 7):
-            assert f(i) == i + 3
 
 class TestException(object):
     def setup_method(self,method):
@@ -355,91 +176,3 @@
         assert f(2) == 17
         assert f(3) == 19
 
-class TestSnippet(object):
-    def setup_method(self, method):
-        if not llvm_found:
-            py.test.skip("llvm-as not found on path.")
-        
-    def test_if_then_else(self):
-        f = compile_function(test.if_then_else, [int, int, int])
-        assert f(0, 12, 13) == 13
-        assert f(13, 12, 13) == 12
-        
-    def test_my_gcd(self):
-        f = compile_function(test.my_gcd, [int, int])
-        assert f(15, 5) == 5
-        assert f(18, 42) == 6
-
-    def test_is_perfect_number(self):
-        f = compile_function(test.is_perfect_number, [int])
-        assert f(28) == 1
-        assert f(123) == 0
-        assert f(496) == 1
-
-    def test_my_bool(self):
-        f = compile_function(test.my_bool, [int])
-        assert f(10) == 1
-        assert f(1) == 1
-        assert f(0) == 0
-
-    def test_two_plus_two(self):
-        f = compile_function(test.two_plus_two, [])
-        assert f() == 4
-
-    def test_sieve_of_eratosthenes(self):
-        f = compile_function(test.sieve_of_eratosthenes, [])
-        assert f() == 1028
-
-    def test_simple_func(self):
-        f = compile_function(test.simple_func, [int])
-        assert f(1027) == 1028
-        
-    def test_while_func(self):
-        while_func = compile_function(test.while_func, [int])
-        assert while_func(10) == 55
-
-    def test_time_waster(self):
-        f = compile_function(test.time_waster, [int])
-        assert f(1) == 1
-        assert f(2) == 2
-        assert f(3) == 6
-        assert f(4) == 12
-
-    def test_int_id(self):
-        f = compile_function(test.int_id, [int])
-        assert f(1027) == 1027
-
-    def test_factorial2(self):
-        factorial2 = compile_function(test.factorial2, [int])
-        assert factorial2(5) == 120
-
-    def test_factorial(self):
-        factorial = compile_function(test.factorial, [int])
-        assert factorial(5) == 120
-
-    def test_set_attr(self):
-        set_attr = compile_function(test.set_attr, [])
-        assert set_attr() == 2
-
-    def test_try_raise_choose(self):
-        try_raise_choose = compile_function(test.try_raise_choose, [int])
-        for i in [-1, 0, 1, 2]:
-            assert try_raise_choose(i) == i
-
-    def test_merge_setattr(self):
-        merge_setattr = compile_function(test.merge_setattr, [bool])
-        assert merge_setattr(1) == 1
-
-    def test_simple_method(self):
-        simple_method = compile_function(test.simple_method, [int])
-        assert simple_method(65) == 65
-
-    def test_with_init(self):
-        with_init = compile_function(test.with_init, [int])
-        assert with_init(42) == 42
-
-    def DONOT_test_with_more_init(self):
-        with_more_init = compile_function(test.with_more_init, [int, bool])
-        assert with_more_init(42, True) == 42
-        assert with_more_init(42, False) == -42
-

Added: pypy/dist/pypy/translator/llvm/test/test_seq.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/test/test_seq.py	Tue Apr 26 21:45:20 2005
@@ -0,0 +1,128 @@
+from __future__ import division
+import autopath
+import py
+
+from pypy.translator.translator import Translator
+from pypy.translator.llvm.genllvm import LLVMGenerator
+from pypy.translator.llvm.test import llvmsnippet
+from pypy.translator.llvm.test.test_genllvm import compile_function, is_on_path
+from pypy.objspace.flow.model import Constant, Variable
+
+def setup_module(mod): 
+    mod.llvm_found = is_on_path("llvm-as")
+
+
+class TestLLVMArray(object):
+    def setup_method(self, method):
+        if not llvm_found:
+            py.test.skip("llvm-as not found on path.")
+
+    def test_array(self):
+        f = compile_function(llvmsnippet.array_simple, [])
+        assert f() == 42
+
+    def test_array1(self):
+        f = compile_function(llvmsnippet.array_simple1, [int])
+        assert f(1) == 10
+        assert f(-42) == -420
+
+    def test_array_setitem(self):
+        f = compile_function(llvmsnippet.array_setitem, [int])
+        print f(1), f(2), f(3)
+        assert f(1) == 12
+        assert f(2) == 13
+        assert f(3) == 3
+
+    def test_array_add(self):
+        f = compile_function(llvmsnippet.array_add, [int, int, int, int, int])
+        assert f(1,2,3,4,0) == 1
+        assert f(1,2,3,4,1) == 2
+        assert f(1,2,3,4,2) == 3
+        assert f(1,2,5,6,3) == 6
+
+    def test_array_double(self):
+        f = compile_function(llvmsnippet.double_array, [])
+        assert f() == 15
+
+    def test_bool_array(self):
+        f = compile_function(llvmsnippet.bool_array, [])
+        assert f() == 1
+
+    def test_array_arg(self):
+        f = compile_function(llvmsnippet.array_arg, [int])
+        assert f(5) == 0
+
+    def test_array_len(self):
+        f = compile_function(llvmsnippet.array_len, [])
+        assert f() == 10
+
+    def test_array_append(self):
+        f = compile_function(llvmsnippet.array_append, [int])
+        for i in range(3):
+            assert f(i) == 0
+        assert f(3) == 10
+
+    def test_array_reverse(self):
+        f = compile_function(llvmsnippet.array_reverse, [int])
+        assert f(0) == 1
+        assert f(1) == 0
+
+    def test_range(self):
+        f = compile_function(llvmsnippet.rangetest, [int])
+        for i in range(10):
+            assert f(i) == i
+
+    def test_array_pop(self):
+        f = compile_function(llvmsnippet.array_pop, [int])
+        assert f(0) == 6
+        assert f(1) == 7
+        assert f(2) == 8
+
+    def test_newlist_zero_arg(self):
+        f = compile_function(llvmsnippet.newlist_zero_arg, [int])
+        assert f(10) == 11
+        assert f(-41) == -40
+
+    def test_big_array(self):
+        f = compile_function(llvmsnippet.big_array, [int])
+        for i in range(18):
+            assert f(i) == i
+    
+
+    def test_access_global_array(self):
+        f = compile_function(llvmsnippet.access_global_array, [int, int, int])
+        for i in range(5):
+            for j in range(5):
+                assert f(i, j, i + j) == i
+        for i in range(5):
+            for j in range(5):
+                assert f(i, j, 0) == i + j
+
+    def test_circular_list(self):
+        f = compile_function(llvmsnippet.circular_list, [int])
+        assert f(0) == 0
+        assert f(1) == 1
+        assert f(10) == 1
+
+
+class TestTuple(object):
+    def setup_method(self, method):
+        if not llvm_found:
+            py.test.skip("llvm-as not found on path.")
+
+    def test_f1(self):
+        f = compile_function(llvmsnippet.tuple_f1, [int])
+        assert f(10) == 10
+        assert f(15) == 15
+
+    def test_f3(self):
+        f = compile_function(llvmsnippet.tuple_f3, [int])
+        assert f(10) == 10
+        assert f(15) == 15
+        assert f(30) == 30
+
+    def test_constant_tuple(self):
+        f = compile_function(llvmsnippet.constant_tuple, [int])
+        for i in range(3, 7):
+            assert f(i) == i + 3
+

Added: pypy/dist/pypy/translator/llvm/test/test_snippet.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/test/test_snippet.py	Tue Apr 26 21:45:20 2005
@@ -0,0 +1,102 @@
+from __future__ import division
+import autopath
+import py
+
+from pypy.translator.translator import Translator
+from pypy.translator.llvm.genllvm import LLVMGenerator
+from pypy.translator.llvm.test import llvmsnippet
+from pypy.translator.llvm.test.test_genllvm import compile_function, is_on_path
+from pypy.translator.test import snippet as test
+from pypy.objspace.flow.model import Constant, Variable
+
+def setup_module(mod): 
+    mod.llvm_found = is_on_path("llvm-as")
+
+class TestSnippet(object):
+    def setup_method(self, method):
+        if not llvm_found:
+            py.test.skip("llvm-as not found on path.")
+        
+    def test_if_then_else(self):
+        f = compile_function(test.if_then_else, [int, int, int])
+        assert f(0, 12, 13) == 13
+        assert f(13, 12, 13) == 12
+        
+    def test_my_gcd(self):
+        f = compile_function(test.my_gcd, [int, int])
+        assert f(15, 5) == 5
+        assert f(18, 42) == 6
+
+    def test_is_perfect_number(self):
+        f = compile_function(test.is_perfect_number, [int])
+        assert f(28) == 1
+        assert f(123) == 0
+        assert f(496) == 1
+
+    def test_my_bool(self):
+        f = compile_function(test.my_bool, [int])
+        assert f(10) == 1
+        assert f(1) == 1
+        assert f(0) == 0
+
+    def test_two_plus_two(self):
+        f = compile_function(test.two_plus_two, [])
+        assert f() == 4
+
+    def test_sieve_of_eratosthenes(self):
+        f = compile_function(test.sieve_of_eratosthenes, [])
+        assert f() == 1028
+
+    def test_simple_func(self):
+        f = compile_function(test.simple_func, [int])
+        assert f(1027) == 1028
+        
+    def test_while_func(self):
+        while_func = compile_function(test.while_func, [int])
+        assert while_func(10) == 55
+
+    def test_time_waster(self):
+        f = compile_function(test.time_waster, [int])
+        assert f(1) == 1
+        assert f(2) == 2
+        assert f(3) == 6
+        assert f(4) == 12
+
+    def test_int_id(self):
+        f = compile_function(test.int_id, [int])
+        assert f(1027) == 1027
+
+    def test_factorial2(self):
+        factorial2 = compile_function(test.factorial2, [int])
+        assert factorial2(5) == 120
+
+    def test_factorial(self):
+        factorial = compile_function(test.factorial, [int])
+        assert factorial(5) == 120
+
+    def test_set_attr(self):
+        set_attr = compile_function(test.set_attr, [])
+        assert set_attr() == 2
+
+    def test_try_raise_choose(self):
+        try_raise_choose = compile_function(test.try_raise_choose, [int])
+        for i in [-1, 0, 1, 2]:
+            assert try_raise_choose(i) == i
+
+    def test_merge_setattr(self):
+        merge_setattr = compile_function(test.merge_setattr, [bool])
+        assert merge_setattr(1) == 1
+
+    def test_simple_method(self):
+        simple_method = compile_function(test.simple_method, [int])
+        assert simple_method(65) == 65
+
+    def test_with_init(self):
+        with_init = compile_function(test.with_init, [int])
+        assert with_init(42) == 42
+
+    def DONOT_test_with_more_init(self):
+        with_more_init = compile_function(test.with_more_init, [int, bool])
+        assert with_more_init(42, True) == 42
+        assert with_more_init(42, False) == -42
+



More information about the Pypy-commit mailing list