[pypy-svn] r15530 - in pypy/dist/pypy/translator/llvm2: . module test
ericvrp at codespeak.net
ericvrp at codespeak.net
Wed Aug 3 01:43:27 CEST 2005
Author: ericvrp
Date: Wed Aug 3 01:43:25 2005
New Revision: 15530
Modified:
pypy/dist/pypy/translator/llvm2/codewriter.py
pypy/dist/pypy/translator/llvm2/genllvm.py
pypy/dist/pypy/translator/llvm2/module/extfunction.py
pypy/dist/pypy/translator/llvm2/module/ll_math.py
pypy/dist/pypy/translator/llvm2/module/ll_os.py
pypy/dist/pypy/translator/llvm2/module/ll_time.py
pypy/dist/pypy/translator/llvm2/module/support.py
pypy/dist/pypy/translator/llvm2/pyxwrapper.py
pypy/dist/pypy/translator/llvm2/test/test_exception.py
pypy/dist/pypy/translator/llvm2/test/test_extfunc.py
Log:
- added entrypoint wrapper function to handle llvm->CPython exception conversions (very basic right now)
- added calling convention (ccc/fastcc) to enable llvm to do its magic with functioncalls
Last remaining exceptions test now passes!
The test that is left is skipped because the interpreter does not like it.
Modified: pypy/dist/pypy/translator/llvm2/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/codewriter.py (original)
+++ pypy/dist/pypy/translator/llvm2/codewriter.py Wed Aug 3 01:43:25 2005
@@ -46,7 +46,7 @@
", ".join(argtypereprs)))
def declare(self, decl):
- self.append("declare %s" %(decl,))
+ self.append("declare fastcc %s" %(decl,))
def startimpl(self):
self.newline()
@@ -69,7 +69,7 @@
def openfunc(self, decl):
self.newline()
- self.append("%s {" % (decl,))
+ self.append("fastcc %s {" % (decl,))
def closefunc(self):
self.append("}")
@@ -99,21 +99,21 @@
def call(self, targetvar, returntype, functionref, argrefs, argtypes):
arglist = ["%s %s" % item for item in zip(argtypes, argrefs)]
- self.indent("%s = call %s %s(%s)" % (targetvar, returntype, functionref,
+ self.indent("%s = call fastcc %s %s(%s)" % (targetvar, returntype, functionref,
", ".join(arglist)))
def call_void(self, functionref, argrefs, argtypes):
arglist = ["%s %s" % item for item in zip(argtypes, argrefs)]
- self.indent("call void %s(%s)" % (functionref, ", ".join(arglist)))
+ self.indent("call fastcc void %s(%s)" % (functionref, ", ".join(arglist)))
def invoke(self, targetvar, returntype, functionref, argrefs, argtypes, label, except_label):
arglist = ["%s %s" % item for item in zip(argtypes, argrefs)]
- self.indent("%s = invoke %s %s(%s) to label %%%s except label %%%s" % (targetvar, returntype, functionref,
+ self.indent("%s = invoke fastcc %s %s(%s) to label %%%s except label %%%s" % (targetvar, returntype, functionref,
", ".join(arglist), label, except_label))
def invoke_void(self, functionref, argrefs, argtypes, label, except_label):
arglist = ["%s %s" % item for item in zip(argtypes, argrefs)]
- self.indent("invoke void %s(%s) to label %%%s except label %%%s" % (functionref, ", ".join(arglist), label, except_label))
+ self.indent("invoke fastcc void %s(%s) to label %%%s except label %%%s" % (functionref, ", ".join(arglist), label, except_label))
def cast(self, targetvar, fromtype, fromvar, targettype):
self.indent("%(targetvar)s = cast %(fromtype)s "
@@ -124,7 +124,7 @@
postfix = ('', '_atomic')[atomic]
self.indent("%%malloc.Size.%(cnt)d = getelementptr %(type_)s* null, uint %(size)s" % locals())
self.indent("%%malloc.SizeU.%(cnt)d = cast %(type_)s* %%malloc.Size.%(cnt)d to uint" % locals())
- self.indent("%%malloc.Ptr.%(cnt)d = call sbyte* %%gc_malloc%(postfix)s(uint %%malloc.SizeU.%(cnt)d)" % locals())
+ self.indent("%%malloc.Ptr.%(cnt)d = call fastcc sbyte* %%gc_malloc%(postfix)s(uint %%malloc.SizeU.%(cnt)d)" % locals())
self.indent("%(targetvar)s = cast sbyte* %%malloc.Ptr.%(cnt)d to %(type_)s*" % locals())
def getelementptr(self, targetvar, type, typevar, *indices):
@@ -140,7 +140,7 @@
"%(valuetype)s* %(ptr)s" % locals())
def debugcomment(self, tempname, len, tmpname):
- res = "%s = tail call int (sbyte*, ...)* %%printf("
+ res = "%s = tail call ccc int (sbyte*, ...)* %%printf("
res += "sbyte* getelementptr ([%s x sbyte]* %s, int 0, int 0) )"
res = res % (tmpname, len, tmpname)
self.indent(res)
Modified: pypy/dist/pypy/translator/llvm2/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm2/genllvm.py Wed Aug 3 01:43:25 2005
@@ -23,6 +23,8 @@
class GenLLVM(object):
def __init__(self, translator, debug=False, embedexterns=True):
+ embedexterns = True # XXX just for now because exception handling globals must be available
+
# reset counters
LLVMNode.nodename_count = {}
self.db = Database(translator)
@@ -90,8 +92,8 @@
gc_funcs = gc_boehm
else:
gc_funcs = gc_disabled
- for extfunc in gc_funcs.split('\n'):
- codewriter.append(extfunc)
+ for gc_func in gc_funcs.split('\n'):
+ codewriter.append(gc_func)
for typ_decl in self.db.getnodes():
typ_decl.writeimpl(codewriter)
@@ -110,6 +112,34 @@
codewriter.append(extfunc)
depdone[dep] = True
+ #XXX use codewriter methods here
+ decl = self.entrynode.getdecl()
+ t = decl.split('%', 1)
+ if t[0] == 'double ': #XXX I know, I know... refactor at will!
+ no_result = '0.0'
+ elif t[0] == 'bool ':
+ no_result = 'false'
+ else:
+ no_result = '0'
+ codewriter.newline()
+ codewriter.append("ccc %s%%__entrypoint__%s {" % (t[0], t[1]))
+ codewriter.append(" %%result = invoke fastcc %s%%%s to label %%no_exception except label %%exception" % (t[0], t[1]))
+ codewriter.newline()
+ codewriter.append("no_exception:")
+ codewriter.append(" store %structtype.object_vtable* null, %structtype.object_vtable** %last_exception_type")
+ codewriter.append(" ret %s%%result" % t[0])
+ codewriter.newline()
+ codewriter.append("exception:")
+ codewriter.append(" ret %s%s" % (t[0], no_result))
+ codewriter.append("}")
+ codewriter.newline()
+ codewriter.append("ccc int %__entrypoint__raised_LLVMException() {")
+ codewriter.append(" %tmp = load %structtype.object_vtable** %last_exception_type")
+ codewriter.append(" %result = cast %structtype.object_vtable* %tmp to int")
+ codewriter.append(" ret int %result")
+ codewriter.append("}")
+ codewriter.newline()
+
comment("End of file") ; nl()
self.content = str(codewriter)
return self.content
@@ -127,7 +157,7 @@
targetdir = udir
llvmsource = targetdir.join(func.func_name+postfix).new(ext='.ll')
- llvmsource.write(self.content)
+ llvmsource.write(self.content) # XXX writing to disc directly would conserve memory
if not llvm_is_on_path():
py.test.skip("llvm not found") # XXX not good to call py.test.skip here
Modified: pypy/dist/pypy/translator/llvm2/module/extfunction.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/extfunction.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/extfunction.py Wed Aug 3 01:43:25 2005
@@ -1,35 +1,35 @@
-extdeclarations = """;gc-type dependent mallocs
-declare sbyte* %gc_malloc(uint)
-declare sbyte* %gc_malloc_atomic(uint)
-
-;rpython stuff
+extdeclarations = """;rpython stuff
%structtype.rpy_string = type {int, {int, [0 x sbyte]}}
+;gc-type dependent mallocs
+declare fastcc sbyte* %gc_malloc(uint)
+declare fastcc sbyte* %gc_malloc_atomic(uint)
+
;exception handling globals
%last_exception_type = global %structtype.object_vtable* null
%last_exception_value = global %structtype.object* null
"""
-gc_boehm = """declare sbyte* %GC_malloc(uint)
-declare sbyte* %GC_malloc_atomic(uint)
+gc_boehm = """declare ccc sbyte* %GC_malloc(uint)
+declare ccc sbyte* %GC_malloc_atomic(uint)
-sbyte* %gc_malloc(uint %n) {
- %ptr = call sbyte* %GC_malloc(uint %n)
+fastcc sbyte* %gc_malloc(uint %n) {
+ %ptr = call ccc sbyte* %GC_malloc(uint %n)
ret sbyte* %ptr
}
-sbyte* %gc_malloc_atomic(uint %n) {
- %ptr = call sbyte* %GC_malloc_atomic(uint %n)
+fastcc sbyte* %gc_malloc_atomic(uint %n) {
+ %ptr = call ccc sbyte* %GC_malloc_atomic(uint %n)
ret sbyte* %ptr
}
"""
-gc_disabled = """sbyte* %gc_malloc(uint %n) {
+gc_disabled = """fastcc sbyte* %gc_malloc(uint %n) {
%ptr = malloc sbyte, uint %n
ret sbyte* %ptr
}
-sbyte* %gc_malloc_atomic(uint %n) {
+fastcc sbyte* %gc_malloc_atomic(uint %n) {
%ptr = malloc sbyte, uint %n
ret sbyte* %ptr
}
Modified: pypy/dist/pypy/translator/llvm2/module/ll_math.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_math.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_math.py Wed Aug 3 01:43:25 2005
@@ -1,23 +1,23 @@
extdeclarations = """
;ll_math.py
-declare double %acos(double)
-declare double %asin(double)
-declare double %atan(double)
-declare double %ceil(double)
-declare double %cos(double)
-declare double %cosh(double)
-declare double %exp(double)
-declare double %fabs(double)
-declare double %floor(double)
-declare double %log(double)
-declare double %log10(double)
-declare double %sin(double)
-declare double %sinh(double)
-declare double %sqrt(double)
-declare double %tan(double)
-declare double %tanh(double)
-declare double %atan2(double,double)
-declare double %fmod(double,double)
+declare ccc double %acos(double)
+declare ccc double %asin(double)
+declare ccc double %atan(double)
+declare ccc double %ceil(double)
+declare ccc double %cos(double)
+declare ccc double %cosh(double)
+declare ccc double %exp(double)
+declare ccc double %fabs(double)
+declare ccc double %floor(double)
+declare ccc double %log(double)
+declare ccc double %log10(double)
+declare ccc double %sin(double)
+declare ccc double %sinh(double)
+declare ccc double %sqrt(double)
+declare ccc double %tan(double)
+declare ccc double %tanh(double)
+declare ccc double %atan2(double,double)
+declare ccc double %fmod(double,double)
"""
extfunctions = {}
@@ -30,8 +30,8 @@
]
simple_function_template = """
-double %%ll_math_%(function)s(%(params)s) {
- %%t = call double %%%(function)s(%(params)s)
+fastcc double %%ll_math_%(function)s(%(params)s) {
+ %%t = call ccc double %%%(function)s(%(params)s)
ret double %%t
}
Modified: pypy/dist/pypy/translator/llvm2/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_os.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_os.py Wed Aug 3 01:43:25 2005
@@ -1,73 +1,101 @@
extdeclarations = """
;ll_os.py
-declare int %dup(int)
-declare void %close(int)
-declare int %open(sbyte*, int, int)
-declare int %write(int, sbyte*, int)
-declare int %read(int, sbyte*, int)
-declare sbyte* %strncpy(sbyte*, sbyte*, int)
-declare int %isatty(int)
+declare ccc int %dup(int)
+declare ccc void %close(int)
+declare ccc int %open(sbyte*, int, int)
+declare ccc int %write(int, sbyte*, int)
+declare ccc int %read(int, sbyte*, int)
+declare ccc sbyte* %strncpy(sbyte*, sbyte*, int)
+declare ccc int %isatty(int)
+declare ccc int %fstat(int, int*)
"""
extfunctions = {}
extfunctions["%ll_os_dup"] = ((), """
-int %ll_os_dup(int %fd) {
- %ret = call int %dup(int %fd)
+fastcc int %ll_os_dup(int %fd) {
+ %ret = call ccc int %dup(int %fd)
ret int %ret
}
""")
extfunctions["%ll_os_close"] = ((), """
-void %ll_os_close(int %fd) {
- call void %close(int %fd)
+fastcc void %ll_os_close(int %fd) {
+ call ccc void %close(int %fd)
ret void
}
""")
extfunctions["%ll_os_open"] = (("%cast",), """
-int %ll_os_open(%structtype.rpy_string* %structstring, int %flag, int %mode) {
- %dest = call sbyte* %cast(%structtype.rpy_string* %structstring)
- %fd = call int %open(sbyte* %dest, int %flag, int %mode)
+fastcc int %ll_os_open(%structtype.rpy_string* %structstring, int %flag, int %mode) {
+ %dest = call fastcc sbyte* %cast(%structtype.rpy_string* %structstring)
+ %fd = call ccc int %open(sbyte* %dest, int %flag, int %mode)
ret int %fd
}
""")
extfunctions["%ll_os_write"] = (("%cast",), """
-int %ll_os_write(int %fd, %structtype.rpy_string* %structstring) {
+fastcc int %ll_os_write(int %fd, %structtype.rpy_string* %structstring) {
%reallengthptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 0
%reallength = load int* %reallengthptr
- %dest = call sbyte* %cast(%structtype.rpy_string* %structstring)
- %byteswritten = call int %write(int %fd, sbyte* %dest, int %reallength)
+ %dest = call fastcc sbyte* %cast(%structtype.rpy_string* %structstring)
+ %byteswritten = call ccc int %write(int %fd, sbyte* %dest, int %reallength)
ret int %byteswritten
}
""")
extfunctions["%ll_read_into"] = ((), """
-int %ll_read_into(int %fd, %structtype.rpy_string* %structstring) {
+fastcc int %ll_read_into(int %fd, %structtype.rpy_string* %structstring) {
%reallengthptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 0
%reallength = load int* %reallengthptr
%destptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 1
%dest = cast [0 x sbyte]* %destptr to sbyte*
- %bytesread = call int %read(int %fd, sbyte* %dest, int %reallength)
+ %bytesread = call ccc int %read(int %fd, sbyte* %dest, int %reallength)
ret int %bytesread
}
""")
extfunctions["%ll_os_isatty"] = ((), """
-bool %ll_os_isatty(int %fd) {
- %ret = call int %isatty(int %fd)
+fastcc bool %ll_os_isatty(int %fd) {
+ %ret = call ccc int %isatty(int %fd)
%ret.bool = cast int %ret to bool
ret bool %ret.bool
}
""")
+extfunctions["%ll_os_fstat"] = ((), """
+%structtype.tuple10* %ll_os_fstat(int %fd) {
+ %st = alloca int, uint 32
+ %error = call ccc int %fstat(int %fd, int* %st)
+ ;TODO XXX if error: raise exception
+ ;%ret = %ll_stat_result__Signed__Signed__Signed__Signed__Signed__Signed__Signed__Signed__Signed__Signed(
+ %ret = alloca %structtype.tuple10 ;ERROR
+ store int %s
+ ret %structtype.tuple10* %ret
+}
+
+""")
+#struct stat {
+# 0 : dev_t res2 : st_dev; /* device */
+# 1 : ino_t res1 : st_ino; /* inode */
+# 2 : mode_t res0 : st_mode; /* protection */
+# 3 : nlink_t res3 : st_nlink; /* number of hard links */
+# 4 : uid_t res4 : st_uid; /* user ID of owner */
+# 5 : gid_t res5 : st_gid; /* group ID of owner */
+# 6 : dev_t : st_rdev; /* device type (if inode device) */
+# 7 : off_t res6 : st_size; /* total size, in bytes */
+# 8 : blksize_t : st_blksize; /* blocksize for filesystem I/O */
+# 9 : blkcnt_t : st_blocks; /* number of blocks allocated */
+# 10 : time_t res7 : st_atime; /* time of last access */
+# 11 : time_t res8 : st_mtime; /* time of last modification */
+# 12 : time_t res9 : st_ctime; /* time of last status change */
+#};
Modified: pypy/dist/pypy/translator/llvm2/module/ll_time.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_time.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_time.py Wed Aug 3 01:43:25 2005
@@ -1,15 +1,15 @@
extdeclarations = '''
;ll_time.py
-declare int %time(int*) ;void* actually
-declare int %clock()
-declare void %sleep(int)
+declare ccc int %time(int*) ;void* actually
+declare ccc int %clock()
+declare ccc void %sleep(int)
'''
extfunctions = {}
extfunctions["%ll_time_time"] = ((), """
-double %ll_time_time() {
- %v0 = call int %time(int* null)
+fastcc double %ll_time_time() {
+ %v0 = call ccc int %time(int* null)
%v1 = cast int %v0 to double
ret double %v1
}
@@ -17,8 +17,8 @@
""")
extfunctions["%ll_time_clock"] = ((), """
-double %ll_time_clock() {
- %v0 = call int %clock()
+fastcc double %ll_time_clock() {
+ %v0 = call ccc int %clock()
%v1 = cast int %v0 to double
; XXX how to get at the proper division (or any other) constant per platform?
%v2 = div double %v1, 1000000.0 ;CLOCKS_PER_SEC accrdoing to single unix spec
@@ -28,9 +28,9 @@
""")
extfunctions["%ll_time_sleep"] = ((), """
-void %ll_time_sleep(double %f) {
+fastcc void %ll_time_sleep(double %f) {
%i = cast double %f to int
- call void %sleep(int %i)
+ call ccc void %sleep(int %i)
ret void
}
Modified: pypy/dist/pypy/translator/llvm2/module/support.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/support.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/support.py Wed Aug 3 01:43:25 2005
@@ -3,16 +3,16 @@
extfunctions = {}
extfunctions["%cast"] = ((), """
-sbyte* %cast(%structtype.rpy_string* %structstring) {
+fastcc sbyte* %cast(%structtype.rpy_string* %structstring) {
%reallengthptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 0
%reallength = load int* %reallengthptr
%length = add int %reallength, 1
%ulength = cast int %length to uint
- %dest = call sbyte* %gc_malloc_atomic(uint %ulength)
+ %dest = call fastcc sbyte* %gc_malloc_atomic(uint %ulength)
%source1ptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 1
%source1 = cast [0 x sbyte]* %source1ptr to sbyte*
- %dummy = call sbyte* %strncpy(sbyte* %dest, sbyte* %source1, int %reallength)
+ %dummy = call ccc sbyte* %strncpy(sbyte* %dest, sbyte* %source1, int %reallength)
%zeropos1 = cast sbyte* %dest to int
%zeropos2 = add int %zeropos1, %reallength
Modified: pypy/dist/pypy/translator/llvm2/pyxwrapper.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/pyxwrapper.py (original)
+++ pypy/dist/pypy/translator/llvm2/pyxwrapper.py Wed Aug 3 01:43:25 2005
@@ -16,7 +16,7 @@
funcgen.graph.returnblock.inputargs[0].concretetype]
inputargtypes = [PRIMITIVES_TO_C[arg.concretetype]
for arg in funcgen.graph.startblock.inputargs]
- result = "%s %s(%s)" % (returntype, funcgen.ref.lstrip("%"),
+ result = "%s __entrypoint__%s(%s)" % (returntype, funcgen.ref.lstrip("%"),
", ".join(inputargtypes))
return result
lines = []
@@ -24,14 +24,21 @@
inputargs = funcgen.db.repr_arg_multi(funcgen.graph.startblock.inputargs)
inputargs = [x.strip("%") for x in inputargs]
append("cdef extern " + c_declaration())
+ append("cdef extern int __entrypoint__raised_LLVMException()")
+ append("")
+ append("class LLVMException(Exception):")
+ append(" pass")
+ append("")
if use_boehm_gc:
append("cdef extern int GC_get_heap_size()")
append("")
append("def GC_get_heap_size_wrapper():")
append(" return GC_get_heap_size()")
- append("")
+ append("")
append("def %s_wrapper(%s):" % (funcgen.ref.strip("%"), ", ".join(inputargs)))
- append(" return %s(%s)" % (funcgen.ref.strip("%"), ", ".join(inputargs)))
+ append(" result = __entrypoint__%s(%s)" % (funcgen.ref.strip("%"), ", ".join(inputargs)))
+ append(" if __entrypoint__raised_LLVMException(): #not caught by the LLVM code itself")
+ append(" raise LLVMException")
+ append(" return result")
append("")
targetpath.write("\n".join(lines))
-
Modified: pypy/dist/pypy/translator/llvm2/test/test_exception.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_exception.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/test_exception.py Wed Aug 3 01:43:25 2005
@@ -12,7 +12,7 @@
def getitem(l, i): #LookupError, KeyError
if not isinstance(i, int):
- raise LookupError
+ raise TypeError
if i < 0:
i = len(l) - i
if i>= len(l):
@@ -103,7 +103,6 @@
# assert f(0) == fn(0)
def test_reraise1():
- py.test.skip("failing, uncaught exception causes exit!")
def fn(n):
lst = range(10)
try:
@@ -112,12 +111,12 @@
raise
return 4
f = compile_function(fn, [int])
- assert f(-1) == fn(-1)
+ py.test.raises(Exception, "f(-1)")
assert f( 0) == fn( 0)
- assert f(10) == fn(10)
+ py.test.raises(Exception, "f(10)")
def test_reraise2():
- py.test.skip("failing, uncaught exception causes exit!")
+ py.test.skip("PyPy interpreter not happy with this test")
def fn(n):
lst = range(10)
try:
@@ -126,9 +125,9 @@
raise e
return 4
f = compile_function(fn, [int])
- assert f(-1) == fn(-1)
+ py.test.raises(Exception, "f(-1)")
assert f( 0) == fn( 0)
- assert f(10) == fn(10)
+ py.test.raises(Exception, "f(10)")
def test_simple_exception():
def fn(n):
@@ -194,7 +193,7 @@
assert f(1) == fn(1)
assert f(2) == fn(2)
assert f(3) == fn(3)
- #py.test.raises(RuntimeError, "f(4)") #currently not raising a CPython exception
+ #py.test.raises(RuntimeError, "f(4)") #XXX would like to test: py.test.not_raises(....)
assert f(5) == fn(5)
assert f(6) == fn(6)
assert f(13) == fn(13)
Modified: pypy/dist/pypy/translator/llvm2/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_extfunc.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/test_extfunc.py Wed Aug 3 01:43:25 2005
@@ -97,28 +97,26 @@
def test_os_stat():
py.test.skip("ll_os_stat not implemented")
filename = str(py.magic.autopath())
- def call_stat():
+ def call_stat(n):
st = os.stat(filename)
- return st
- f = compile_function(call_stat, [])
- result = f()
- assert result[0] == os.stat(filename)[0]
- assert result[1] == os.stat(filename)[1]
- assert result[2] == os.stat(filename)[2]
+ return st[n]
+ f = compile_function(call_stat, [int])
+ assert f(0) == os.stat(filename)[0]
+ assert f(1) == os.stat(filename)[1]
+ assert f(2) == os.stat(filename)[2]
def test_os_fstat():
py.test.skip("ll_os_fstat not implemented")
filename = str(py.magic.autopath())
- def call_fstat():
+ def call_fstat(n):
fd = os.open(filename, os.O_RDONLY, 0777)
st = os.fstat(fd)
os.close(fd)
- return st
- f = compile_function(call_fstat, [])
- result = f()
- assert result[0] == os.stat(filename)[0]
- assert result[1] == os.stat(filename)[1]
- assert result[2] == os.stat(filename)[2]
+ return st[0] #XXX want to use 0 here!
+ f = compile_function(call_fstat, [int])
+ assert f(0) == os.stat(filename)[0]
+ assert f(1) == os.stat(filename)[1]
+ assert f(2) == os.stat(filename)[2]
def test_getcwd():
py.test.skip("ll_os_getcwd not implemented")
More information about the Pypy-commit
mailing list