How to use the nuitka.nodes.AssignNodes.StatementReleaseVariable function in Nuitka

To help you get started, we’ve selected a few Nuitka examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nuitka / Nuitka / nuitka / tree / ReformulationAssignmentStatements.py View on Github external
source=ExpressionTempVariableRef(
                variable=tmp_variable2, source_ref=source_ref
            ),
            source_ref=source_ref,
        ),
        final=StatementReleaseVariable(variable=tmp_variable2, source_ref=source_ref),
        source_ref=source_ref,
    )

    return (
        preserve_to_tmp,
        # making sure the above temporary variable is deleted in any case.
        makeTryFinallyStatement(
            provider=provider,
            tried=(inplace_to_tmp, copy_back_from_tmp),
            final=StatementReleaseVariable(
                variable=tmp_variable1, source_ref=source_ref
            ),
            source_ref=source_ref,
        ),
github Nuitka / Nuitka / nuitka / tree / ReformulationComparisonExpressions.py View on Github external
if value is not rights[-1]:
            statements.extend(makeValueComparisonReturn(left, right, comparator))
        else:
            statements.append(
                StatementReturn(
                    expression=_makeComparisonNode(
                        left=left,
                        right=right,
                        comparator=comparator,
                        source_ref=source_ref,
                    ),
                    source_ref=source_ref,
                )
            )
            final.append(
                StatementReleaseVariable(variable=tmp_variable, source_ref=source_ref)
            )

    outline_body.setBody(
        makeStatementsSequenceFromStatement(
            statement=makeTryFinallyStatement(
                provider=outline_body,
                tried=statements,
                final=final,
                source_ref=source_ref,
            )
        )
    )

    return outline_body
github Nuitka / Nuitka / nuitka / tree / ReformulationComparisonExpressions.py View on Github external
def makeReleaseStatement(count):
        return StatementReleaseVariable(
            variable=variables[count], source_ref=source_ref
        )
github Nuitka / Nuitka / nuitka / tree / ReformulationSequenceCreation.py View on Github external
list_arg=ExpressionTempVariableRef(
                    variable=tmp_result_variable, source_ref=internal_source_ref
                ),
                value=ExpressionTempVariableRef(
                    variable=tmp_item_variable, source_ref=internal_source_ref
                ),
                source_ref=internal_source_ref,
            ),
            source_ref=internal_source_ref,
        ),
    )

    args_variable = result.getVariableForAssignment(variable_name="args")

    final = (
        StatementReleaseVariable(
            variable=tmp_result_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_iter_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_item_variable, source_ref=internal_source_ref
        ),
    )

    tried = makeStatementsSequenceFromStatements(
        StatementAssignmentVariable(
            variable=tmp_iter_variable,
            source=ExpressionBuiltinIter1(
                value=ExpressionVariableRef(
                    variable=args_variable, source_ref=internal_source_ref
github Nuitka / Nuitka / nuitka / tree / ReformulationImportStatements.py View on Github external
import_name = import_name,
                        level       = level,
                        source_ref  = source_ref
                    ),
                    source_ref    = source_ref
                )
            )

        # Release the temporary module value as well.
        if multi_names:
            statements.append(
                makeTryFinallyStatement(
                    provider   = provider,
                    tried      = import_statements,
                    final      = (
                        StatementReleaseVariable(
                            variable   = tmp_import_from,
                            source_ref = source_ref
                        ),
                    ),
                    source_ref = source_ref
                )
            )
        else:
            statements.extend(import_statements)

        # Note: Each import is sequential. It can succeed, and the failure of a
        # later one is not undoing previous ones. We can therefore have a
        # sequence of imports that each only import one thing therefore.
        return StatementsSequence(
            statements = mergeStatements(statements),
            source_ref = source_ref
github Nuitka / Nuitka / nuitka / tree / ReformulationForLoopStatements.py View on Github external
constant   = True,
                        source_ref = source_ref
                    ),
                    source_ref = source_ref
                ),
                yes_branch = else_block,
                no_branch  = None,
                source_ref = source_ref
            )
        ]

        statements = (
            makeTryFinallyStatement(
                provider   = provider,
                tried      = statements,
                final      = StatementReleaseVariable(
                    variable   = tmp_break_indicator,
                    source_ref = source_ref
                ),
                source_ref = source_ref
            ),
        )

    return makeStatementsSequenceFromStatements(
        *statements
    )
github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
def _makeStarDictArgumentMergeToKwStatement(
    result, called_variable, kw_variable, star_dict_variable
):
    # This is plain terribly complex, pylint: disable=too-many-locals
    temp_scope = result.allocateTempScope("dict")

    tmp_dict_variable = result.allocateTempVariable(temp_scope, "dict")
    tmp_iter_variable = result.allocateTempVariable(temp_scope, "iter")
    tmp_keys_variable = result.allocateTempVariable(temp_scope, "keys")
    tmp_key_variable = result.allocateTempVariable(temp_scope, "key_xxx")

    final = [
        StatementReleaseVariable(
            variable=tmp_dict_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_iter_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_keys_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_key_variable, source_ref=internal_source_ref
        ),
    ]

    mapping_loop_body = (
        makeStatementConditional(
            condition=ExpressionComparisonIn(
github Nuitka / Nuitka / nuitka / tree / ReformulationAssignmentStatements.py View on Github external
for target in node.targets:
            statements.append(
                buildAssignmentStatements(
                    provider=provider,
                    node=target,
                    source=ExpressionTempVariableRef(
                        variable=tmp_source, source_ref=source_ref
                    ),
                    source_ref=source_ref,
                )
            )

        return makeTryFinallyStatement(
            provider=provider,
            tried=statements,
            final=StatementReleaseVariable(variable=tmp_source, source_ref=source_ref),
            source_ref=source_ref,
        )
github Nuitka / Nuitka / nuitka / tree / ReformulationSequenceCreation.py View on Github external
value=ExpressionTempVariableRef(
                    variable=tmp_item_variable, source_ref=internal_source_ref
                ),
                source_ref=internal_source_ref,
            ),
            source_ref=internal_source_ref,
        ),
    )

    args_variable = result.getVariableForAssignment(variable_name="args")

    final = (
        StatementReleaseVariable(
            variable=tmp_result_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_iter_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_item_variable, source_ref=internal_source_ref
        ),
    )

    tried = makeStatementsSequenceFromStatements(
        StatementAssignmentVariable(
            variable=tmp_iter_variable,
            source=ExpressionBuiltinIter1(
                value=ExpressionVariableRef(
                    variable=args_variable, source_ref=internal_source_ref
                ),
                source_ref=internal_source_ref,
            ),
github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
),
                args=ExpressionVariableRef(
                    variable=star_arg_list_variable, source_ref=internal_source_ref
                ),
                kw=None,
                source_ref=internal_source_ref,
            ),
            source_ref=internal_source_ref,
        ),
    )

    final = (
        StatementReleaseVariable(
            variable=called_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=star_arg_list_variable, source_ref=internal_source_ref
        ),
    )

    result.setBody(
        makeStatementsSequenceFromStatement(
            makeTryFinallyStatement(
                provider=result,
                tried=statements,
                final=final,
                source_ref=internal_source_ref,
            )
        )
    )

    return result