[pypy-svn] r13441 - in pypy/dist/pypy/rpython: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Jun 15 16:23:08 CEST 2005
Author: arigo
Date: Wed Jun 15 16:23:06 2005
New Revision: 13441
Modified:
pypy/dist/pypy/rpython/interp.py
pypy/dist/pypy/rpython/test/test_interp.py
Log:
* comments about the details of the low-level operations
* assert(..., _ptr) looks indeed like the way to check for pointer-ness
* _getobj() should not be called explicitely in the test (not needed here)
Modified: pypy/dist/pypy/rpython/interp.py
==============================================================================
--- pypy/dist/pypy/rpython/interp.py (original)
+++ pypy/dist/pypy/rpython/interp.py Wed Jun 15 16:23:06 2005
@@ -1,4 +1,5 @@
from pypy.rpython.lltype import *
+from pypy.rpython.lltype import _ptr
import py
@@ -91,24 +92,42 @@
def op_setfield(self, obj, fieldname, fieldvalue):
# obj should be pointer
- setattr(obj, fieldname, fieldvalue) # is that right?
+ setattr(obj, fieldname, fieldvalue) # is that right? -- yes
def op_direct_call(self,f,*args):
+ # XXX the logic should be:
+ # if f._obj has a graph attribute, interpret
+ # that graph without looking at _callable
res = self.eval_function(f._obj._callable,args)
return res
- def op_malloc(self,obj, n=None, immortal=False):
- return malloc(obj,n,immortal)
+ def op_malloc(self,obj):
+ return malloc(obj)
def op_getfield(self,obj,field):
- return getattr(obj,field)
-
+ # assert: obj should be pointer
+ result = getattr(obj,field)
+ # check the difference between op_getfield and op_getsubstruct:
+ # the former returns the real field, the latter a pointer to it
+ assert typeOf(result) == getattr(typeOf(obj).TO, field)
+ return result
+
+ def op_getsubstruct(self,obj,field):
+ # assert: obj should be pointer
+ result = getattr(obj,field)
+ # check the difference between op_getfield and op_getsubstruct:
+ # the former returns the real field, the latter a pointer to it
+ assert typeOf(result) == Ptr(getattr(typeOf(obj).TO, field))
+ return result
+
def op_malloc_varsize(self,obj,size):
- return self.op_malloc(obj,size)
+ return malloc(obj,size)
def op_getarraysubstruct(self,array,index):
- #assert isinstance(array,_ptr)
+ assert isinstance(array,_ptr)
return array[index]
+ # the diff between op_getarrayitem and op_getarraysubstruct
+ # is the same as between op_getfield and op_getsubstruct
# __________________________________________________________
# primitive operations
Modified: pypy/dist/pypy/rpython/test/test_interp.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_interp.py (original)
+++ pypy/dist/pypy/rpython/test/test_interp.py Wed Jun 15 16:23:06 2005
@@ -66,7 +66,7 @@
res = interpret(f,[])
assert len(res.items) == len([1,2,3])
for i in range(3):
- assert res.items[i]._getobj().item == i+1
+ assert res.items[i].item == i+1
#__________________________________________________________________
# example functions for testing the LLInterpreter
_snap = globals().copy()
More information about the Pypy-commit
mailing list