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

ericvrp at codespeak.net ericvrp at codespeak.net
Tue Jan 10 10:19:16 CET 2006


Author: ericvrp
Date: Tue Jan 10 10:19:14 2006
New Revision: 21864

Modified:
   pypy/dist/pypy/translator/llvm/codewriter.py
   pypy/dist/pypy/translator/llvm/opwriter.py
   pypy/dist/pypy/translator/llvm/test/test_lladdresses.py
Log:
support raw flavored_malloc


Modified: pypy/dist/pypy/translator/llvm/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/codewriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/codewriter.py	Tue Jan 10 10:19:14 2006
@@ -166,4 +166,9 @@
                                                 returntype,
                                                 functionref,
                                                 args))
-        
+
+    def malloc(self, targetvar, vartype):
+        self._indent("%s = malloc %s" % (targetvar, vartype))
+
+    def free(self, vartype, varref):
+        self._indent("free %s %s" % (vartype, varref))

Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py	Tue Jan 10 10:19:14 2006
@@ -278,25 +278,17 @@
                              opr.argtypes[1:], opr.argrefs[1:])
 
     def flavored_malloc(self, opr):
-        #TYPE = self.lltypemap(opr.op.result).TO
-        #typename = self.db.gettype(TYPE)
-        #eresult = self.expr(opr.op.result)
-        #esize = 'sizeof(%s)' % cdecl(typename, '')
         flavor = opr.op.args[0].value
+        type_  = opr.rettype[:-1] #XXX stripping of *
         if flavor == "raw": 
-            self.codewriter.call(opr.retref, opr.rettype, "%raw_malloc",
-                                 opr.argtypes[1:], opr.argrefs[1:]) 
-            #return "OP_RAW_MALLOC(%s, %s);" % (esize, eresult) 
+            self.codewriter.malloc(opr.retref, type_)
         else:
             raise NotImplementedError
 
     def flavored_free(self, opr):
         flavor = opr.op.args[0].value
         if flavor == "raw":
-            self.codewriter.call(opr.retref, opr.rettype, "%raw_free",
-                                 opr.argtypes[1:], opr.argrefs[1:])
-            #return "OP_RAW_FREE(%s, %s)" % (self.expr(opr.op.args[1]),
-            #                                self.expr(opr.op.result))
+            self.codewriter.free(opr.argtypes[1], opr.argrefs[1])
         else:
             raise NotImplementedError
 

Modified: pypy/dist/pypy/translator/llvm/test/test_lladdresses.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_lladdresses.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_lladdresses.py	Tue Jan 10 10:19:14 2006
@@ -104,7 +104,6 @@
     assert res == int('011100' * 2, 2)
 
 def test_flavored_malloc():
-    py.test.skip("not supported yet")
     class A(object):
         _alloc_flavor_ = "raw"
         def __init__(self, val):



More information about the Pypy-commit mailing list