<s> from pypy . tool . pairtype import pairtype <EOL> from pypy . annotation import model as annmodel <EOL> from pypy . objspace . flow . model import Constant <EOL> from pypy . rpython . lltypesystem import lltype , rclass , llmemory <EOL> from pypy . rpython import rint , raddress <EOL> from pypy . rlib import rarithmetic , objectmodel <EOL> from pypy . rpython . error import TyperError <EOL> from pypy . rpython . rmodel import Repr , IntegerRepr , inputconst <EOL> from pypy . rpython . rrange import rtype_builtin_range , rtype_builtin_xrange <EOL> from pypy . rpython import rstr <EOL> from pypy . rpython import rptr <EOL> from pypy . rpython . robject import pyobj_repr <EOL> from pypy . tool import sourcetools <EOL> from pypy . rpython import extregistry <EOL> class __extend__ ( annmodel . SomeBuiltin ) : <EOL> def rtyper_makerepr ( self , rtyper ) : <EOL> if self . s_self is None : <EOL> if not self . is_constant ( ) : <EOL> raise TyperError ( "<STR_LIT>" ) <EOL> return BuiltinFunctionRepr ( self . const ) <EOL> else : <EOL> assert self . methodname is not None <EOL> result = BuiltinMethodRepr ( rtyper , self . s_self , self . methodname ) <EOL> if result . self_repr == pyobj_repr : <EOL> return pyobj_repr <EOL> else : <EOL> return result <EOL> def rtyper_makekey ( self ) : <EOL> if self . s_self is None : <EOL> const = getattr ( self , '<STR_LIT>' , None ) <EOL> if extregistry . is_registered ( const ) : <EOL> const = extregistry . lookup ( const ) <EOL> return self . __class__ , const <EOL> else : <EOL> return ( self . __class__ , self . methodname , id ( self . s_self ) ) <EOL> def call_args_expand ( hop , takes_kwds = True ) : <EOL> hop = hop . copy ( ) <EOL> from pypy . interpreter . argument import ArgumentsForTranslation <EOL> arguments = ArgumentsForTranslation . fromshape ( <EOL> None , hop . args_s [ <NUM_LIT:1> ] . const , <EOL> range ( hop . nb_args - <NUM_LIT:2> ) ) <EOL> if arguments . w_starstararg is not None : <EOL> raise TyperError ( "<STR_LIT>" ) <EOL> if arguments . w_stararg is not None : <EOL> from pypy . rpython . rtuple import AbstractTupleRepr <EOL> if arguments . w_stararg != hop . nb_args - <NUM_LIT:3> : <EOL> raise TyperError ( "<STR_LIT>" ) <EOL> hop . nb_args -= <NUM_LIT:1> <EOL> v_tuple = hop . args_v . pop ( ) <EOL> s_tuple = hop . args_s . pop ( ) <EOL> r_tuple = hop . args_r . pop ( ) <EOL> if not isinstance ( r_tuple , AbstractTupleRepr ) : <EOL> raise TyperError ( "<STR_LIT>" ) <EOL> for i in range ( len ( r_tuple . items_r ) ) : <EOL> v_item = r_tuple . getitem_internal ( hop . llops , v_tuple , i ) <EOL> hop . nb_args += <NUM_LIT:1> <EOL> hop . args_v . append ( v_item ) <EOL> hop . args_s . append ( s_tuple . items [ i ] ) <EOL> hop . args_r . append ( r_tuple . items_r [ i ] ) <EOL> keywords = arguments . keywords <EOL> if not takes_kwds and keywords : <EOL> raise TyperError ( "<STR_LIT>" ) <EOL> kwds_i = { } <EOL> for i , key in enumerate ( keywords ) : <EOL> index = arguments . keywords_w [ i ] <EOL> kwds_i [ '<STR_LIT>' + key ] = index <EOL> return hop , kwds_i <EOL> class BuiltinFunctionRepr ( Repr ) : <EOL> lowleveltype = lltype . Void <EOL> def __init__ ( self , builtinfunc ) : <EOL> self . builtinfunc = builtinfunc <EOL> def findbltintyper ( self , rtyper ) : <EOL> "<STR_LIT>" <EOL> try : <EOL> return BUILTIN_TYPER [ self . builtinfunc ] <EOL> except ( KeyError , TypeError ) : <EOL> pass <EOL> try : <EOL> return rtyper . type_system . rbuiltin . BUILTIN_TYPER [ self . builtinfunc ] <EOL> except ( KeyError , TypeError ) : <EOL> pass <EOL> if extregistry . is_registered ( self . builtinfunc ) : <EOL> entry = extregistry . lookup ( self . builtinfunc ) <EOL> return entry . specialize_call <EOL> raise TyperError ( "<STR_LIT>" % ( <EOL> self . builtinfunc , ) ) <EOL> def rtype_simple_call ( self , hop ) : <EOL> bltintyper = self . findbltintyper ( hop . rtyper ) <EOL> hop2 = hop . copy ( ) <EOL> hop2 . r_s_popfirstarg ( ) <EOL> return bltintyper ( hop2 ) <EOL> def rtype_call_args ( self , hop ) : <EOL> hop , kwds_i = call_args_expand ( hop ) <EOL> bltintyper = self . findbltintyper ( hop . rtyper ) <EOL> hop2 = hop . copy ( ) <EOL> hop2 . r_s_popfirstarg ( ) <EOL> hop2 . r_s_popfirstarg ( ) <EOL> return bltintyper ( hop2 , ** kwds_i ) <EOL> class BuiltinMethodRepr ( Repr ) : <EOL> def __init__ ( self , rtyper , s_self , methodname ) : <EOL> self . s_self = s_self <EOL> self . self_repr = rtyper . getrepr ( s_self ) <EOL> self . methodname = methodname <EOL> self . lowleveltype = self . self_repr . lowleveltype <EOL> def convert_const ( self , obj ) : <EOL> return self . self_repr . convert_const ( get_builtin_method_self ( obj ) ) <EOL> def rtype_simple_call ( self , hop ) : <EOL> name = '<STR_LIT>' + self . methodname <EOL> try : <EOL> bltintyper = getattr ( self . self_repr , name ) <EOL> except AttributeError : <EOL> raise TyperError ( "<STR_LIT>" % ( <EOL> self . self_repr . __class__ . __name__ , name ) ) <EOL> hop2 = hop . copy ( ) <EOL> assert hop2 . args_r [ <NUM_LIT:0> ] is self <EOL> if isinstance ( hop2 . args_v [ <NUM_LIT:0> ] , Constant ) : <EOL> c = hop2 . args_v [ <NUM_LIT:0> ] . value <EOL> c = get_builtin_method_self ( c ) <EOL> hop2 . args_v [ <NUM_LIT:0> ] = Constant ( c ) <EOL> hop2 . args_s [ <NUM_LIT:0> ] = self . s_self <EOL> hop2 . args_r [ <NUM_LIT:0> ] = self . self_repr <EOL> return bltintyper ( hop2 ) <EOL> class __extend__ ( pairtype ( BuiltinMethodRepr , BuiltinMethodRepr ) ) : <EOL> def convert_from_to ( ( r_from , r_to ) , v , llops ) : <EOL> if r_from . methodname != r_to . methodname : <EOL> return NotImplemented <EOL> return llops . convertvar ( v , r_from . self_repr , r_to . self_repr ) <EOL> def parse_kwds ( hop , * argspec_i_r ) : <EOL> lst = [ i for ( i , r ) in argspec_i_r if i is not None ] <EOL> lst . sort ( ) <EOL> if lst != range ( hop . nb_args - len ( lst ) , hop . nb_args ) : <EOL> raise TyperError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> result = [ ] <EOL> for i , r in argspec_i_r : <EOL> if i is not None : <EOL> if r is None : <EOL> r = hop . args_r [ i ] <EOL> result . append ( hop . inputarg ( r , arg = i ) ) <EOL> else : <EOL> result . append ( None ) <EOL> hop . nb_args -= len ( lst ) <EOL> return result <EOL> def get_builtin_method_self ( x ) : <EOL> try : <EOL> return x . __self__ <EOL> except AttributeError : <EOL> return x . im_self <EOL> def rtype_builtin_bool ( hop ) : <EOL> assert hop . nb_args == <NUM_LIT:1> <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_is_true ( hop ) <EOL> def rtype_builtin_int ( hop ) : <EOL> if isinstance ( hop . args_s [ <NUM_LIT:0> ] , annmodel . SomeString ) : <EOL> assert <NUM_LIT:1> <= hop . nb_args <= <NUM_LIT:2> <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_int ( hop ) <EOL> assert hop . nb_args == <NUM_LIT:1> <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_int ( hop ) <EOL> def rtype_builtin_float ( hop ) : <EOL> assert hop . nb_args == <NUM_LIT:1> <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_float ( hop ) <EOL> def rtype_builtin_chr ( hop ) : <EOL> assert hop . nb_args == <NUM_LIT:1> <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_chr ( hop ) <EOL> def rtype_builtin_unichr ( hop ) : <EOL> assert hop . nb_args == <NUM_LIT:1> <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_unichr ( hop ) <EOL> def rtype_builtin_unicode ( hop ) : <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_unicode ( hop ) <EOL> def rtype_builtin_list ( hop ) : <EOL> return hop . args_r [ <NUM_LIT:0> ] . rtype_bltn_list ( hop ) <EOL> def rtype_intmask ( hop ) : <EOL> hop . exception_cannot_occur ( ) <EOL> vlist = hop . inputargs ( lltype . Signed ) <EOL> return vlist [ <NUM_LIT:0> ] <EOL> def rtype_builtin_min ( hop ) : <EOL> v1 , v2 = hop . inputargs ( hop . r_result , hop . r_result ) <EOL> return hop . gendirectcall ( ll_min , v1 , v2 ) <EOL> def ll_min ( i1 , i2 ) : <EOL> if i1 < i2 : <EOL> return i1 <EOL> return i2 <EOL> def rtype_builtin_max ( hop ) : <EOL> v1 , v2 = hop . inputargs ( hop . r_result , hop . r_result ) <EOL> return hop . gendirectcall ( ll_max , v1 , v2 ) <EOL> def ll_max ( i1 , i2 ) : <EOL> if i1 > i2 : <EOL> return i1 <EOL> return i2 <EOL> def rtype_Exception__init__ ( hop ) : <EOL> pass <EOL> def rtype_object__init__ ( hop ) : <EOL> pass <EOL> def rtype_OSError__init__ ( hop ) : <EOL> if hop . nb_args == <NUM_LIT:2> : <EOL> raise TyperError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if hop . nb_args >= <NUM_LIT:3> : <EOL> v_self = hop . args_v [ <NUM_LIT:0> ] <EOL> r_self = hop . args_r [ <NUM_LIT:0> ] <EOL> v_errno = hop . inputarg ( lltype . Signed , arg = <NUM_LIT:1> ) <EOL> r_self . setfield ( v_self , '<STR_LIT>' , v_errno , hop . llops ) <EOL> def rtype_WindowsError__init__ ( hop ) : <EOL> if hop . nb_args == <NUM_LIT:2> : <EOL> raise TyperError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if hop . nb_args >= <NUM_LIT:3> : <EOL> v_self = hop . args_v [ <NUM_LIT:0> ] <EOL> r_self = hop . args_r [ <NUM_LIT:0> ] <EOL> v_error = hop . inputarg ( lltype . Signed , arg = <NUM_LIT:1> ) <EOL> r_self . setfield ( v_self , '<STR_LIT>' , v_error , hop . llops ) <EOL> def rtype_we_are_translated ( hop ) : <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . inputconst ( lltype . Bool , True ) <EOL> def rtype_hlinvoke ( hop ) : <EOL> _ , s_repr = hop . r_s_popfirstarg ( ) <EOL> r_callable = s_repr . const <EOL> r_func , nimplicitarg = r_callable . get_r_implfunc ( ) <EOL> s_callable = r_callable . get_s_callable ( ) <EOL> nbargs = len ( hop . args_s ) - <NUM_LIT:1> + nimplicitarg <EOL> s_sigs = r_func . get_s_signatures ( ( nbargs , ( ) , False , False ) ) <EOL> if len ( s_sigs ) != <NUM_LIT:1> : <EOL> raise TyperError ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( r_callable , <EOL> s_sigs ) ) <EOL> args_s , s_ret = s_sigs [ <NUM_LIT:0> ] <EOL> rinputs = [ hop . rtyper . getrepr ( s_obj ) for s_obj in args_s ] <EOL> rresult = hop . rtyper . getrepr ( s_ret ) <EOL> args_s = args_s [ nimplicitarg : ] <EOL> rinputs = rinputs [ nimplicitarg : ] <EOL> new_args_r = [ r_callable ] + rinputs <EOL> for i in range ( len ( new_args_r ) ) : <EOL> assert hop . args_r [ i ] . lowleveltype == new_args_r [ i ] . lowleveltype <EOL> hop . args_r = new_args_r <EOL> hop . args_s = [ s_callable ] + args_s <EOL> hop . s_result = s_ret <EOL> assert hop . r_result . lowleveltype == rresult . lowleveltype <EOL> hop . r_result = rresult <EOL> return hop . dispatch ( ) <EOL> import __builtin__ , exceptions <EOL> BUILTIN_TYPER = { } <EOL> for name , value in globals ( ) . items ( ) : <EOL> if name . startswith ( '<STR_LIT>' ) : <EOL> original = getattr ( __builtin__ , name [ <NUM_LIT> : ] ) <EOL> BUILTIN_TYPER [ original ] = value <EOL> BUILTIN_TYPER [ getattr ( OSError . __init__ , '<STR_LIT>' , OSError . __init__ ) ] = ( <EOL> rtype_OSError__init__ ) <EOL> try : <EOL> WindowsError <EOL> except NameError : <EOL> pass <EOL> else : <EOL> BUILTIN_TYPER [ <EOL> getattr ( WindowsError . __init__ , '<STR_LIT>' , WindowsError . __init__ ) ] = ( <EOL> rtype_WindowsError__init__ ) <EOL> BUILTIN_TYPER [ object . __init__ ] = rtype_object__init__ <EOL> def rtype_malloc ( hop , i_flavor = None , i_zero = None ) : <EOL> assert hop . args_s [ <NUM_LIT:0> ] . is_constant ( ) <EOL> vlist = [ hop . inputarg ( lltype . Void , arg = <NUM_LIT:0> ) ] <EOL> opname = '<STR_LIT>' <EOL> v_flavor , v_zero = parse_kwds ( hop , ( i_flavor , lltype . Void ) , ( i_zero , None ) ) <EOL> flags = { '<STR_LIT>' : '<STR_LIT>' } <EOL> if v_flavor is not None : <EOL> flags [ '<STR_LIT>' ] = v_flavor . value <EOL> if i_zero is not None : <EOL> flags [ '<STR_LIT>' ] = v_zero . value <EOL> vlist . append ( hop . inputconst ( lltype . Void , flags ) ) <EOL> if hop . nb_args == <NUM_LIT:2> : <EOL> vlist . append ( hop . inputarg ( lltype . Signed , arg = <NUM_LIT:1> ) ) <EOL> opname += '<STR_LIT>' <EOL> hop . has_implicit_exception ( MemoryError ) <EOL> hop . exception_is_here ( ) <EOL> return hop . genop ( opname , vlist , resulttype = hop . r_result . lowleveltype ) <EOL> def rtype_free ( hop , i_flavor ) : <EOL> assert i_flavor == <NUM_LIT:1> <EOL> hop . exception_cannot_occur ( ) <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] , lltype . Void ) <EOL> hop . genop ( '<STR_LIT>' , vlist ) <EOL> def rtype_const_result ( hop ) : <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . inputconst ( hop . r_result . lowleveltype , hop . s_result . const ) <EOL> def rtype_cast_pointer ( hop ) : <EOL> assert hop . args_s [ <NUM_LIT:0> ] . is_constant ( ) <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:1> ] , rptr . PtrRepr ) <EOL> v_type , v_input = hop . inputargs ( lltype . Void , hop . args_r [ <NUM_LIT:1> ] ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ v_input ] , <EOL> resulttype = hop . r_result . lowleveltype ) <EOL> def rtype_cast_opaque_ptr ( hop ) : <EOL> assert hop . args_s [ <NUM_LIT:0> ] . is_constant ( ) <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:1> ] , rptr . PtrRepr ) <EOL> v_type , v_input = hop . inputargs ( lltype . Void , hop . args_r [ <NUM_LIT:1> ] ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ v_input ] , <EOL> resulttype = hop . r_result . lowleveltype ) <EOL> def rtype_direct_fieldptr ( hop ) : <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:0> ] , rptr . PtrRepr ) <EOL> assert hop . args_s [ <NUM_LIT:1> ] . is_constant ( ) <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] , lltype . Void ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , vlist , <EOL> resulttype = hop . r_result . lowleveltype ) <EOL> def rtype_direct_arrayitems ( hop ) : <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:0> ] , rptr . PtrRepr ) <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , vlist , <EOL> resulttype = hop . r_result . lowleveltype ) <EOL> def rtype_direct_ptradd ( hop ) : <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:0> ] , rptr . PtrRepr ) <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] , lltype . Signed ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , vlist , <EOL> resulttype = hop . r_result . lowleveltype ) <EOL> def rtype_cast_primitive ( hop ) : <EOL> assert hop . args_s [ <NUM_LIT:0> ] . is_constant ( ) <EOL> TGT = hop . args_s [ <NUM_LIT:0> ] . const <EOL> v_type , v_value = hop . inputargs ( lltype . Void , hop . args_r [ <NUM_LIT:1> ] ) <EOL> return gen_cast ( hop . llops , TGT , v_value ) <EOL> _cast_to_Signed = { <EOL> lltype . Signed : None , <EOL> lltype . Bool : '<STR_LIT>' , <EOL> lltype . Char : '<STR_LIT>' , <EOL> lltype . UniChar : '<STR_LIT>' , <EOL> lltype . Float : '<STR_LIT>' , <EOL> lltype . Unsigned : '<STR_LIT>' , <EOL> lltype . SignedLongLong : '<STR_LIT>' , <EOL> } <EOL> _cast_from_Signed = { <EOL> lltype . Signed : None , <EOL> lltype . Bool : '<STR_LIT>' , <EOL> lltype . Char : '<STR_LIT>' , <EOL> lltype . UniChar : '<STR_LIT>' , <EOL> lltype . Float : '<STR_LIT>' , <EOL> lltype . Unsigned : '<STR_LIT>' , <EOL> lltype . SignedLongLong : '<STR_LIT>' , <EOL> } <EOL> def gen_cast ( llops , TGT , v_value ) : <EOL> ORIG = v_value . concretetype <EOL> if ORIG == TGT : <EOL> return v_value <EOL> if ( isinstance ( TGT , lltype . Primitive ) and <EOL> isinstance ( ORIG , lltype . Primitive ) ) : <EOL> if ORIG in _cast_to_Signed and TGT in _cast_from_Signed : <EOL> op = _cast_to_Signed [ ORIG ] <EOL> if op : <EOL> v_value = llops . genop ( op , [ v_value ] , resulttype = lltype . Signed ) <EOL> op = _cast_from_Signed [ TGT ] <EOL> if op : <EOL> v_value = llops . genop ( op , [ v_value ] , resulttype = TGT ) <EOL> return v_value <EOL> else : <EOL> return llops . genop ( '<STR_LIT>' , [ v_value ] , resulttype = TGT ) <EOL> elif isinstance ( TGT , lltype . Ptr ) : <EOL> if isinstance ( ORIG , lltype . Ptr ) : <EOL> if ( isinstance ( TGT . TO , lltype . OpaqueType ) or <EOL> isinstance ( ORIG . TO , lltype . OpaqueType ) ) : <EOL> return llops . genop ( '<STR_LIT>' , [ v_value ] , <EOL> resulttype = TGT ) <EOL> else : <EOL> return llops . genop ( '<STR_LIT>' , [ v_value ] , resulttype = TGT ) <EOL> elif ORIG == llmemory . Address : <EOL> return llops . genop ( '<STR_LIT>' , [ v_value ] , resulttype = TGT ) <EOL> elif isinstance ( ORIG , lltype . Primitive ) : <EOL> v_value = gen_cast ( llops , lltype . Signed , v_value ) <EOL> return llops . genop ( '<STR_LIT>' , [ v_value ] , resulttype = TGT ) <EOL> elif TGT == llmemory . Address and isinstance ( ORIG , lltype . Ptr ) : <EOL> return llops . genop ( '<STR_LIT>' , [ v_value ] , resulttype = TGT ) <EOL> elif isinstance ( TGT , lltype . Primitive ) : <EOL> if isinstance ( ORIG , lltype . Ptr ) : <EOL> v_value = llops . genop ( '<STR_LIT>' , [ v_value ] , <EOL> resulttype = lltype . Signed ) <EOL> elif ORIG == llmemory . Address : <EOL> v_value = llops . genop ( '<STR_LIT>' , [ v_value ] , <EOL> resulttype = lltype . Signed ) <EOL> else : <EOL> raise TypeError ( "<STR_LIT>" % ( ORIG , <EOL> TGT ) ) <EOL> return gen_cast ( llops , TGT , v_value ) <EOL> raise TypeError ( "<STR_LIT>" % ( ORIG , TGT ) ) <EOL> def rtype_cast_ptr_to_int ( hop ) : <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:0> ] , rptr . PtrRepr ) <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , vlist , <EOL> resulttype = lltype . Signed ) <EOL> def rtype_cast_int_to_ptr ( hop ) : <EOL> assert hop . args_s [ <NUM_LIT:0> ] . is_constant ( ) <EOL> v_type , v_input = hop . inputargs ( lltype . Void , lltype . Signed ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ v_input ] , <EOL> resulttype = hop . r_result . lowleveltype ) <EOL> def rtype_identity_hash ( hop ) : <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] ) <EOL> return hop . genop ( '<STR_LIT>' , vlist , resulttype = lltype . Signed ) <EOL> def rtype_runtime_type_info ( hop ) : <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:0> ] , rptr . PtrRepr ) <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] ) <EOL> return hop . genop ( '<STR_LIT>' , vlist , <EOL> resulttype = hop . r_result . lowleveltype ) <EOL> BUILTIN_TYPER [ lltype . malloc ] = rtype_malloc <EOL> BUILTIN_TYPER [ lltype . free ] = rtype_free <EOL> BUILTIN_TYPER [ lltype . cast_primitive ] = rtype_cast_primitive <EOL> BUILTIN_TYPER [ lltype . cast_pointer ] = rtype_cast_pointer <EOL> BUILTIN_TYPER [ lltype . cast_opaque_ptr ] = rtype_cast_opaque_ptr <EOL> BUILTIN_TYPER [ lltype . direct_fieldptr ] = rtype_direct_fieldptr <EOL> BUILTIN_TYPER [ lltype . direct_arrayitems ] = rtype_direct_arrayitems <EOL> BUILTIN_TYPER [ lltype . direct_ptradd ] = rtype_direct_ptradd <EOL> BUILTIN_TYPER [ lltype . cast_ptr_to_int ] = rtype_cast_ptr_to_int <EOL> BUILTIN_TYPER [ lltype . cast_int_to_ptr ] = rtype_cast_int_to_ptr <EOL> BUILTIN_TYPER [ lltype . typeOf ] = rtype_const_result <EOL> BUILTIN_TYPER [ lltype . nullptr ] = rtype_const_result <EOL> BUILTIN_TYPER [ lltype . identityhash ] = rtype_identity_hash <EOL> BUILTIN_TYPER [ lltype . getRuntimeTypeInfo ] = rtype_const_result <EOL> BUILTIN_TYPER [ lltype . Ptr ] = rtype_const_result <EOL> BUILTIN_TYPER [ lltype . runtime_type_info ] = rtype_runtime_type_info <EOL> BUILTIN_TYPER [ rarithmetic . intmask ] = rtype_intmask <EOL> BUILTIN_TYPER [ objectmodel . we_are_translated ] = rtype_we_are_translated <EOL> BUILTIN_TYPER [ objectmodel . hlinvoke ] = rtype_hlinvoke <EOL> from pypy . rpython . lltypesystem import llmemory <EOL> def rtype_raw_malloc ( hop ) : <EOL> v_size , = hop . inputargs ( lltype . Signed ) <EOL> return hop . genop ( '<STR_LIT>' , [ v_size ] , resulttype = llmemory . Address ) <EOL> def rtype_raw_malloc_usage ( hop ) : <EOL> v_size , = hop . inputargs ( lltype . Signed ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ v_size ] , resulttype = lltype . Signed ) <EOL> def rtype_raw_free ( hop ) : <EOL> v_addr , = hop . inputargs ( llmemory . Address ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ v_addr ] ) <EOL> def rtype_raw_memcopy ( hop ) : <EOL> v_list = hop . inputargs ( llmemory . Address , llmemory . Address , lltype . Signed ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , v_list ) <EOL> def rtype_raw_memclear ( hop ) : <EOL> v_list = hop . inputargs ( llmemory . Address , lltype . Signed ) <EOL> return hop . genop ( '<STR_LIT>' , v_list ) <EOL> BUILTIN_TYPER [ llmemory . raw_malloc ] = rtype_raw_malloc <EOL> BUILTIN_TYPER [ llmemory . raw_malloc_usage ] = rtype_raw_malloc_usage <EOL> BUILTIN_TYPER [ llmemory . raw_free ] = rtype_raw_free <EOL> BUILTIN_TYPER [ llmemory . raw_memclear ] = rtype_raw_memclear <EOL> BUILTIN_TYPER [ llmemory . raw_memcopy ] = rtype_raw_memcopy <EOL> def rtype_offsetof ( hop ) : <EOL> TYPE , field = hop . inputargs ( lltype . Void , lltype . Void ) <EOL> return hop . inputconst ( lltype . Signed , <EOL> llmemory . offsetof ( TYPE . value , field . value ) ) <EOL> BUILTIN_TYPER [ llmemory . offsetof ] = rtype_offsetof <EOL> def rtype_free_non_gc_object ( hop ) : <EOL> vinst , = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] ) <EOL> flavor = hop . args_r [ <NUM_LIT:0> ] . gcflavor <EOL> assert flavor != '<STR_LIT>' <EOL> cflavor = hop . inputconst ( lltype . Void , flavor ) <EOL> return hop . genop ( '<STR_LIT>' , [ vinst , cflavor ] ) <EOL> BUILTIN_TYPER [ objectmodel . free_non_gc_object ] = rtype_free_non_gc_object <EOL> def rtype_keepalive_until_here ( hop ) : <EOL> for v in hop . args_v : <EOL> hop . genop ( '<STR_LIT>' , [ v ] , resulttype = lltype . Void ) <EOL> return hop . inputconst ( lltype . Void , None ) <EOL> BUILTIN_TYPER [ objectmodel . keepalive_until_here ] = rtype_keepalive_until_here <EOL> def rtype_cast_ptr_to_adr ( hop ) : <EOL> vlist = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] ) <EOL> assert isinstance ( vlist [ <NUM_LIT:0> ] . concretetype , lltype . Ptr ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , vlist , <EOL> resulttype = llmemory . Address ) <EOL> def rtype_cast_adr_to_ptr ( hop ) : <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:0> ] , raddress . AddressRepr ) <EOL> adr , TYPE = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] , lltype . Void ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ adr ] , <EOL> resulttype = TYPE . value ) <EOL> def rtype_cast_adr_to_int ( hop ) : <EOL> assert isinstance ( hop . args_r [ <NUM_LIT:0> ] , raddress . AddressRepr ) <EOL> adr , = hop . inputargs ( hop . args_r [ <NUM_LIT:0> ] ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ adr ] , <EOL> resulttype = lltype . Signed ) <EOL> def rtype_cast_int_to_adr ( hop ) : <EOL> v_input , = hop . inputargs ( lltype . Signed ) <EOL> hop . exception_cannot_occur ( ) <EOL> return hop . genop ( '<STR_LIT>' , [ v_input ] , <EOL> resulttype = llmemory . Address ) <EOL> BUILTIN_TYPER [ llmemory . cast_ptr_to_adr ] = rtype_cast_ptr_to_adr <EOL> BUILTIN_TYPER [ llmemory . cast_adr_to_ptr ] = rtype_cast_adr_to_ptr <EOL> BUILTIN_TYPER [ llmemory . cast_adr_to_int ] = rtype_cast_adr_to_int <EOL> BUILTIN_TYPER [ llmemory . cast_int_to_adr ] = rtype_cast_int_to_adr </s>
