<s> import types <EOL> from pypy . rpython . ootypesystem import ootype <EOL> from pypy . translator . cli . cts import CTS <EOL> from pypy . translator . cli . node import Node <EOL> IEQUALITY_COMPARER = '<STR_LIT>' <EOL> class EqualityComparer ( Node ) : <EOL> count = <NUM_LIT:0> <EOL> def __init__ ( self , db , KEY_TYPE , eq_args , hash_args ) : <EOL> self . db = db <EOL> self . cts = CTS ( db ) <EOL> self . KEY_TYPE = KEY_TYPE <EOL> self . key_type = self . cts . lltype_to_cts ( KEY_TYPE ) <EOL> self . eq_args = eq_args <EOL> self . hash_args = hash_args <EOL> self . name = '<STR_LIT>' % EqualityComparer . count <EOL> EqualityComparer . count += <NUM_LIT:1> <EOL> def get_ctor ( self ) : <EOL> return '<STR_LIT>' % self . name <EOL> def render ( self , ilasm ) : <EOL> self . ilasm = ilasm <EOL> IEqualityComparer = IEQUALITY_COMPARER % self . key_type <EOL> ilasm . begin_class ( self . name , interfaces = [ IEqualityComparer ] ) <EOL> self . _ctor ( ) <EOL> self . _method ( '<STR_LIT>' , [ ( self . key_type , '<STR_LIT:x>' ) , ( self . key_type , '<STR_LIT:y>' ) ] , <EOL> '<STR_LIT:bool>' , self . eq_args ) <EOL> self . _method ( '<STR_LIT>' , [ ( self . key_type , '<STR_LIT:x>' ) ] , '<STR_LIT>' , self . hash_args ) <EOL> ilasm . end_class ( ) <EOL> def _ctor ( self ) : <EOL> self . ilasm . begin_function ( '<STR_LIT>' , [ ] , '<STR_LIT>' , False , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . ilasm . opcode ( '<STR_LIT>' ) <EOL> self . ilasm . call ( '<STR_LIT>' ) <EOL> self . ilasm . opcode ( '<STR_LIT>' ) <EOL> self . ilasm . end_function ( ) <EOL> def _method ( self , name , arglist , return_type , fn_args ) : <EOL> self . ilasm . begin_function ( name , arglist , return_type , False , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:default>' ) <EOL> if type ( fn_args ) == types . FunctionType : <EOL> assert len ( fn_args . self_arg ) <= <NUM_LIT:1> <EOL> if len ( fn_args . self_arg ) == <NUM_LIT:1> : <EOL> assert fn_args . graph . getargs ( ) [ <NUM_LIT:0> ] . concretetype is ootype . Void <EOL> self . _call_function ( fn_args . graph , len ( arglist ) ) <EOL> else : <EOL> fn , obj , method_name = fn_args <EOL> if method_name . value is None : <EOL> self . _call_function ( fn . value . graph , len ( arglist ) ) <EOL> else : <EOL> assert False , '<STR_LIT>' <EOL> self . ilasm . end_function ( ) <EOL> def _call_function ( self , graph , n_args ) : <EOL> self . db . pending_function ( graph ) <EOL> for arg in range ( <NUM_LIT:1> , n_args + <NUM_LIT:1> ) : <EOL> self . ilasm . opcode ( '<STR_LIT>' , arg ) <EOL> signature = self . cts . graph_to_signature ( graph ) <EOL> self . ilasm . call ( signature ) <EOL> self . ilasm . opcode ( '<STR_LIT>' ) </s>
