[pypy-svn] r16180 - in pypy/dist/pypy/rpython: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Aug 19 20:25:58 CEST 2005
Author: cfbolz
Date: Fri Aug 19 20:25:57 2005
New Revision: 16180
Modified:
pypy/dist/pypy/rpython/llinterp.py
pypy/dist/pypy/rpython/test/test_nongc.py
Log:
implementing flavored_malloc in the llinterpreter
Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py (original)
+++ pypy/dist/pypy/rpython/llinterp.py Fri Aug 19 20:25:57 2005
@@ -5,6 +5,7 @@
from pypy.rpython import lltype
from pypy.rpython.rmodel import getfunctionptr
from pypy.rpython.memory import lladdress
+from pypy.rpython.objectmodel import free_non_gc_object
import math
import py
@@ -284,6 +285,10 @@
else:
return self.llt.malloc(obj, size)
+ def op_flavored_malloc(self, flavor, obj):
+ assert isinstance(flavor, str)
+ return self.llt.malloc(obj, flavor=flavor)
+
def op_getfield(self, obj, field):
assert isinstance(obj, self.llt._ptr)
result = getattr(obj, field)
Modified: pypy/dist/pypy/rpython/test/test_nongc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_nongc.py (original)
+++ pypy/dist/pypy/rpython/test/test_nongc.py Fri Aug 19 20:25:57 2005
@@ -4,6 +4,7 @@
from pypy.translator.annrpython import RPythonAnnotator
from pypy.rpython.rtyper import RPythonTyper
from pypy.rpython.objectmodel import free_non_gc_object
+from pypy.rpython.test.test_llinterp import interpret
def test_free_non_gc_object():
class TestClass(object):
@@ -98,15 +99,14 @@
assert s.knowntype == int
rtyper = RPythonTyper(a)
rtyper.specialize()
-## res = interpret(f, [1])
-## assert res == 100
-## res = interpret(f, [2])
-## assert res == 110
-## res = interpret(f, [3])
-## assert res == 111
-
-## res = interpret(f, [0])
-## assert res == 0
+ res = interpret(f, [1])
+ assert res == 100
+ res = interpret(f, [2])
+ assert res == 110
+ res = interpret(f, [3])
+ assert res == 111
+ res = interpret(f, [0])
+ assert res == 0
def test_is():
@@ -148,14 +148,13 @@
def test_rtype__nongc_object():
+ from pypy.rpython.memory.lladdress import address
class TestClass(object):
- _alloc_flavor_ = ""
+ _alloc_flavor_ = "raw"
def __init__(self, a):
self.a = a
def method1(self):
return self.a
- def method2(self):
- return 42
def malloc_and_free(a):
ci = TestClass(a)
b = ci.method1()
@@ -167,3 +166,5 @@
assert isinstance(s, annmodel.SomeAddress)
rtyper = RPythonTyper(a)
rtyper.specialize()
+## res = interpret(malloc_and_free, [address()])
+## assert res == address()
More information about the Pypy-commit
mailing list