Exemplo n.º 1
0
    def getVariableObjectAccessCode(cls, to_name, needs_check,
                                    variable_code_name, variable, emit,
                                    context):
        template = template_read_local

        emit(
            template % {
                "tmp_name":
                to_name,
                "identifier":
                cls.getLocalVariableObjectAccessCode(variable_code_name)
            })

        if needs_check:
            if variable.getOwner() is not context.getOwner():
                getErrorFormatExitCode(check_name=to_name,
                                       exception="PyExc_NameError",
                                       args=("""\
free variable '%s' referenced before assignment in enclosing scope""",
                                             variable.getName()),
                                       emit=emit,
                                       context=context)
            else:
                getErrorFormatExitCode(check_name=to_name,
                                       exception="PyExc_UnboundLocalError",
                                       args=("""\
local variable '%s' referenced before assignment""", variable.getName()),
                                       emit=emit,
                                       context=context)
        else:
            getCheckObjectCode(check_name=to_name, emit=emit)
Exemplo n.º 2
0
    def getVariableObjectAccessCode(cls, to_name, needs_check,
                                    variable_code_name, variable, emit,
                                    context):
        template = template_read_shared_unclear

        emit(template % {
            "tmp_name": to_name,
            "identifier": variable_code_name
        })

        if needs_check:
            getLocalVariableReferenceErrorCode(variable=variable,
                                               condition="%s == NULL" %
                                               to_name,
                                               emit=emit,
                                               context=context)
        else:
            getCheckObjectCode(check_name=to_name, emit=emit)
Exemplo n.º 3
0
 def emitValueAssertionCode(cls, value_name, emit, context):
     # Not using the context, pylint: disable=unused-argument
     getCheckObjectCode(check_name=value_name, emit=emit)
Exemplo n.º 4
0
 def emitValueAssertionCode(cls, value_name, emit, context):
     # Not using the context, pylint: disable=unused-argument
     getCheckObjectCode(check_name=value_name, emit=emit)