<s> """<STR_LIT>""" <EOL> from py . builtin import set <EOL> from pypy . translator . oosupport import constant as ooconst <EOL> from pypy . translator . oosupport . treebuilder import build_trees <EOL> from pypy . translator . backendopt . ssa import SSI_to_SSA <EOL> class GenOO ( object ) : <EOL> TypeSystem = None <EOL> Function = None <EOL> Database = None <EOL> opcodes = None <EOL> log = None <EOL> ConstantGenerator = None <EOL> NullConst = ooconst . NullConst <EOL> InstanceConst = ooconst . InstanceConst <EOL> RecordConst = ooconst . RecordConst <EOL> ClassConst = ooconst . ClassConst <EOL> ListConst = ooconst . ListConst <EOL> ArrayConst = ooconst . ArrayConst <EOL> StaticMethodConst = ooconst . StaticMethodConst <EOL> CustomDictConst = ooconst . CustomDictConst <EOL> DictConst = ooconst . DictConst <EOL> WeakRefConst = ooconst . WeakRefConst <EOL> def __init__ ( self , tmpdir , translator , entrypoint , config = None , exctrans = False ) : <EOL> self . tmpdir = tmpdir <EOL> self . translator = translator <EOL> self . entrypoint = entrypoint <EOL> self . db = self . Database ( self ) <EOL> if config is None : <EOL> from pypy . config . pypyoption import get_pypy_config <EOL> config = get_pypy_config ( translating = True ) <EOL> self . config = config <EOL> exctrans = exctrans or translator . config . translation . cli . exception_transformer <EOL> if exctrans : <EOL> self . db . exceptiontransformer = translator . getexceptiontransformer ( ) <EOL> self . append_prebuilt_nodes ( ) <EOL> if exctrans : <EOL> etrafo = self . db . exceptiontransformer <EOL> for graph in translator . graphs : <EOL> etrafo . create_exception_handling ( graph ) <EOL> if translator . config . translation . backendopt . stack_optimization : <EOL> self . stack_optimization ( ) <EOL> def stack_optimization ( self ) : <EOL> for graph in self . translator . graphs : <EOL> SSI_to_SSA ( graph ) <EOL> build_trees ( graph ) <EOL> def append_prebuilt_nodes ( self ) : <EOL> pass <EOL> def generate_source ( self ) : <EOL> self . ilasm = self . create_assembler ( ) <EOL> self . fix_names ( ) <EOL> self . gen_entrypoint ( ) <EOL> self . gen_pendings ( ) <EOL> self . db . gen_constants ( self . ilasm ) <EOL> self . ilasm . close ( ) <EOL> def gen_entrypoint ( self ) : <EOL> if self . entrypoint : <EOL> self . entrypoint . set_db ( self . db ) <EOL> self . db . pending_node ( self . entrypoint ) <EOL> else : <EOL> self . db . pending_function ( self . translator . graphs [ <NUM_LIT:0> ] ) <EOL> def gen_pendings ( self ) : <EOL> n = <NUM_LIT:0> <EOL> while self . db . _pending_nodes : <EOL> node = self . db . _pending_nodes . pop ( ) <EOL> node . render ( self . ilasm ) <EOL> self . db . _rendered_nodes . add ( node ) <EOL> n += <NUM_LIT:1> <EOL> if ( n % <NUM_LIT:100> ) == <NUM_LIT:0> : <EOL> total = len ( self . db . _pending_nodes ) + n <EOL> self . log . graphs ( '<STR_LIT>' % ( n , total , n * <NUM_LIT> / total ) ) <EOL> def fix_names ( self ) : <EOL> names = set ( ) <EOL> for graph in self . translator . graphs : <EOL> base_name = graph . name <EOL> i = <NUM_LIT:0> <EOL> while graph . name in names : <EOL> graph . name = '<STR_LIT>' % ( base_name , i ) <EOL> i += <NUM_LIT:1> <EOL> names . add ( graph . name ) <EOL> def create_assembler ( self ) : <EOL> raise NotImplementedError </s>
