How to use the nuitka.nodes.VariableRefNodes.ExpressionVariableRef 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 kamilion / customizer / nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
args_variable = result.getVariableForAssignment(
        variable_name = "args"
    )

    star_arg_list_variable = result.getVariableForAssignment(
        variable_name = "star_arg_list"
    )

    star_arg_dict_variable = result.getVariableForAssignment(
        variable_name = "star_arg_dict"
    )

    statements = (
        _makeStarDictArgumentToDictStatement(
            result                        = result,
            called_variable_ref           = ExpressionVariableRef(
                variable_name = "called",
                variable      = called_variable,
                source_ref    = source_ref
            ),
            star_dict_variable_ref        = ExpressionVariableRef(
                variable_name = "star_arg_dict",
                variable      = star_arg_dict_variable,
                source_ref    = source_ref
            ),
            star_dict_target_variable_ref = ExpressionTargetVariableRef(
                variable_name = "star_arg_dict",
                variable      = star_arg_dict_variable,
                source_ref    = source_ref
            )
        ),
        _makeStarListArgumentToTupleStatement(
github Nuitka / Nuitka / nuitka / optimizations / OptimizeBuiltinCalls.py View on Github external
def wrapSuperBuiltin(type_arg, object_arg, source_ref):
        if type_arg is None and python_version >= 300:
            if provider.isCompiledPythonModule():
                return makeRaiseExceptionReplacementExpression(
                    expression=node,
                    exception_type="RuntimeError",
                    exception_value="super(): no arguments",
                )

            class_variable = provider.getVariableForReference(variable_name="__class__")

            provider.trace_collection.getVariableCurrentTrace(class_variable).addUsage()

            type_arg = ExpressionVariableRef(
                # Ought to be already closure taken due to "super" flag in
                # tree building.
                variable=class_variable,
                source_ref=source_ref,
            )

            # If we already have this as a local variable, then use that
            # instead.
            type_arg_owner = type_arg.getVariable().getOwner()
            if type_arg_owner is provider or not (
                type_arg_owner.isExpressionFunctionBody()
                or type_arg_owner.isExpressionClassBody()
            ):
                type_arg = None

            if type_arg is None:
github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
),
            yes_branch=instance_case,
            no_branch=no_branch,
            source_ref=internal_source_ref,
        )

        class_case = StatementReturn(
            expression=makeBinaryOperationNode(
                operator="Add",
                right=makeConstantRefNode(
                    constant=" constructor",
                    source_ref=internal_source_ref,
                    user_provided=True,
                ),
                left=_makeNameAttributeLookup(
                    ExpressionVariableRef(
                        variable=called_variable, source_ref=internal_source_ref
                    )
                ),
                source_ref=internal_source_ref,
            ),
            source_ref=internal_source_ref,
        )

        no_branch = makeStatementConditional(
            condition=ExpressionBuiltinIsinstance(
                instance=ExpressionVariableRef(
                    variable=called_variable, source_ref=internal_source_ref
                ),
                classes=ExpressionBuiltinAnonymousRef(
                    builtin_name="classobj", source_ref=internal_source_ref
                ),
github kamilion / customizer / nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
source_ref    = source_ref
            ),
            star_dict_variable_ref        = ExpressionVariableRef(
                variable_name = "star_arg_dict",
                variable      = star_arg_dict_variable,
                source_ref    = source_ref
            ),
            star_dict_target_variable_ref = ExpressionTargetVariableRef(
                variable_name = "star_arg_dict",
                variable      = star_arg_dict_variable,
                source_ref    = source_ref
            )
        ),
        StatementReturn(
            expression = ExpressionCallKeywordsOnly(
                called     = ExpressionVariableRef(
                    variable_name = "called",
                    variable      = called_variable,
                    source_ref    = source_ref
                ),
                kw         = ExpressionVariableRef(
                    variable_name = "star_arg_dict",
                    variable      = star_arg_dict_variable,
                    source_ref    = source_ref
                ),
                source_ref = source_ref
            ),
            source_ref = source_ref
        )
    )

    result.setBody(
github kamilion / customizer / nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
)
        )
    )

    no_branch = makeStatementsSequenceFromStatement(
        statement = StatementReturn(
            expression = ExpressionOperationBinary(
                operator   = "Add",
                right      = ExpressionConstantRef(
                    constant      = " object",
                    source_ref    = source_ref,
                    user_provided = True
                ),
                left       = makeNameAttributeLookup(
                    ExpressionBuiltinType1(
                        value      = ExpressionVariableRef(
                            variable_name = "called",
                            variable      = called_variable,
                            source_ref    = source_ref
                        ),
                        source_ref = source_ref
                    )
                ),
                source_ref = source_ref
            ),
            source_ref = source_ref
        ),
    )

    if python_version < 300:
        instance_case = makeStatementsSequenceFromStatement(
            statement = StatementReturn(
github kamilion / customizer / nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
called_variable_ref           = ExpressionVariableRef(
                variable_name = "called",
                variable      = called_variable,
                source_ref    = source_ref
            ),
            kw_variable_ref               = ExpressionVariableRef(
                variable_name = "kw",
                variable      = kw_variable,
                source_ref    = source_ref
            ),
            kw_target_variable_ref        = ExpressionTargetVariableRef(
                variable_name = "kw",
                variable      = kw_variable,
                source_ref    = source_ref
            ),
            star_dict_variable_ref        = ExpressionVariableRef(
                variable_name = "star_arg_dict",
                variable      = star_arg_dict_variable,
                source_ref    = source_ref
            )
        ),
        _makeStarListArgumentToTupleStatement(
            called_variable_ref           = ExpressionVariableRef(
                variable_name = "called",
                variable      = called_variable,
                source_ref    = source_ref
            ),
            star_list_variable_ref        = ExpressionVariableRef(
                variable_name = "star_arg_list",
                variable      = star_arg_list_variable,
                source_ref    = source_ref
            ),
github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
),
        source_ref=internal_source_ref,
    )

    if python_version < 300:
        instance_case = StatementReturn(
            expression=makeBinaryOperationNode(
                operator="Add",
                right=makeConstantRefNode(
                    constant=" instance",
                    source_ref=internal_source_ref,
                    user_provided=True,
                ),
                left=_makeNameAttributeLookup(
                    _makeNameAttributeLookup(
                        ExpressionVariableRef(
                            variable=called_variable, source_ref=internal_source_ref
                        ),
                        attribute_name="__class__",
                    )
                ),
                source_ref=internal_source_ref,
            ),
            source_ref=internal_source_ref,
        )

        no_branch = makeStatementConditional(
            condition=ExpressionBuiltinIsinstance(
                instance=ExpressionVariableRef(
                    variable=called_variable, source_ref=internal_source_ref
                ),
                classes=ExpressionBuiltinAnonymousRef(
github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
),
                    right=ExpressionMakeTuple(
                        elements=(
                            ExpressionFunctionCall(
                                function=ExpressionFunctionCreation(
                                    function_ref=ExpressionFunctionRef(
                                        function_body=getCallableNameDescBody(),
                                        source_ref=internal_source_ref,
                                    ),
                                    defaults=(),
                                    kw_defaults=None,
                                    annotations=None,
                                    source_ref=internal_source_ref,
                                ),
                                values=(
                                    ExpressionVariableRef(
                                        variable=called_variable,
                                        source_ref=internal_source_ref,
                                    ),
                                ),
                                source_ref=internal_source_ref,
                            ),
                            _makeNameAttributeLookup(
                                ExpressionBuiltinType1(
                                    value=ExpressionVariableRef(
                                        variable=star_dict_variable,
                                        source_ref=internal_source_ref,
                                    ),
                                    source_ref=internal_source_ref,
                                )
                            ),
                        ),
github kamilion / customizer / nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
source_ref    = source_ref
            ),
            star_dict_variable_ref        = ExpressionVariableRef(
                variable_name = "star_arg_dict",
                variable      = star_arg_dict_variable,
                source_ref    = source_ref
            )
        ),
        StatementReturn(
            expression = ExpressionCall(
                called     = ExpressionVariableRef(
                    variable_name = "called",
                    variable      = called_variable,
                    source_ref    = source_ref
                ),
                args       = ExpressionVariableRef(
                    variable_name = "args",
                    variable      = args_variable,
                    source_ref    = source_ref
                ),
                kw         = ExpressionVariableRef(
                    variable_name = "kw",
                    variable      = kw_variable,
                    source_ref    = source_ref
                ),
                source_ref = source_ref
            ),
            source_ref = source_ref
        )
    )

    result.setBody(
github Nuitka / Nuitka / nuitka / tree / ReformulationClasses3.py View on Github external
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,
            ),
            source_ref=internal_source_ref,
        ),
        StatementAssignmentVariable(
            variable=tmp_result_variable,
            source=makeConstantRefNode(constant=[], source_ref=internal_source_ref),
            source_ref=internal_source_ref,
        ),
        StatementLoop(body=loop_body, source_ref=internal_source_ref),
        StatementReturn(
            expression=ExpressionBuiltinTuple(
                value=ExpressionTempVariableRef(
                    variable=tmp_result_variable, source_ref=internal_source_ref