def generateMakeGeneratorObjectCode(to_name, expression, emit, context):
    generator_object_body = expression.getGeneratorRef().getFunctionBody()

    closure_variables = generator_object_body.getClosureVariables()

    if python_version < 350 or context.isForDirectCall():
        generator_name_obj = getConstantCode(
            constant = generator_object_body.getFunctionName(),
            context  = context
        )
    else:
        generator_name_obj = "self->m_name"

    if python_version < 350:
        generator_qualname_obj = "NULL"
    elif not context.isForDirectCall():
        generator_qualname_obj = "self->m_qualname"
    else:
        generator_qualname_obj = getConstantCode(
            constant = generator_object_body.getFunctionQualname(),
            context  = context
        )

    code_identifier = context.getCodeObjectHandle(
        code_object  = expression.getCodeObject(),
        filename     = generator_object_body.getParentModule().getRunTimeFilename(),
        line_number  = generator_object_body.getSourceReference().getLineNumber(),
        is_optimized = True,
        new_locals   = not generator_object_body.needsLocalsDict(),
        has_closure  = len(closure_variables) > 0,
        future_flags = generator_object_body.getSourceReference().getFutureSpec().asFlags()
    )

    if closure_variables:
        closure_copy = []

        for count, variable in enumerate(closure_variables):
            variable_code = getVariableCode(
                context  = context,
                variable = variable
            )

            # Generators might not use them, but they still need to be put there.
            # TODO: But they don't have to be cells.
            if not variable.isSharedTechnically():
                closure_copy.append(
                    "closure[%d] = PyCell_NEW0( %s );" % (
                        count,
                        variable_code
                    )
                )
            else:
                closure_copy.append(
                    "closure[%d] = %s;" % (
                        count,
                        variable_code
                    )
                )
                closure_copy.append(
                    "Py_INCREF( closure[%d] );" % count
                )

        closure_making = template_function_closure_making % {
            "closure_copy"  : indented(closure_copy),
            "closure_count" : len(closure_variables)
        }

        emit(
            template_generator_making_with_context % {
                "closure_making"         : closure_making,
                "to_name"                : to_name,
                "generator_identifier"   : generator_object_body.getCodeName(),
                "generator_name_obj"     : generator_name_obj,
                "generator_qualname_obj" : generator_qualname_obj,
                "code_identifier"        : code_identifier,
                "closure_count"          : len(closure_variables)
            }
        )
    else:
        emit(
            template_generator_making_without_context % {
                "to_name"                : to_name,
                "generator_identifier"   : generator_object_body.getCodeName(),
                "generator_name_obj"     : generator_name_obj,
                "generator_qualname_obj" : generator_qualname_obj,
                "code_identifier"        : code_identifier
            }
        )

    context.addCleanupTempName(to_name)
dataset/ETHPy150Open kayhayen/Nuitka/nuitka/codegen/GeneratorCodes.py/generateMakeGeneratorObjectCode/original