<s> import weakref <EOL> from pypy . rpython . lltypesystem import lltype , llmemory , rffi <EOL> class GroupType ( lltype . ContainerType ) : <EOL> """<STR_LIT>""" <EOL> _gckind = '<STR_LIT>' <EOL> Group = GroupType ( ) <EOL> class group ( lltype . _container ) : <EOL> _TYPE = Group <EOL> outdated = None <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> self . members = [ ] <EOL> def add_member ( self , structptr ) : <EOL> TYPE = lltype . typeOf ( structptr ) <EOL> assert isinstance ( TYPE . TO , lltype . Struct ) <EOL> assert TYPE . TO . _gckind == '<STR_LIT>' <EOL> struct = structptr . _as_obj ( ) <EOL> prevgroup = _membership . get ( struct ) <EOL> if prevgroup is not None : <EOL> prevgroup . outdated = ( <EOL> "<STR_LIT>" % ( struct , ) ) <EOL> assert struct . _parentstructure ( ) is None <EOL> index = len ( self . members ) <EOL> self . members . append ( struct ) <EOL> _membership [ struct ] = self <EOL> return GroupMemberOffset ( self , index ) <EOL> def member_of_group ( structptr ) : <EOL> return _membership . get ( structptr . _as_obj ( ) , None ) <EOL> _membership = weakref . WeakValueDictionary ( ) <EOL> class GroupMemberOffset ( llmemory . Symbolic ) : <EOL> """<STR_LIT>""" <EOL> def annotation ( self ) : <EOL> from pypy . annotation import model <EOL> return model . SomeInteger ( knowntype = rffi . r_ushort ) <EOL> def lltype ( self ) : <EOL> return rffi . USHORT <EOL> def __init__ ( self , grp , memberindex ) : <EOL> assert lltype . typeOf ( grp ) == Group <EOL> self . grpptr = grp . _as_ptr ( ) <EOL> self . index = memberindex <EOL> self . member = grp . members [ memberindex ] . _as_ptr ( ) <EOL> def _get_group_member ( self , grpptr ) : <EOL> assert grpptr == self . grpptr , "<STR_LIT>" <EOL> return self . member <EOL> def _get_next_group_member ( self , grpptr , skipoffset ) : <EOL> assert grpptr == self . grpptr , "<STR_LIT>" <EOL> assert isinstance ( skipoffset , llmemory . ItemOffset ) <EOL> assert skipoffset . TYPE == lltype . typeOf ( self . member ) . TO <EOL> assert skipoffset . repeat == <NUM_LIT:1> <EOL> return self . grpptr . _as_obj ( ) . members [ self . index + <NUM_LIT:1> ] . _as_ptr ( ) <EOL> class CombinedSymbolic ( llmemory . Symbolic ) : <EOL> """<STR_LIT>""" <EOL> def annotation ( self ) : <EOL> from pypy . annotation import model <EOL> return model . SomeInteger ( ) <EOL> def lltype ( self ) : <EOL> return lltype . Signed <EOL> def __init__ ( self , lowpart , rest ) : <EOL> assert ( rest & <NUM_LIT> ) == <NUM_LIT:0> <EOL> self . lowpart = lowpart <EOL> self . rest = rest <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . lowpart , self . rest ) <EOL> def __and__ ( self , other ) : <EOL> if ( other & <NUM_LIT> ) == <NUM_LIT:0> : <EOL> return self . rest & other <EOL> if ( other & <NUM_LIT> ) == <NUM_LIT> : <EOL> return CombinedSymbolic ( self . lowpart , self . rest & other ) <EOL> raise Exception ( "<STR_LIT>" % other ) <EOL> def __or__ ( self , other ) : <EOL> assert ( other & <NUM_LIT> ) == <NUM_LIT:0> <EOL> return CombinedSymbolic ( self . lowpart , self . rest | other ) <EOL> def __add__ ( self , other ) : <EOL> assert ( other & <NUM_LIT> ) == <NUM_LIT:0> <EOL> return CombinedSymbolic ( self . lowpart , self . rest + other ) <EOL> def __sub__ ( self , other ) : <EOL> assert ( other & <NUM_LIT> ) == <NUM_LIT:0> <EOL> return CombinedSymbolic ( self . lowpart , self . rest - other ) <EOL> def __eq__ ( self , other ) : <EOL> if ( isinstance ( other , CombinedSymbolic ) and <EOL> self . lowpart is other . lowpart ) : <EOL> return self . rest == other . rest <EOL> else : <EOL> return NotImplemented <EOL> def __ne__ ( self , other ) : <EOL> if ( isinstance ( other , CombinedSymbolic ) and <EOL> self . lowpart is other . lowpart ) : <EOL> return self . rest != other . rest <EOL> else : <EOL> return NotImplemented </s>
