Exemple #1
0
    def emitTruthCheckCode(cls, to_name, value_name, needs_check, emit,
                           context):
        emit("%s = CHECK_IF_TRUE( %s );" % (to_name, value_name))

        if needs_check:
            getErrorExitBoolCode(condition="%s == -1" % to_name,
                                 needs_check=needs_check,
                                 emit=emit,
                                 context=context)
Exemple #2
0
    def emitTruthCheckCode(cls, to_name, value_name, needs_check, emit, context):
        emit("%s = CHECK_IF_TRUE( %s );" % (to_name, value_name))

        if needs_check:
            getErrorExitBoolCode(
                condition="%s == -1" % to_name,
                needs_check=needs_check,
                emit=emit,
                context=context,
            )
Exemple #3
0
    def emitAssignmentCodeToNuitkaBool(cls, to_name, value_name, needs_check,
                                       emit, context):
        truth_name = context.allocateTempName("truth_name", "int")

        emit("%s = CHECK_IF_TRUE(%s);" % (truth_name, value_name))

        getErrorExitBoolCode(
            condition="%s == -1" % truth_name,
            needs_check=needs_check,
            emit=emit,
            context=context,
        )

        emit("%s = %s == 0 ? NUITKA_BOOL_FALSE : NUITKA_BOOL_TRUE;" %
             (to_name, truth_name))
Exemple #4
0
    def emitAssignmentCodeToNuitkaBool(cls, to_name, value_name, needs_check,
                                       emit, context):
        if needs_check:
            truth_name = context.allocateTempName("truth_name", "int")

            emit("%s = CHECK_IF_TRUE( %s );" % (truth_name, value_name))

            getErrorExitBoolCode(condition="%s == -1" % truth_name,
                                 emit=emit,
                                 context=context,
                                 needs_check=True)

            emit("%s = %s == 1 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;" %
                 (to_name, truth_name))
        else:
            cls.emitAssignmentCodeFromBoolCondition(to_name=to_name,
                                                    condition="%s == 1",
                                                    emit=emit)
Exemple #5
0
    def emitAssignmentCodeToNuitkaBool(
        cls, to_name, value_name, needs_check, emit, context
    ):
        truth_name = context.allocateTempName("truth_name", "int")

        emit("%s = CHECK_IF_TRUE( %s );" % (truth_name, value_name))

        getErrorExitBoolCode(
            condition="%s == -1" % truth_name,
            needs_check=needs_check,
            emit=emit,
            context=context,
        )

        emit(
            "%s = %s == 1 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;"
            % (to_name, truth_name)
        )