<s> """<STR_LIT>""" <EOL> from . ConstantCodes import getConstantCode <EOL> from . ErrorCodes import ( <EOL> getErrorExitBoolCode , <EOL> getErrorExitCode , <EOL> getReleaseCode , <EOL> getReleaseCodes <EOL> ) <EOL> from . GlobalsLocalsCodes import getLoadGlobalsCode , getLoadLocalsCode <EOL> from . Helpers import generateExpressionCode , generateExpressionsCode <EOL> from . LineNumberCodes import emitLineNumberUpdateCode <EOL> from . ModuleCodes import getModuleAccessCode <EOL> def generateBuiltinImportCode ( to_name , expression , emit , context ) : <EOL> module_name , globals_name , locals_name , import_list_name , level_name = generateExpressionsCode ( <EOL> expressions = ( <EOL> expression . getImportName ( ) , <EOL> expression . getGlobals ( ) , <EOL> expression . getLocals ( ) , <EOL> expression . getFromList ( ) , <EOL> expression . getLevel ( ) <EOL> ) , <EOL> names = ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ) , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> if expression . getGlobals ( ) is None : <EOL> globals_name = context . allocateTempName ( "<STR_LIT>" ) <EOL> getLoadGlobalsCode ( <EOL> to_name = globals_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> if expression . getLocals ( ) is None : <EOL> provider = expression . getParentVariableProvider ( ) <EOL> if provider . isCompiledPythonModule ( ) : <EOL> locals_name = globals_name <EOL> else : <EOL> locals_name = context . allocateTempName ( "<STR_LIT>" ) <EOL> getLoadLocalsCode ( <EOL> to_name = locals_name , <EOL> provider = provider , <EOL> mode = provider . getLocalsMode ( ) , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> getBuiltinImportCode ( <EOL> to_name = to_name , <EOL> module_name = module_name , <EOL> globals_name = globals_name , <EOL> locals_name = locals_name , <EOL> import_list_name = import_list_name , <EOL> level_name = level_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> def getBuiltinImportCode ( to_name , module_name , globals_name , locals_name , <EOL> import_list_name , level_name , emit , context ) : <EOL> emitLineNumberUpdateCode ( emit , context ) <EOL> emit ( <EOL> "<STR_LIT>" % ( <EOL> to_name , <EOL> module_name , <EOL> globals_name , <EOL> locals_name , <EOL> import_list_name , <EOL> level_name <EOL> ) <EOL> ) <EOL> getReleaseCodes ( <EOL> release_names = ( <EOL> module_name , <EOL> globals_name , <EOL> locals_name , <EOL> import_list_name , <EOL> level_name <EOL> ) , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> getErrorExitCode ( <EOL> check_name = to_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> context . addCleanupTempName ( to_name ) <EOL> def generateImportModuleHardCode ( to_name , expression , emit , context ) : <EOL> getImportModuleHardCode ( <EOL> to_name = to_name , <EOL> module_name = expression . getModuleName ( ) , <EOL> import_name = expression . getImportName ( ) , <EOL> needs_check = expression . mayRaiseException ( BaseException ) , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> def getImportModuleHardCode ( to_name , module_name , import_name , needs_check , <EOL> emit , context ) : <EOL> if module_name == "<STR_LIT>" : <EOL> emit ( <EOL> """<STR_LIT>""" % ( <EOL> to_name , <EOL> import_name <EOL> ) <EOL> ) <EOL> elif module_name in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> emit ( <EOL> """<STR_LIT>""" % ( <EOL> to_name , <EOL> module_name , <EOL> import_name <EOL> ) <EOL> ) <EOL> else : <EOL> assert False , module_name <EOL> if needs_check : <EOL> getErrorExitCode ( <EOL> check_name = to_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> def generateImportModuleCode ( to_name , expression , emit , context ) : <EOL> provider = expression . getParentVariableProvider ( ) <EOL> globals_name = context . allocateTempName ( "<STR_LIT>" ) <EOL> getLoadGlobalsCode ( <EOL> to_name = globals_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> if provider . isCompiledPythonModule ( ) : <EOL> locals_name = globals_name <EOL> else : <EOL> locals_name = context . allocateTempName ( "<STR_LIT>" ) <EOL> getLoadLocalsCode ( <EOL> to_name = locals_name , <EOL> provider = expression . getParentVariableProvider ( ) , <EOL> mode = "<STR_LIT>" , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> old_source_ref = context . setCurrentSourceCodeReference ( expression . getSourceReference ( ) ) <EOL> getBuiltinImportCode ( <EOL> to_name = to_name , <EOL> module_name = getConstantCode ( <EOL> constant = expression . getModuleName ( ) , <EOL> context = context <EOL> ) , <EOL> globals_name = globals_name , <EOL> locals_name = locals_name , <EOL> import_list_name = getConstantCode ( <EOL> constant = expression . getImportList ( ) , <EOL> context = context <EOL> ) , <EOL> level_name = getConstantCode ( <EOL> constant = expression . getLevel ( ) , <EOL> context = context <EOL> ) , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> context . setCurrentSourceCodeReference ( old_source_ref ) <EOL> def generateImportStarCode ( statement , emit , context ) : <EOL> module_name = context . allocateTempName ( "<STR_LIT>" ) <EOL> generateImportModuleCode ( <EOL> to_name = module_name , <EOL> expression = statement . getModule ( ) , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> old_source_ref = context . setCurrentSourceCodeReference ( statement . getSourceReference ( ) ) <EOL> res_name = context . getBoolResName ( ) <EOL> if not context . hasLocalsDict ( ) : <EOL> emit ( <EOL> "<STR_LIT>" % ( <EOL> res_name , <EOL> getModuleAccessCode ( <EOL> context = context <EOL> ) , <EOL> module_name <EOL> ) <EOL> ) <EOL> else : <EOL> emit ( <EOL> "<STR_LIT>" % ( <EOL> res_name , <EOL> module_name <EOL> ) <EOL> ) <EOL> getReleaseCode ( <EOL> release_name = module_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> getErrorExitBoolCode ( <EOL> condition = "<STR_LIT>" % res_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> context . setCurrentSourceCodeReference ( old_source_ref ) <EOL> def generateImportNameCode ( to_name , expression , emit , context ) : <EOL> from_arg_name = context . allocateTempName ( "<STR_LIT>" ) <EOL> generateExpressionCode ( <EOL> to_name = from_arg_name , <EOL> expression = expression . getModule ( ) , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> emit ( <EOL> "<STR_LIT>" % ( <EOL> to_name , <EOL> from_arg_name , <EOL> getConstantCode ( <EOL> constant = expression . getImportName ( ) , <EOL> context = context <EOL> ) <EOL> ) <EOL> ) <EOL> getReleaseCode ( <EOL> release_name = from_arg_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> getErrorExitCode ( <EOL> check_name = to_name , <EOL> emit = emit , <EOL> context = context <EOL> ) <EOL> context . addCleanupTempName ( to_name ) </s>
