Author: Richard Plangger <planri...@gmail.com>
Branch: s390x-backend
Changeset: r82612:df3c1340c16f
Date: 2016-02-29 14:58 +0100
http://bitbucket.org/pypy/pypy/changeset/df3c1340c16f/

Log:    list create, list concat

diff --git a/rpython/jit/backend/llsupport/tl/code.py 
b/rpython/jit/backend/llsupport/tl/code.py
--- a/rpython/jit/backend/llsupport/tl/code.py
+++ b/rpython/jit/backend/llsupport/tl/code.py
@@ -128,6 +128,25 @@
     def __init__(self):
         pass
 
+@requires_stack(LIST_TYP, LIST_TYP)
+@leaves_on_stack(LIST_TYP)
+class AddList(ByteCode):
+    BYTE_CODE = unique_code()
+    def __init__(self):
+        pass
+
+@requires_stack()
+@leaves_on_stack(LIST_TYP)
+class CreateList(ByteCode):
+    BYTE_CODE = unique_code()
+    @requires_param(BYTE_TYP)
+    def __init__(self, size=8):
+        self.size = size
+    def encode(self, ctx):
+        ctx.append_byte(self.BYTE_CODE)
+        ctx.append_short(self.size)
+
+
 # remove comment one by one!
 
 #@requires_stack()
@@ -157,24 +176,6 @@
 #        pass
 #
 
-#
-#@requires_stack(LIST_TYP, LIST_TYP)
-#@leaves_on_stack(LIST_TYP)
-#class AddList(ByteCode):
-#    BYTE_CODE = unique_code()
-#    def __init__(self):
-#        pass
-#
-#@requires_stack()
-#class CreateList(ByteCode):
-#    BYTE_CODE = unique_code()
-#    @requires_param(BYTE_TYP)
-#    def __init__(self, size=8):
-#        self.size = size
-#    def encode(self, ctx):
-#        ctx.append_byte(self.BYTE_CODE)
-#        ctx.append_short(self.size)
-#
 #@requires_stack(LIST_TYP, INT_TYP, INT_TYP) # TODO VAL_TYP
 #class InsertList(ByteCode):
 #    BYTE_CODE = unique_code()
diff --git a/rpython/jit/backend/llsupport/tl/interp.py 
b/rpython/jit/backend/llsupport/tl/interp.py
--- a/rpython/jit/backend/llsupport/tl/interp.py
+++ b/rpython/jit/backend/llsupport/tl/interp.py
@@ -6,8 +6,12 @@
     pass
 
 class W_ListObject(W_Root):
-    def __init__(self):
-        self.items = []
+    def __init__(self, items):
+        self.items = items
+
+    def concat(self, w_lst):
+        assert isinstance(w_lst, W_ListObject)
+        return self.items + w_lst.items
 
 class W_IntObject(W_Root):
     def __init__(self, value):
@@ -36,6 +40,8 @@
             return W_StrObject(val)
         if isinstance(val, unicode):
             return W_StrObject(val.encode('utf-8'))
+        if isinstance(val, list):
+            return W_ListObject(val)
         raise NotImplementedError("cannot handle: " + str(val) + 
str(type(val)))
 
 def entry_point(argv):
@@ -70,6 +76,14 @@
         w_str2 = stack.pop()
         w_str1 = stack.pop()
         stack.append(space.wrap(w_str1.concat(w_str2)))
+    elif opcode == code.AddList.BYTE_CODE:
+        w_lst2 = stack.pop()
+        w_lst1 = stack.pop()
+        stack.append(space.wrap(w_lst1.concat(w_lst2)))
+    elif opcode == code.CreateList.BYTE_CODE:
+        size = runpack('h', bytecode[i+1:i+3])
+        stack.append(space.wrap([None] * size))
+        i += 2
     else:
         raise NotImplementedError
     return i + 1
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to