<s> """<STR_LIT>""" <EOL> from types import MethodType <EOL> from pypy . annotation . model import SomeObject , SomeInteger , SomeBool , SomeString , SomeChar , SomeList , SomeDict , SomeTuple , SomeImpossibleValue , SomeInstance , SomeBuiltin , SomeFloat , SomeIterator , SomePBC , SomeExternalObject , SomeTypedAddressAccess , SomeAddress , s_ImpossibleValue , s_Bool , s_None , unionof , set , missing_operation , add_knowntypedata , HarmlesslyBlocked , SomeGenericCallable , SomeWeakRef , SomeUnicodeString <EOL> from pypy . annotation . bookkeeper import getbookkeeper <EOL> from pypy . annotation import builtin <EOL> from pypy . annotation . binaryop import _clone <EOL> from pypy . rpython import extregistry <EOL> def immutablevalue ( x ) : <EOL> return getbookkeeper ( ) . immutablevalue ( x ) <EOL> UNARY_OPERATIONS = set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:str>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:type>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:int>' , '<STR_LIT:float>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:id>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> for opname in UNARY_OPERATIONS : <EOL> missing_operation ( SomeObject , opname ) <EOL> class __extend__ ( SomeObject ) : <EOL> def type ( obj , * moreargs ) : <EOL> if moreargs : <EOL> raise Exception , '<STR_LIT>' <EOL> if obj . is_constant ( ) : <EOL> if isinstance ( obj , SomeInstance ) : <EOL> r = SomePBC ( [ obj . classdef . classdesc ] ) <EOL> else : <EOL> r = immutablevalue ( obj . knowntype ) <EOL> else : <EOL> r = SomeObject ( ) <EOL> r . knowntype = type <EOL> bk = getbookkeeper ( ) <EOL> fn , block , i = bk . position_key <EOL> annotator = bk . annotator <EOL> op = block . operations [ i ] <EOL> assert op . opname == "<STR_LIT:type>" <EOL> assert len ( op . args ) == <NUM_LIT:1> <EOL> assert annotator . binding ( op . args [ <NUM_LIT:0> ] ) == obj <EOL> r . is_type_of = [ op . args [ <NUM_LIT:0> ] ] <EOL> return r <EOL> def issubtype ( obj , s_cls ) : <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> vars = obj . is_type_of <EOL> annotator = getbookkeeper ( ) . annotator <EOL> return builtin . builtin_isinstance ( annotator . binding ( vars [ <NUM_LIT:0> ] ) , <EOL> s_cls , vars ) <EOL> if obj . is_constant ( ) and s_cls . is_constant ( ) : <EOL> return immutablevalue ( issubclass ( obj . const , s_cls . const ) ) <EOL> return s_Bool <EOL> def len ( obj ) : <EOL> return SomeInteger ( nonneg = True ) <EOL> def is_true_behavior ( obj , s ) : <EOL> if obj . is_immutable_constant ( ) : <EOL> s . const = bool ( obj . const ) <EOL> else : <EOL> s_len = obj . len ( ) <EOL> if s_len . is_immutable_constant ( ) : <EOL> s . const = s_len . const > <NUM_LIT:0> <EOL> def is_true ( s_obj ) : <EOL> r = SomeBool ( ) <EOL> s_obj . is_true_behavior ( r ) <EOL> bk = getbookkeeper ( ) <EOL> knowntypedata = r . knowntypedata = { } <EOL> fn , block , i = bk . position_key <EOL> op = block . operations [ i ] <EOL> assert op . opname == "<STR_LIT>" or op . opname == "<STR_LIT>" <EOL> assert len ( op . args ) == <NUM_LIT:1> <EOL> arg = op . args [ <NUM_LIT:0> ] <EOL> s_nonnone_obj = s_obj <EOL> if s_obj . can_be_none ( ) : <EOL> s_nonnone_obj = s_obj . nonnoneify ( ) <EOL> add_knowntypedata ( knowntypedata , True , [ arg ] , s_nonnone_obj ) <EOL> return r <EOL> def nonzero ( obj ) : <EOL> return obj . is_true ( ) <EOL> def hash ( obj ) : <EOL> raise TypeError , ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def str ( obj ) : <EOL> getbookkeeper ( ) . count ( '<STR_LIT:str>' , obj ) <EOL> return SomeString ( ) <EOL> def unicode ( obj ) : <EOL> getbookkeeper ( ) . count ( '<STR_LIT>' , obj ) <EOL> return SomeUnicodeString ( ) <EOL> def repr ( obj ) : <EOL> getbookkeeper ( ) . count ( '<STR_LIT>' , obj ) <EOL> return SomeString ( ) <EOL> def hex ( obj ) : <EOL> getbookkeeper ( ) . count ( '<STR_LIT>' , obj ) <EOL> return SomeString ( ) <EOL> def oct ( obj ) : <EOL> getbookkeeper ( ) . count ( '<STR_LIT>' , obj ) <EOL> return SomeString ( ) <EOL> def id ( obj ) : <EOL> raise Exception ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def int ( obj ) : <EOL> return SomeInteger ( ) <EOL> def float ( obj ) : <EOL> return SomeFloat ( ) <EOL> def long ( obj ) : <EOL> return SomeObject ( ) <EOL> def delattr ( obj , s_attr ) : <EOL> if obj . __class__ != SomeObject or obj . knowntype != object : <EOL> getbookkeeper ( ) . warning ( <EOL> ( "<STR_LIT>" % <EOL> ( obj , s_attr ) ) ) <EOL> def find_method ( obj , name ) : <EOL> "<STR_LIT>" <EOL> try : <EOL> analyser = getattr ( obj . __class__ , '<STR_LIT>' + name ) <EOL> except AttributeError : <EOL> return None <EOL> else : <EOL> return SomeBuiltin ( analyser , obj , name ) <EOL> def getattr ( obj , s_attr ) : <EOL> if s_attr . is_constant ( ) and isinstance ( s_attr . const , str ) : <EOL> attr = s_attr . const <EOL> s_method = obj . find_method ( attr ) <EOL> if s_method is not None : <EOL> return s_method <EOL> if obj . is_immutable_constant ( ) and hasattr ( obj . const , attr ) : <EOL> return immutablevalue ( getattr ( obj . const , attr ) ) <EOL> else : <EOL> getbookkeeper ( ) . warning ( '<STR_LIT>' % <EOL> ( obj , s_attr ) ) <EOL> return SomeObject ( ) <EOL> getattr . can_only_throw = [ ] <EOL> def bind_callables_under ( obj , classdef , name ) : <EOL> return obj <EOL> def simple_call ( obj , * args_s ) : <EOL> return obj . call ( getbookkeeper ( ) . build_args ( "<STR_LIT>" , args_s ) ) <EOL> def call_args ( obj , * args_s ) : <EOL> return obj . call ( getbookkeeper ( ) . build_args ( "<STR_LIT>" , args_s ) ) <EOL> def call ( obj , args , implicit_init = False ) : <EOL> getbookkeeper ( ) . warning ( "<STR_LIT>" % ( obj , args ) ) <EOL> return SomeObject ( ) <EOL> def op_contains ( obj , s_element ) : <EOL> return s_Bool <EOL> op_contains . can_only_throw = [ ] <EOL> def hint ( self , * args_s ) : <EOL> return self <EOL> class __extend__ ( SomeFloat ) : <EOL> def pos ( flt ) : <EOL> return flt <EOL> def neg ( flt ) : <EOL> return SomeFloat ( ) <EOL> abs = neg <EOL> def is_true ( self ) : <EOL> if self . is_immutable_constant ( ) : <EOL> return getbookkeeper ( ) . immutablevalue ( bool ( self . const ) ) <EOL> return s_Bool <EOL> class __extend__ ( SomeInteger ) : <EOL> def invert ( self ) : <EOL> return SomeInteger ( knowntype = self . knowntype ) <EOL> invert . can_only_throw = [ ] <EOL> def pos ( self ) : <EOL> return SomeInteger ( knowntype = self . knowntype ) <EOL> pos . can_only_throw = [ ] <EOL> int = pos <EOL> def neg ( self ) : <EOL> return SomeInteger ( knowntype = self . knowntype ) <EOL> neg . can_only_throw = [ ] <EOL> neg_ovf = _clone ( neg , [ OverflowError ] ) <EOL> def abs ( self ) : <EOL> return SomeInteger ( nonneg = True , knowntype = self . knowntype ) <EOL> abs . can_only_throw = [ ] <EOL> abs_ovf = _clone ( abs , [ OverflowError ] ) <EOL> class __extend__ ( SomeBool ) : <EOL> def is_true ( self ) : <EOL> return self <EOL> def invert ( self ) : <EOL> return SomeInteger ( ) <EOL> invert . can_only_throw = [ ] <EOL> def neg ( self ) : <EOL> return SomeInteger ( ) <EOL> neg . can_only_throw = [ ] <EOL> neg_ovf = _clone ( neg , [ OverflowError ] ) <EOL> def abs ( self ) : <EOL> return SomeInteger ( nonneg = True ) <EOL> abs . can_only_throw = [ ] <EOL> abs_ovf = _clone ( abs , [ OverflowError ] ) <EOL> def pos ( self ) : <EOL> return SomeInteger ( nonneg = True ) <EOL> pos . can_only_throw = [ ] <EOL> int = pos <EOL> class __extend__ ( SomeTuple ) : <EOL> def len ( tup ) : <EOL> return immutablevalue ( len ( tup . items ) ) <EOL> def iter ( tup ) : <EOL> getbookkeeper ( ) . count ( "<STR_LIT>" , tup ) <EOL> return SomeIterator ( tup ) <EOL> iter . can_only_throw = [ ] <EOL> def getanyitem ( tup ) : <EOL> return unionof ( * tup . items ) <EOL> def getslice ( tup , s_start , s_stop ) : <EOL> assert s_start . is_immutable_constant ( ) , "<STR_LIT>" <EOL> assert s_stop . is_immutable_constant ( ) , "<STR_LIT>" <EOL> items = tup . items [ s_start . const : s_stop . const ] <EOL> return SomeTuple ( items ) <EOL> class __extend__ ( SomeList ) : <EOL> def method_append ( lst , s_value ) : <EOL> lst . listdef . resize ( ) <EOL> lst . listdef . generalize ( s_value ) <EOL> def method_extend ( lst , s_iterable ) : <EOL> lst . listdef . resize ( ) <EOL> if isinstance ( s_iterable , SomeList ) : <EOL> lst . listdef . agree ( s_iterable . listdef ) <EOL> else : <EOL> s_iter = s_iterable . iter ( ) <EOL> lst . method_append ( s_iter . next ( ) ) <EOL> def method_reverse ( lst ) : <EOL> lst . listdef . mutate ( ) <EOL> def method_insert ( lst , s_index , s_value ) : <EOL> lst . method_append ( s_value ) <EOL> def method_remove ( lst , s_value ) : <EOL> lst . listdef . resize ( ) <EOL> lst . listdef . generalize ( s_value ) <EOL> def method_pop ( lst , s_index = None ) : <EOL> lst . listdef . resize ( ) <EOL> return lst . listdef . read_item ( ) <EOL> def method_index ( lst , s_value ) : <EOL> getbookkeeper ( ) . count ( "<STR_LIT>" ) <EOL> lst . listdef . generalize ( s_value ) <EOL> return SomeInteger ( nonneg = True ) <EOL> def len ( lst ) : <EOL> s_item = lst . listdef . read_item ( ) <EOL> if isinstance ( s_item , SomeImpossibleValue ) : <EOL> return immutablevalue ( <NUM_LIT:0> ) <EOL> return SomeObject . len ( lst ) <EOL> def iter ( lst ) : <EOL> return SomeIterator ( lst ) <EOL> iter . can_only_throw = [ ] <EOL> def getanyitem ( lst ) : <EOL> return lst . listdef . read_item ( ) <EOL> def op_contains ( lst , s_element ) : <EOL> lst . listdef . generalize ( s_element ) <EOL> return s_Bool <EOL> op_contains . can_only_throw = [ ] <EOL> def hint ( lst , * args_s ) : <EOL> hints = args_s [ - <NUM_LIT:1> ] . const <EOL> if '<STR_LIT>' in hints : <EOL> s_iterable = args_s [ <NUM_LIT:0> ] <EOL> if isinstance ( s_iterable , ( SomeList , SomeDict ) ) : <EOL> lst = SomeList ( lst . listdef ) <EOL> lst . known_maxlength = True <EOL> lst . listdef . resize ( ) <EOL> lst . listdef . listitem . hint_maxlength = True <EOL> elif '<STR_LIT>' in hints : <EOL> lst = lst . listdef . offspring ( ) <EOL> return lst <EOL> def getslice ( lst , s_start , s_stop ) : <EOL> check_negative_slice ( s_start , s_stop ) <EOL> return lst . listdef . offspring ( ) <EOL> def setslice ( lst , s_start , s_stop , s_iterable ) : <EOL> check_negative_slice ( s_start , s_stop ) <EOL> if not isinstance ( s_iterable , SomeList ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> lst . listdef . agree ( s_iterable . listdef ) <EOL> def delslice ( lst , s_start , s_stop ) : <EOL> check_negative_slice ( s_start , s_stop ) <EOL> lst . listdef . resize ( ) <EOL> def check_negative_slice ( s_start , s_stop ) : <EOL> if isinstance ( s_start , SomeInteger ) and not s_start . nonneg : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> if isinstance ( s_stop , SomeInteger ) and not s_stop . nonneg and getattr ( s_stop , '<STR_LIT>' , <NUM_LIT:0> ) != - <NUM_LIT:1> : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> class __extend__ ( SomeDict ) : <EOL> def _is_empty ( dct ) : <EOL> s_key = dct . dictdef . read_key ( ) <EOL> s_value = dct . dictdef . read_value ( ) <EOL> return ( isinstance ( s_key , SomeImpossibleValue ) or <EOL> isinstance ( s_value , SomeImpossibleValue ) ) <EOL> def len ( dct ) : <EOL> if dct . _is_empty ( ) : <EOL> return immutablevalue ( <NUM_LIT:0> ) <EOL> return SomeObject . len ( dct ) <EOL> def iter ( dct ) : <EOL> return SomeIterator ( dct ) <EOL> iter . can_only_throw = [ ] <EOL> def getanyitem ( dct , variant = '<STR_LIT>' ) : <EOL> if variant == '<STR_LIT>' : <EOL> return dct . dictdef . read_key ( ) <EOL> elif variant == '<STR_LIT>' : <EOL> return dct . dictdef . read_value ( ) <EOL> elif variant == '<STR_LIT>' : <EOL> s_key = dct . dictdef . read_key ( ) <EOL> s_value = dct . dictdef . read_value ( ) <EOL> if ( isinstance ( s_key , SomeImpossibleValue ) or <EOL> isinstance ( s_value , SomeImpossibleValue ) ) : <EOL> return s_ImpossibleValue <EOL> else : <EOL> return SomeTuple ( ( s_key , s_value ) ) <EOL> else : <EOL> raise ValueError <EOL> def method_get ( dct , key , dfl ) : <EOL> dct . dictdef . generalize_key ( key ) <EOL> dct . dictdef . generalize_value ( dfl ) <EOL> return dct . dictdef . read_value ( ) <EOL> method_setdefault = method_get <EOL> def method_copy ( dct ) : <EOL> return SomeDict ( dct . dictdef ) <EOL> def method_update ( dct1 , dct2 ) : <EOL> dct1 . dictdef . union ( dct2 . dictdef ) <EOL> def method_keys ( dct ) : <EOL> return getbookkeeper ( ) . newlist ( dct . dictdef . read_key ( ) ) <EOL> def method_values ( dct ) : <EOL> return getbookkeeper ( ) . newlist ( dct . dictdef . read_value ( ) ) <EOL> def method_items ( dct ) : <EOL> return getbookkeeper ( ) . newlist ( dct . getanyitem ( '<STR_LIT>' ) ) <EOL> def method_iterkeys ( dct ) : <EOL> return SomeIterator ( dct , '<STR_LIT>' ) <EOL> def method_itervalues ( dct ) : <EOL> return SomeIterator ( dct , '<STR_LIT>' ) <EOL> def method_iteritems ( dct ) : <EOL> return SomeIterator ( dct , '<STR_LIT>' ) <EOL> def method_clear ( dct ) : <EOL> pass <EOL> def _can_only_throw ( dic , * ignore ) : <EOL> if dic1 . dictdef . dictkey . custom_eq_hash : <EOL> return None <EOL> return [ ] <EOL> def op_contains ( dct , s_element ) : <EOL> dct . dictdef . generalize_key ( s_element ) <EOL> if dct . _is_empty ( ) : <EOL> s_bool = SomeBool ( ) <EOL> s_bool . const = False <EOL> return s_bool <EOL> return s_Bool <EOL> op_contains . can_only_throw = _can_only_throw <EOL> class __extend__ ( SomeString , <EOL> SomeUnicodeString ) : <EOL> def method_startswith ( str , frag ) : <EOL> return s_Bool <EOL> def method_endswith ( str , frag ) : <EOL> return s_Bool <EOL> def method_find ( str , frag , start = None , end = None ) : <EOL> return SomeInteger ( ) <EOL> def method_rfind ( str , frag , start = None , end = None ) : <EOL> return SomeInteger ( ) <EOL> def method_count ( str , frag , start = None , end = None ) : <EOL> return SomeInteger ( nonneg = True ) <EOL> def method_strip ( str , chr ) : <EOL> return str . basestringclass ( ) <EOL> def method_lstrip ( str , chr ) : <EOL> return str . basestringclass ( ) <EOL> def method_rstrip ( str , chr ) : <EOL> return str . basestringclass ( ) <EOL> def method_join ( str , s_list ) : <EOL> getbookkeeper ( ) . count ( "<STR_LIT>" , str ) <EOL> s_item = s_list . listdef . read_item ( ) <EOL> if isinstance ( s_item , SomeImpossibleValue ) : <EOL> if isinstance ( str , SomeUnicodeString ) : <EOL> return immutablevalue ( u"<STR_LIT>" ) <EOL> return immutablevalue ( "<STR_LIT>" ) <EOL> return str . basestringclass ( ) <EOL> def iter ( str ) : <EOL> return SomeIterator ( str ) <EOL> iter . can_only_throw = [ ] <EOL> def getanyitem ( str ) : <EOL> return str . basecharclass ( ) <EOL> def ord ( str ) : <EOL> return SomeInteger ( nonneg = True ) <EOL> def method_split ( str , patt ) : <EOL> getbookkeeper ( ) . count ( "<STR_LIT>" , str , patt ) <EOL> return getbookkeeper ( ) . newlist ( str . basestringclass ( ) ) <EOL> def method_replace ( str , s1 , s2 ) : <EOL> return str . basestringclass ( ) <EOL> def getslice ( str , s_start , s_stop ) : <EOL> check_negative_slice ( s_start , s_stop ) <EOL> return str . basestringclass ( ) <EOL> class __extend__ ( SomeUnicodeString ) : <EOL> def method_encode ( uni , s_enc ) : <EOL> if not s_enc . is_constant ( ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> enc = s_enc . const <EOL> if enc not in ( '<STR_LIT:ascii>' , '<STR_LIT>' ) : <EOL> raise TypeError ( "<STR_LIT>" % ( enc , ) ) <EOL> return SomeString ( ) <EOL> method_encode . can_only_throw = [ UnicodeEncodeError ] <EOL> class __extend__ ( SomeString ) : <EOL> def method_upper ( str ) : <EOL> return SomeString ( ) <EOL> def method_lower ( str ) : <EOL> return SomeString ( ) <EOL> def method_splitlines ( str , s_keep_newlines = None ) : <EOL> s_list = getbookkeeper ( ) . newlist ( str . basestringclass ( ) ) <EOL> s_list . listdef . listitem . resize ( ) <EOL> return s_list <EOL> def method_decode ( str , s_enc ) : <EOL> if not s_enc . is_constant ( ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> enc = s_enc . const <EOL> if enc not in ( '<STR_LIT:ascii>' , '<STR_LIT>' ) : <EOL> raise TypeError ( "<STR_LIT>" % ( enc , ) ) <EOL> return SomeUnicodeString ( ) <EOL> method_decode . can_only_throw = [ UnicodeDecodeError ] <EOL> class __extend__ ( SomeChar ) : <EOL> def len ( chr ) : <EOL> return immutablevalue ( <NUM_LIT:1> ) <EOL> def method_isspace ( chr ) : <EOL> return s_Bool <EOL> def method_isdigit ( chr ) : <EOL> return s_Bool <EOL> def method_isalpha ( chr ) : <EOL> return s_Bool <EOL> def method_isalnum ( chr ) : <EOL> return s_Bool <EOL> def method_islower ( chr ) : <EOL> return s_Bool <EOL> def method_isupper ( chr ) : <EOL> return s_Bool <EOL> class __extend__ ( SomeIterator ) : <EOL> def iter ( itr ) : <EOL> return itr <EOL> iter . can_only_throw = [ ] <EOL> def _can_only_throw ( itr ) : <EOL> can_throw = [ StopIteration ] <EOL> if isinstance ( itr . s_container , SomeDict ) : <EOL> can_throw . append ( RuntimeError ) <EOL> return can_throw <EOL> def next ( itr ) : <EOL> return itr . s_container . getanyitem ( * itr . variant ) <EOL> next . can_only_throw = _can_only_throw <EOL> method_next = next <EOL> class __extend__ ( SomeInstance ) : <EOL> def getattr ( ins , s_attr ) : <EOL> if s_attr . is_constant ( ) and isinstance ( s_attr . const , str ) : <EOL> attr = s_attr . const <EOL> if attr == '<STR_LIT>' : <EOL> return ins . classdef . read_attr__class__ ( ) <EOL> attrdef = ins . classdef . find_attribute ( attr ) <EOL> position = getbookkeeper ( ) . position_key <EOL> attrdef . read_locations [ position ] = True <EOL> s_result = attrdef . getvalue ( ) <EOL> if isinstance ( s_result , SomePBC ) : <EOL> s_result = ins . classdef . lookup_filter ( s_result , attr , <EOL> ins . flags ) <EOL> elif isinstance ( s_result , SomeImpossibleValue ) : <EOL> ins . classdef . check_missing_attribute_update ( attr ) <EOL> for basedef in ins . classdef . getmro ( ) : <EOL> if basedef . classdesc . all_enforced_attrs is not None : <EOL> if attr in basedef . classdesc . all_enforced_attrs : <EOL> raise HarmlesslyBlocked ( "<STR_LIT>" ) <EOL> return s_result <EOL> return SomeObject ( ) <EOL> getattr . can_only_throw = [ ] <EOL> def setattr ( ins , s_attr , s_value ) : <EOL> if s_attr . is_constant ( ) and isinstance ( s_attr . const , str ) : <EOL> attr = s_attr . const <EOL> clsdef = ins . classdef . locate_attribute ( attr ) <EOL> attrdef = clsdef . attrs [ attr ] <EOL> attrdef . modified ( clsdef ) <EOL> if attrdef . getvalue ( ) . contains ( s_value ) : <EOL> return <EOL> clsdef . generalize_attr ( attr , s_value ) <EOL> def is_true_behavior ( ins , s ) : <EOL> if not ins . can_be_None : <EOL> s . const = True <EOL> class __extend__ ( SomeBuiltin ) : <EOL> def simple_call ( bltn , * args ) : <EOL> if bltn . s_self is not None : <EOL> return bltn . analyser ( bltn . s_self , * args ) <EOL> else : <EOL> if bltn . methodname : <EOL> getbookkeeper ( ) . count ( bltn . methodname . replace ( '<STR_LIT:.>' , '<STR_LIT:_>' ) , * args ) <EOL> return bltn . analyser ( * args ) <EOL> def call ( bltn , args , implicit_init = False ) : <EOL> args_s , kwds = args . unpack ( ) <EOL> kwds_s = { } <EOL> for key , s_value in kwds . items ( ) : <EOL> kwds_s [ '<STR_LIT>' + key ] = s_value <EOL> if bltn . s_self is not None : <EOL> return bltn . analyser ( bltn . s_self , * args_s , ** kwds_s ) <EOL> else : <EOL> return bltn . analyser ( * args_s , ** kwds_s ) <EOL> class __extend__ ( SomePBC ) : <EOL> def getattr ( pbc , s_attr ) : <EOL> bookkeeper = getbookkeeper ( ) <EOL> return bookkeeper . pbc_getattr ( pbc , s_attr ) <EOL> getattr . can_only_throw = [ ] <EOL> def setattr ( pbc , s_attr , s_value ) : <EOL> getbookkeeper ( ) . warning ( "<STR_LIT>" % ( pbc , ) ) <EOL> def call ( pbc , args ) : <EOL> bookkeeper = getbookkeeper ( ) <EOL> return bookkeeper . pbc_call ( pbc , args ) <EOL> def bind_callables_under ( pbc , classdef , name ) : <EOL> d = [ desc . bind_under ( classdef , name ) for desc in pbc . descriptions ] <EOL> return SomePBC ( d , can_be_None = pbc . can_be_None ) <EOL> def is_true_behavior ( pbc , s ) : <EOL> if pbc . isNone ( ) : <EOL> s . const = False <EOL> elif not pbc . can_be_None : <EOL> s . const = True <EOL> def len ( pbc ) : <EOL> if pbc . isNone ( ) : <EOL> return immutablevalue ( <NUM_LIT:0> ) <EOL> else : <EOL> return SomeObject ( ) <EOL> class __extend__ ( SomeGenericCallable ) : <EOL> def call ( self , args ) : <EOL> bookkeeper = getbookkeeper ( ) <EOL> for arg , expected in zip ( args . unpack ( ) [ <NUM_LIT:0> ] , self . args_s ) : <EOL> assert expected . contains ( arg ) <EOL> return self . s_result <EOL> class __extend__ ( SomeExternalObject ) : <EOL> def getattr ( p , s_attr ) : <EOL> if s_attr . is_constant ( ) and isinstance ( s_attr . const , str ) : <EOL> attr = s_attr . const <EOL> entry = extregistry . lookup_type ( p . knowntype ) <EOL> s_value = entry . get_field_annotation ( p . knowntype , attr ) <EOL> return s_value <EOL> else : <EOL> return SomeObject ( ) <EOL> getattr . can_only_throw = [ ] <EOL> def setattr ( p , s_attr , s_value ) : <EOL> assert s_attr . is_constant ( ) <EOL> attr = s_attr . const <EOL> entry = extregistry . lookup_type ( p . knowntype ) <EOL> entry . set_field_annotation ( p . knowntype , attr , s_value ) <EOL> def is_true ( p ) : <EOL> return s_Bool <EOL> from pypy . annotation . model import SomePtr , SomeLLADTMeth <EOL> from pypy . annotation . model import SomeOOInstance , SomeOOBoundMeth , SomeOOStaticMeth <EOL> from pypy . annotation . model import ll_to_annotation , lltype_to_annotation , annotation_to_lltype <EOL> class __extend__ ( SomePtr ) : <EOL> def getattr ( p , s_attr ) : <EOL> assert s_attr . is_constant ( ) , "<STR_LIT>" % p . ll_ptrtype <EOL> example = p . ll_ptrtype . _example ( ) <EOL> try : <EOL> v = example . _lookup_adtmeth ( s_attr . const ) <EOL> except AttributeError : <EOL> v = getattr ( example , s_attr . const ) <EOL> return ll_to_annotation ( v ) <EOL> else : <EOL> if isinstance ( v , MethodType ) : <EOL> from pypy . rpython . lltypesystem import lltype <EOL> ll_ptrtype = lltype . typeOf ( v . im_self ) <EOL> assert isinstance ( ll_ptrtype , ( lltype . Ptr , lltype . InteriorPtr ) ) <EOL> return SomeLLADTMeth ( ll_ptrtype , v . im_func ) <EOL> return getbookkeeper ( ) . immutablevalue ( v ) <EOL> getattr . can_only_throw = [ ] <EOL> def len ( p ) : <EOL> length = p . ll_ptrtype . _example ( ) . _fixedlength ( ) <EOL> if length is None : <EOL> return SomeObject . len ( p ) <EOL> else : <EOL> return immutablevalue ( length ) <EOL> def setattr ( p , s_attr , s_value ) : <EOL> assert s_attr . is_constant ( ) , "<STR_LIT>" % p . ll_ptrtype <EOL> example = p . ll_ptrtype . _example ( ) <EOL> if getattr ( example , s_attr . const ) is not None : <EOL> v_lltype = annotation_to_lltype ( s_value ) <EOL> setattr ( example , s_attr . const , v_lltype . _defl ( ) ) <EOL> def call ( p , args ) : <EOL> args_s , kwds_s = args . unpack ( ) <EOL> if kwds_s : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> info = '<STR_LIT>' <EOL> llargs = [ annotation_to_lltype ( s_arg , info ) . _defl ( ) for s_arg in args_s ] <EOL> v = p . ll_ptrtype . _example ( ) ( * llargs ) <EOL> return ll_to_annotation ( v ) <EOL> def is_true ( p ) : <EOL> return s_Bool <EOL> class __extend__ ( SomeLLADTMeth ) : <EOL> def call ( adtmeth , args ) : <EOL> bookkeeper = getbookkeeper ( ) <EOL> s_func = bookkeeper . immutablevalue ( adtmeth . func ) <EOL> return s_func . call ( args . prepend ( lltype_to_annotation ( adtmeth . ll_ptrtype ) ) ) <EOL> from pypy . rpython . ootypesystem import ootype <EOL> class __extend__ ( SomeOOInstance ) : <EOL> def getattr ( r , s_attr ) : <EOL> assert s_attr . is_constant ( ) , "<STR_LIT>" % r . ootype <EOL> v = getattr ( r . ootype . _example ( ) , s_attr . const ) <EOL> if isinstance ( v , ootype . _bound_meth ) : <EOL> return SomeOOBoundMeth ( r . ootype , s_attr . const ) <EOL> return ll_to_annotation ( v ) <EOL> def setattr ( r , s_attr , s_value ) : <EOL> assert s_attr . is_constant ( ) , "<STR_LIT>" % r . ootype <EOL> v = annotation_to_lltype ( s_value ) <EOL> example = r . ootype . _example ( ) <EOL> if example is not None : <EOL> setattr ( r . ootype . _example ( ) , s_attr . const , v . _example ( ) ) <EOL> def is_true ( p ) : <EOL> return s_Bool <EOL> class __extend__ ( SomeOOBoundMeth ) : <EOL> def simple_call ( m , * args_s ) : <EOL> _ , meth = m . ootype . _lookup ( m . name ) <EOL> if isinstance ( meth , ootype . _overloaded_meth ) : <EOL> return meth . _resolver . annotate ( args_s ) <EOL> else : <EOL> METH = ootype . typeOf ( meth ) <EOL> return lltype_to_annotation ( METH . RESULT ) <EOL> def call ( m , args ) : <EOL> args_s , kwds_s = args . unpack ( ) <EOL> if kwds_s : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> inst = m . ootype . _example ( ) <EOL> _ , meth = ootype . typeOf ( inst ) . _lookup ( m . name ) <EOL> METH = ootype . typeOf ( meth ) <EOL> return lltype_to_annotation ( METH . RESULT ) <EOL> class __extend__ ( SomeOOStaticMeth ) : <EOL> def call ( m , args ) : <EOL> args_s , kwds_s = args . unpack ( ) <EOL> if kwds_s : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> info = '<STR_LIT>' <EOL> llargs = [ annotation_to_lltype ( s_arg , info ) . _defl ( ) for s_arg in args_s ] <EOL> v = m . method . _example ( ) ( * llargs ) <EOL> return ll_to_annotation ( v ) <EOL> class __extend__ ( SomeWeakRef ) : <EOL> def simple_call ( s_wrf ) : <EOL> if s_wrf . classdef is None : <EOL> return s_None <EOL> else : <EOL> return SomeInstance ( s_wrf . classdef , can_be_None = True ) <EOL> from pypy . rpython . lltypesystem import llmemory <EOL> class __extend__ ( SomeAddress ) : <EOL> def getattr ( s_addr , s_attr ) : <EOL> assert s_attr . is_constant ( ) <EOL> assert isinstance ( s_attr , SomeString ) <EOL> assert s_attr . const in llmemory . supported_access_types <EOL> return SomeTypedAddressAccess ( <EOL> llmemory . supported_access_types [ s_attr . const ] ) <EOL> getattr . can_only_throw = [ ] <EOL> def is_true ( s_addr ) : <EOL> return s_Bool </s>
