Commit a2905ea4 authored by John Zhang's avatar John Zhang

fix: the definition of some opaque types can not be found, thus they are...

fix: the definition of some opaque types can not be found, thus they are translated to uptr<int<64>> by capturing the CompilationError
parent 7b483027
......@@ -8,6 +8,7 @@ from rpython.rlib.objectmodel import CDefinedIntSymbolic
from rpython.rlib import rarithmetic
from rpython.flowspace.model import Variable, Constant, SpaceOperation, Link
from rpython.translator.c.node import needs_gcheader
from rpython.translator.platform import CompilationError
from random import randint
import weakref
......@@ -282,7 +283,7 @@ class LL2MuMapper:
cls = mutype.MuUPtr
MuT = self.map_type(T)
except NotImplementedError:
except (NotImplementedError, CompilationError):
MuT = mutype.MU_INT64 # default to ref/uptr<int<64>>
return cls(MuT)
......@@ -44,11 +44,24 @@ def test_map_type_opqptr():
LL_META_CSTR = lltype.Ptr(lltype.GcOpaqueType("MuStr", hints={'mu_render_ptr_as': mutype.META_CSTR}))
assert ll2mu.map_type(LL_META_CSTR) == mutype.META_CSTR
def arrayofbytes(n):
return mutype.MuArray(mutype.MU_INT8, n)
# other opaque types
# try translate the underlying opaque type first
from rpython.rlib._rsocket_rffi import fd_set
assert ll2mu.map_type(fd_set) == mutype.MuUPtr(mutype.MuArray(mutype.MU_INT8, fd_set.TO.hints['getsize']()))
assert ll2mu.map_type(fd_set) == mutype.MuUPtr(arrayofbytes(fd_set.TO.hints['getsize']()))
# on Linux the exact definition of DIR struct cannot be found,
# thus there will be problem when querying the size of it
# thus on Linux DIRP will be translated to uptr<int<64>>
from rpython.rlib import rposix
DIRP = rposix.DIRP
import sys
if sys.platform.startswith('linux'):
assert ll2mu.map_type(rposix.DIRP) == mutype.MuUPtr(mutype.MU_INT64)
elif sys.platform == 'darwin':
assert ll2mu.map_type(rposix.DIRP) == mutype.MuUPtr(arrayofbytes(DIRP.TO.hints['getsize']()))
def test_map_type_hybrid():
ll2mu = LL2MuMapper()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment