<s> import pypy . translator . jvm . typesystem as jvm <EOL> from pypy . rpython . ootypesystem import ootype <EOL> from pypy . translator . jvm . typesystem import jInt , jVoid , jStringBuilder , jString , jPyPy , jChar , jArrayList , jObject , jBool , jHashMap , jPyPyDictItemsIterator , Generifier , jCharSequence , jPyPyCustomDict <EOL> class JvmBuiltInType ( jvm . JvmClassType ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , db , classty , OOTYPE ) : <EOL> jvm . JvmClassType . __init__ ( self , classty . name ) <EOL> self . db = db <EOL> self . OOTYPE = OOTYPE <EOL> self . gen = Generifier ( OOTYPE ) <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , JvmBuiltInType ) and other . name == self . name <EOL> def __hash__ ( self ) : <EOL> return hash ( self . name ) <EOL> def lookup_field ( self , fieldnm ) : <EOL> """<STR_LIT>""" <EOL> _ , FIELDTY = self . OOTYPE . _lookup_field ( fieldnm ) <EOL> jfieldty = self . db . lltype_to_cts ( FIELDTY ) <EOL> return jvm . Field ( <EOL> self . descriptor . class_name ( ) , fieldnm , jfieldty , False ) <EOL> def lookup_method ( self , methodnm ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> key = ( self . OOTYPE . __class__ , methodnm ) <EOL> return built_in_methods [ key ] <EOL> except KeyError : pass <EOL> ARGS , RESULT = self . gen . erased_types ( methodnm ) <EOL> jargtypes = [ self . db . lltype_to_cts ( P ) for P in ARGS ] <EOL> jrettype = self . db . lltype_to_cts ( RESULT ) <EOL> if self . OOTYPE . __class__ in bridged_objects : <EOL> return jvm . Method . v ( self , methodnm , jargtypes , jrettype ) <EOL> else : <EOL> jargtypes = [ self ] + jargtypes <EOL> return jvm . Method . s ( jPyPy , methodnm , jargtypes , jrettype ) <EOL> bridged_objects = ( <EOL> ootype . DictItemsIterator , <EOL> ootype . WeakReference . __class__ <EOL> ) <EOL> built_in_methods = { <EOL> ( ootype . StringBuilder . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jStringBuilder , "<STR_LIT>" , ( jInt , ) , jVoid ) , <EOL> ( ootype . StringBuilder . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jStringBuilder , "<STR_LIT>" , ( ) , jString ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( ) , jInt ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( jObject , ) , jBool ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( ) , jInt ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( jInt , ) , jChar ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( jString , ) , jBool ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( jString , ) , jBool ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( jString , ) , jInt ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( ) , jString ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT>" , ( ) , jString ) , <EOL> ( ootype . String . __class__ , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jString , "<STR_LIT:replace>" , ( jChar , jChar ) , jString ) , <EOL> ( ootype . Dict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jHashMap , "<STR_LIT>" , ( jObject , jObject ) , jObject ) , <EOL> ( ootype . Dict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jHashMap , "<STR_LIT>" , ( jObject , ) , jObject ) , <EOL> ( ootype . Dict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jHashMap , "<STR_LIT>" , ( jObject , ) , jBool ) , <EOL> ( ootype . Dict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jHashMap , "<STR_LIT:size>" , ( ) , jInt ) , <EOL> ( ootype . Dict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jHashMap , "<STR_LIT>" , ( ) , jVoid ) , <EOL> ( ootype . CustomDict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jPyPyCustomDict , "<STR_LIT>" , ( jObject , jObject ) , jObject ) , <EOL> ( ootype . CustomDict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jPyPyCustomDict , "<STR_LIT>" , ( jObject , ) , jObject ) , <EOL> ( ootype . CustomDict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jPyPyCustomDict , "<STR_LIT>" , ( jObject , ) , jBool ) , <EOL> ( ootype . CustomDict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jPyPyCustomDict , "<STR_LIT:size>" , ( ) , jInt ) , <EOL> ( ootype . CustomDict , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jPyPyCustomDict , "<STR_LIT>" , ( ) , jVoid ) , <EOL> ( ootype . List , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jArrayList , "<STR_LIT:size>" , ( ) , jInt ) , <EOL> ( ootype . List , "<STR_LIT>" ) : <EOL> jvm . Method . v ( jArrayList , "<STR_LIT>" , ( jInt , ) , jObject ) , <EOL> } <EOL> def add_unicode_methods ( ) : <EOL> mapping = { <EOL> ootype . String . __class__ : ootype . Unicode . __class__ , <EOL> ootype . StringBuilder . __class__ : ootype . UnicodeBuilder . __class__ <EOL> } <EOL> for ( TYPE , name ) , value in built_in_methods . items ( ) : <EOL> if TYPE in mapping : <EOL> TYPE = mapping [ TYPE ] <EOL> built_in_methods [ TYPE , name ] = value <EOL> add_unicode_methods ( ) <EOL> del add_unicode_methods </s>
