<s> import autopath <EOL> import py , os <EOL> from pypy . config . config import OptionDescription , BoolOption , IntOption , ArbitraryOption , FloatOption <EOL> from pypy . config . config import ChoiceOption , StrOption , to_optparse , Config <EOL> from pypy . config . config import ConfigError <EOL> DEFL_INLINE_THRESHOLD = <NUM_LIT> <EOL> DEFL_PROF_BASED_INLINE_THRESHOLD = <NUM_LIT> <EOL> DEFL_CLEVER_MALLOC_REMOVAL_INLINE_THRESHOLD = <NUM_LIT> <EOL> DEFL_LOW_INLINE_THRESHOLD = DEFL_INLINE_THRESHOLD / <NUM_LIT> <EOL> PLATFORMS = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:host>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> translation_optiondescription = OptionDescription ( <EOL> "<STR_LIT>" , "<STR_LIT>" , [ <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False , cmdline = "<STR_LIT>" , <EOL> requires = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] ) , <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , cmdline = None , default = "<STR_LIT>" , <EOL> requires = { <EOL> "<STR_LIT>" : [ <EOL> ( "<STR_LIT>" , False ) , <EOL> ( "<STR_LIT>" , False ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] <EOL> } ) , <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" ] , default = "<STR_LIT:c>" , <EOL> requires = { <EOL> "<STR_LIT:c>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> } , <EOL> cmdline = "<STR_LIT>" ) , <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:none>" ] , <EOL> "<STR_LIT>" , requires = { <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , False ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT:none>" : [ ( "<STR_LIT>" , False ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:none>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> } , <EOL> cmdline = "<STR_LIT>" ) , <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:none>" ] , <EOL> default = "<STR_LIT>" , cmdline = None , <EOL> requires = { <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT:none>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> } ) , <EOL> OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False , cmdline = "<STR_LIT>" ) , <EOL> ] ) , <EOL> ChoiceOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" , <EOL> requires = { <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:c>" ) ] , <EOL> } ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False , cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False , cmdline = "<STR_LIT>" , <EOL> requires = [ ( "<STR_LIT>" , False ) ] , <EOL> suggests = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = True ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False , <EOL> requires = [ ( "<STR_LIT>" , False ) , <EOL> ( "<STR_LIT>" , False ) ] , <EOL> suggests = [ ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , True ) ] ) , <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> default = "<STR_LIT>" , cmdline = "<STR_LIT>" ) , <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> default = "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" , default = True ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False , <EOL> cmdline = "<STR_LIT>" ) , <EOL> StrOption ( "<STR_LIT>" , "<STR_LIT>" , cmdline = "<STR_LIT>" ) , <EOL> StrOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False , cmdline = "<STR_LIT>" , negation = False ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False , cmdline = None ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False , <EOL> cmdline = None ) , <EOL> ChoiceOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:source>" , <EOL> "<STR_LIT>" ] , <EOL> default = None , cmdline = "<STR_LIT>" ) , <EOL> ArbitraryOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = None ) , <EOL> StrOption ( "<STR_LIT>" , "<STR_LIT>" , cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" , <EOL> default = False , requires = [ ( "<STR_LIT>" , "<STR_LIT:c>" ) ] ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> default = False , <EOL> cmdline = "<STR_LIT>" , <EOL> requires = [ ( "<STR_LIT>" , True ) ] ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> default = False , cmdline = "<STR_LIT>" , negation = False ) , <EOL> StrOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" ) , <EOL> StrOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = True ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = False , <EOL> cmdline = None ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = False , <EOL> cmdline = '<STR_LIT>' ) , <EOL> IntOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> default = <NUM_LIT:0> ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = False ) , <EOL> OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = True ) , <EOL> ] ) , <EOL> OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = True ) , <EOL> FloatOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = DEFL_INLINE_THRESHOLD , cmdline = "<STR_LIT>" ) , <EOL> StrOption ( "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = False ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" , default = True ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = False , cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = True ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , <EOL> default = True ) , <EOL> StrOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = None , cmdline = "<STR_LIT>" ) , <EOL> FloatOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = DEFL_PROF_BASED_INLINE_THRESHOLD , <EOL> cmdline = "<STR_LIT>" ) , <EOL> StrOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> default = False , <EOL> cmdline = "<STR_LIT>" ) , <EOL> FloatOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = DEFL_CLEVER_MALLOC_REMOVAL_INLINE_THRESHOLD , <EOL> cmdline = "<STR_LIT>" ) , <EOL> StrOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = "<STR_LIT>" , <EOL> cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = False ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = False ) , <EOL> BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = True ) , <EOL> BoolOption ( "<STR_LIT:none>" , <EOL> "<STR_LIT>" , <EOL> requires = [ ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ( '<STR_LIT>' , False ) ] ) <EOL> ] ) , <EOL> OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False , <EOL> cmdline = "<STR_LIT>" ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False ) , <EOL> ] ) , <EOL> ChoiceOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , [ '<STR_LIT:host>' ] + PLATFORMS , default = '<STR_LIT:host>' , <EOL> cmdline = '<STR_LIT>' ) , <EOL> ] ) <EOL> def get_combined_translation_config ( other_optdescr = None , <EOL> existing_config = None , <EOL> overrides = None , <EOL> translating = False ) : <EOL> if overrides is None : <EOL> overrides = { } <EOL> d = BoolOption ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> default = False , cmdline = None ) <EOL> if other_optdescr is None : <EOL> children = [ ] <EOL> newname = "<STR_LIT>" <EOL> else : <EOL> children = [ other_optdescr ] <EOL> newname = other_optdescr . _name <EOL> if existing_config is None : <EOL> children += [ d , translation_optiondescription ] <EOL> else : <EOL> children += [ child for child in existing_config . _cfgimpl_descr . _children <EOL> if child . _name != newname ] <EOL> descr = OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , children ) <EOL> config = Config ( descr , ** overrides ) <EOL> if translating : <EOL> config . translating = True <EOL> if existing_config is not None : <EOL> for child in existing_config . _cfgimpl_descr . _children : <EOL> if child . _name == newname : <EOL> continue <EOL> value = getattr ( existing_config , child . _name ) <EOL> config . _cfgimpl_values [ child . _name ] = value <EOL> return config <EOL> OPT_LEVELS = [ '<STR_LIT:0>' , '<STR_LIT:1>' , '<STR_LIT:size>' , '<STR_LIT>' , '<STR_LIT:2>' , '<STR_LIT:3>' , '<STR_LIT>' ] <EOL> DEFAULT_OPT_LEVEL = '<STR_LIT:2>' <EOL> OPT_TABLE_DOC = { <EOL> '<STR_LIT:0>' : '<STR_LIT>' , <EOL> '<STR_LIT:1>' : '<STR_LIT>' , <EOL> '<STR_LIT:size>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:2>' : '<STR_LIT>' , <EOL> '<STR_LIT:3>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> OPT_TABLE = { <EOL> '<STR_LIT:0>' : '<STR_LIT>' , <EOL> '<STR_LIT:1>' : '<STR_LIT>' , <EOL> '<STR_LIT:size>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:2>' : '<STR_LIT>' , <EOL> '<STR_LIT:3>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def set_opt_level ( config , level ) : <EOL> """<STR_LIT>""" <EOL> type_system = config . translation . type_system <EOL> backend = config . translation . backend <EOL> try : <EOL> opts = OPT_TABLE [ level ] <EOL> except KeyError : <EOL> raise ConfigError ( "<STR_LIT>" % ( level , ) ) <EOL> words = opts . split ( ) <EOL> gc = words . pop ( <NUM_LIT:0> ) <EOL> if config . translation . _cfgimpl_value_owners [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> config . translation . suggest ( gc = gc ) <EOL> for word in words : <EOL> if word == '<STR_LIT>' : <EOL> config . translation . backendopt . suggest ( none = True ) <EOL> elif word == '<STR_LIT>' : <EOL> config . translation . backendopt . suggest ( inline_threshold = <EOL> DEFL_LOW_INLINE_THRESHOLD ) <EOL> elif word == '<STR_LIT>' : <EOL> config . translation . backendopt . suggest ( remove_asserts = True ) <EOL> elif word == '<STR_LIT>' : <EOL> config . translation . suggest ( withsmallfuncsets = <NUM_LIT:5> ) <EOL> elif word == '<STR_LIT>' : <EOL> config . translation . suggest ( jit = True ) <EOL> elif word == '<STR_LIT>' : <EOL> config . translation . gcconfig . suggest ( removetypeptr = True ) <EOL> else : <EOL> raise ValueError ( word ) <EOL> hasbackendopts = '<STR_LIT>' not in words <EOL> config . translation . suggest ( list_comprehension_operations = hasbackendopts ) <EOL> def set_platform ( config ) : <EOL> from pypy . translator . platform import set_platform <EOL> set_platform ( config . translation . platform , config . translation . cc ) <EOL> def get_platform ( config ) : <EOL> from pypy . translator . platform import pick_platform <EOL> opt = config . translation . platform <EOL> cc = config . translation . cc <EOL> return pick_platform ( opt , cc ) </s>
