WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 866da014 authored by John Zhang's avatar John Zhang
Browse files

move get_typedescr_str to module scope, not as a method

parent 02d860ca
......@@ -296,32 +296,6 @@ class LL2MuMapper:
"""
return mutype.MuStruct('WeakRef', ('wref', mutype.MU_WEAKREF_VOID))
def get_typedescr_str(self, MuT): # JIT Mu back-end support
descr_dict = {
mutype.MuRef: 'r',
mutype.MuUPtr: 'p',
mutype.MuFuncRef: 'r', # assuming function ref/uptr has same size as ref/uptr
mutype.MuUFuncPtr: 'p',
mutype.MU_INT8: 'b',
mutype.MU_INT16: 's',
mutype.MU_INT32: 'i',
mutype.MU_INT64: 'l',
mutype.MU_FLOAT: 'f',
mutype.MU_DOUBLE: 'd'
}
if MuT.__class__ in descr_dict:
return descr_dict[MuT.__class__]
if MuT in descr_dict:
return descr_dict[MuT]
if isinstance(MuT, mutype.MuStruct):
return '(%s)' % ''.join(map(self.get_typedescr_str, [getattr(MuT, fld) for fld in MuT._names]))
if isinstance(MuT, mutype.MuHybrid):
fix = ''.join(map(self.get_typedescr_str, [getattr(MuT, fld) for fld in MuT._names[:-1]]))
var = self.get_typedescr_str(MuT._vartype.OF)
return '{%(fix)s|%(var)s}' % locals()
if isinstance(MuT, mutype.MuArray):
return '[%d|%s]' % (MuT.length, self.get_typedescr_str(MuT.OF))
# -----------------------------------------------------------------------------
def map_value(self, llv, **kwargs):
cache, v = (self._ptr_cache, llv._obj) \
......@@ -2011,3 +1985,30 @@ def ll2mu_value(llv):
muv = ll2mu.map_value(llv)
ll2mu.resolve_ptr_values()
return muv
def get_typedescr_str(MuT): # JIT Mu back-end support
descr_dict = {
mutype.MuRef: 'r',
mutype.MuUPtr: 'p',
mutype.MuFuncRef: 'r', # assuming function ref/uptr has same size as ref/uptr
mutype.MuUFuncPtr: 'p',
mutype.MU_INT8: 'b',
mutype.MU_INT16: 's',
mutype.MU_INT32: 'i',
mutype.MU_INT64: 'l',
mutype.MU_FLOAT: 'f',
mutype.MU_DOUBLE: 'd'
}
if MuT.__class__ in descr_dict:
return descr_dict[MuT.__class__]
if MuT in descr_dict:
return descr_dict[MuT]
if isinstance(MuT, mutype.MuStruct):
return '(%s)' % ''.join(map(get_typedescr_str, [getattr(MuT, fld) for fld in MuT._names]))
if isinstance(MuT, mutype.MuHybrid):
fix = ''.join(map(get_typedescr_str, [getattr(MuT, fld) for fld in MuT._names[:-1]]))
var = get_typedescr_str(MuT._vartype.OF)
return '{%(fix)s|%(var)s}' % locals()
if isinstance(MuT, mutype.MuArray):
return '[%d|%s]' % (MuT.length, get_typedescr_str(MuT.OF))
\ No newline at end of file
......@@ -675,16 +675,15 @@ def test_getsubstruct():
def test_typedescr_str():
ll2mu = LL2MuMapper()
S = mutype.MuStruct('S', ('x', mutype.MU_INT64), ('y', mutype.MU_FLOAT), ('z', mutype.MuRef(mutype.MU_INT64)))
assert ll2mu.get_typedescr_str(S) == '(lfr)'
assert get_typedescr_str(S) == '(lfr)'
from rpython.rtyper.lltypesystem.rstr import STR
H = ll2mu.map_type(STR)
assert ll2mu.get_typedescr_str(H) == '{lll|b}'
H = ll2mu_type(STR)
assert get_typedescr_str(H) == '{lll|b}'
A = mutype.MuArray(S, 10)
assert ll2mu.get_typedescr_str(A) == '[10|(lfr)]'
assert get_typedescr_str(A) == '[10|(lfr)]'
def test_cast_pointer_pin():
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