#NEWLINE# def generateFunctionCreationCode( to_name , expression , emit , context ) : #NEWLINE# #INDENT# function_body = expression . getFunctionRef ( ) . getFunctionBody ( ) #NEWLINE# code_object = expression . getCodeObject ( ) #NEWLINE# defaults = expression . getDefaults ( ) #NEWLINE# kw_defaults = expression . getKwDefaults ( ) #NEWLINE# annotations = expression . getAnnotations ( ) #NEWLINE# defaults_first = ( not expression . kw_defaults_before_defaults ) #NEWLINE# assert function_body . needsCreation ( ) , function_body #NEWLINE# def handleKwDefaults( ) : #NEWLINE# #INDENT# if kw_defaults : #NEWLINE# #INDENT# kw_defaults_name = context . allocateTempName ( 'kw_defaults' ) #NEWLINE# assert ( ( not kw_defaults . isExpressionConstantRef ( ) ) or ( kw_defaults . getConstant ( ) != { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) , kw_defaults . getConstant ( ) #NEWLINE# generateExpressionCode ( to_name = kw_defaults_name , expression = kw_defaults , emit = emit , context = context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kw_defaults_name = None #NEWLINE# #UNINDENT# return kw_defaults_name #NEWLINE# #UNINDENT# def handleDefaults( ) : #NEWLINE# #INDENT# if defaults : #NEWLINE# #INDENT# defaults_name = context . allocateTempName ( 'defaults' ) #NEWLINE# getTupleCreationCode ( to_name = defaults_name , elements = defaults , emit = emit , context = context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# defaults_name = None #NEWLINE# #UNINDENT# return defaults_name #NEWLINE# #UNINDENT# if defaults_first : #NEWLINE# #INDENT# defaults_name = handleDefaults ( ) #NEWLINE# kw_defaults_name = handleKwDefaults ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kw_defaults_name = handleKwDefaults ( ) #NEWLINE# defaults_name = handleDefaults ( ) #NEWLINE# #UNINDENT# if annotations : #NEWLINE# #INDENT# annotations_name = context . allocateTempName ( 'annotations' ) #NEWLINE# generateExpressionCode ( to_name = annotations_name , expression = annotations , emit = emit , context = context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# annotations_name = None #NEWLINE# #UNINDENT# function_identifier = function_body . getCodeName ( ) #NEWLINE# if ( not context . hasHelperCode ( function_identifier ) ) : #NEWLINE# #INDENT# code_identifier = context . getCodeObjectHandle ( code_object = code_object , filename = function_body . getParentModule ( ) . getRunTimeFilename ( ) , line_number = function_body . getSourceReference ( ) . getLineNumber ( ) , is_optimized = ( not function_body . needsLocalsDict ( ) ) , new_locals = True , has_closure = ( function_body . getClosureVariables ( ) != ( ) ) , future_flags = function_body . getSourceReference ( ) . getFutureSpec ( ) . asFlags ( ) ) #NEWLINE# maker_code = getFunctionMakerCode ( function_name = function_body . getFunctionName ( ) , function_qualname = function_body . getFunctionQualname ( ) , function_identifier = function_identifier , code_identifier = kw_defaults , closure_variables = function_body . getClosureVariables ( ) , defaults_name = defaults_name , kw_defaults_name = kw_defaults_name , annotations_name = annotations_name , function_doc = function_body . getDoc ( ) , context = context ) #NEWLINE# context . addHelperCode ( function_identifier , maker_code ) #NEWLINE# function_decl = getFunctionMakerDecl ( function_identifier = function_body . getCodeName ( ) , defaults_name = defaults_name , kw_defaults_name = kw_defaults_name , annotations_name = annotations_name , closure_variables = function_body . getClosureVariables ( ) ) #NEWLINE# context . addDeclaration ( function_identifier , function_decl ) #NEWLINE# #UNINDENT# getFunctionCreationCode ( to_name = to_name , function_identifier = function_body . getCodeName ( ) , defaults_name = defaults_name , kw_defaults_name = kw_defaults_name , annotations_name = annotations_name , closure_variables = function_body . getClosureVariables ( ) , emit = emit , context = context ) #NEWLINE# getReleaseCode ( release_name = annotations_name , emit = emit , context = context )