⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 infer.cxx

📁 Intel XScale PXA255 引导Linux的Redboot 版bootloader源代码!
💻 CXX
📖 第 1 页 / 共 4 页
字号:
    if (constant.get_value() == goal.get_value()) {        result = true;    }    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  infer_handle_integer_constant()          // ----------------------------------------------------------------------------// Integers are also fairly straightforward.static boolinfer_handle_integer_constant_bool(CdlSimpleValue& constant, bool goal){    CYG_REPORT_FUNCNAMETYPE("infer_handle_integer_constant_bool", "result %d");    CYG_PRECONDITIONC(constant.has_integer_value());    bool result = false;    if (goal) {        if (0 != constant.get_integer_value()) {            result = true;        }    } else {        if (0 == constant.get_integer_value()) {            result = true;        }    }        CYG_REPORT_RETVAL(result);    return result;}static boolinfer_handle_integer_constant_value(CdlSimpleValue& constant, CdlSimpleValue& goal){    CYG_REPORT_FUNCNAMETYPE("infer_handle_integer_constant_value", "result %d");    CYG_PRECONDITIONC(constant.has_integer_value());    bool result = false;    if (goal.has_integer_value() && (constant.get_integer_value() == goal.get_integer_value())) {        result = true;    }    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  infer_handle_double_constant()           // ----------------------------------------------------------------------------// Doubles are also straightforward, except than an exact comparision may// be too strict. There is not a lot that can be done about this right now.// Future enhancements to CDL may support tolerances.static boolinfer_handle_double_constant_bool(CdlSimpleValue& constant, bool goal){    CYG_REPORT_FUNCNAMETYPE("infer_handle_double_constant_bool", "result %d");    CYG_PRECONDITIONC(constant.has_double_value());    bool result = false;    if (goal) {        if (0.0 != constant.get_double_value()) {            result = true;        }    } else {        if (0.0 == constant.get_double_value()) {            result = true;        }    }    CYG_REPORT_RETVAL(result);    return result;}static boolinfer_handle_double_constant_value(CdlSimpleValue& constant, CdlSimpleValue& goal){    CYG_REPORT_FUNCNAMETYPE("infer_handle_double_constant_value", "result %d");    CYG_PRECONDITIONC(constant.has_double_value());    bool result = false;    if (goal.has_double_value() && (constant.get_double_value() == goal.get_double_value())) {        result = true;    }    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  infer_handle_logical_NOT()               // ----------------------------------------------------------------------------// Logical not simply involves inverting the goal and then trying to infer// the rest of the sub-expression. There is little point in touching// the other arguments.static boolinfer_handle_logical_NOT_bool(CdlTransaction transaction, CdlExpression expr, unsigned int index, bool goal, int level){    CYG_REPORT_FUNCNAMETYPE("infer_handle_logical_NOT_bool", "result %d");    bool result = infer_subexpr_bool(transaction, expr, index, !goal, level);    CYG_REPORT_RETVAL(result);    return result;}static boolinfer_handle_logical_NOT_value(CdlTransaction transaction, CdlExpression expr, unsigned int index,                               CdlSimpleValue& goal, int level){    CYG_REPORT_FUNCNAMETYPE("infer_handle_logical_NOT_value", "result %d");    bool new_goal = false;    if (("0" == goal.get_value()) || ("" == goal.get_value())) {        new_goal = true;    }    bool result = infer_subexpr_bool(transaction, expr, index, new_goal, level);    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  infer_handle_AND()                       // ----------------------------------------------------------------------------// Depending on the goal, we want either both sides of the AND to evaluate to// true, or we want one of the sides to evaluate to false.static boolinfer_handle_AND_bool(CdlTransaction transaction, CdlExpression expr, unsigned int lhs, unsigned int rhs,                      bool goal, int level){    CYG_REPORT_FUNCNAMETYPE("infer_handle_AND_bool", "result %d");    CYG_REPORT_FUNCARG4XV(transaction, expr, lhs, rhs);    CYG_PRECONDITION_CLASSC(transaction);    CYG_PRECONDITION_CLASSC(expr);    CYG_PRECONDITIONC(lhs != rhs);    bool result = false;        if (goal) {        // Both sides must be true in the same transaction, in case        // the solutions overlap in conflicting ways.        // NOTE: this leaves the transaction argument in an indeterminate        // state. Care has to be taken in the calling code.        if (infer_subexpr_bool(transaction, expr, lhs, true, level) &&            infer_subexpr_bool(transaction, expr, rhs, true, level)) {            result = true;        }    } else {        // We need to try out both sides of the OR and see which one is preferable.        // An optimization would be to only try the LHS, but trying both allows        // for a more informed choice.        CdlTransaction lhs_transaction = transaction->make(transaction->get_conflict());        CdlTransaction rhs_transaction = transaction->make(transaction->get_conflict());        bool lhs_result = infer_subexpr_bool(lhs_transaction, expr, lhs, false, level);        bool rhs_result = infer_subexpr_bool(rhs_transaction, expr, rhs, false, level);        if (lhs_result && !rhs_result) {            // Only the lhs succeeded.            rhs_transaction->cancel();            lhs_transaction->commit();            result = true;        } else if (!lhs_result && rhs_result) {            // Only the rhs succeeded.            lhs_transaction->cancel();            rhs_transaction->commit();            result = true;        } else if (lhs_result && rhs_result) {            // Both sides succeeded. Next check for user_confirmation.            bool lhs_confirm_needed = lhs_transaction->user_confirmation_required();            bool rhs_confirm_needed = rhs_transaction->user_confirmation_required();            if (lhs_confirm_needed && !rhs_confirm_needed) {                lhs_transaction->cancel();                rhs_transaction->commit();                result = true;            } else if (!lhs_confirm_needed && rhs_confirm_needed) {                rhs_transaction->cancel();                lhs_transaction->commit();                result = true;            } else {                // Neither or both of the two sides need user confirmation, so they                // are equal in that respect                if (lhs_transaction->is_preferable_to(rhs_transaction)) {                    rhs_transaction->cancel();                    lhs_transaction->commit();                    result = true;                } else {                    lhs_transaction->cancel();                    rhs_transaction->commit();                    result = true;                }            }        } else {            // Neither side succeeded.            lhs_transaction->cancel();            rhs_transaction->cancel();        }        // Zero or one of these transactions will have been committed,        // neither is still necessary.        delete lhs_transaction;        delete rhs_transaction;    }    CYG_REPORT_RETVAL(result);    return result;}static boolinfer_handle_AND_value(CdlTransaction transaction, CdlExpression expr, unsigned int lhs, unsigned int rhs,                       CdlSimpleValue& goal, int level){    CYG_REPORT_FUNCNAMETYPE("infer_handle_AND_value", "result %d");    bool new_goal = true;    if (("0" == goal.get_value()) || ("" == goal.get_value())) {        new_goal = false;    }    bool result = infer_handle_AND_bool(transaction, expr, lhs, rhs, new_goal, level);    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  infer_handle_OR()                        // ----------------------------------------------------------------------------// The support for OR logic is much the same as for ANDstatic boolinfer_handle_OR_bool(CdlTransaction transaction, CdlExpression expr, unsigned int lhs, unsigned int rhs,                     bool goal, int level){    CYG_REPORT_FUNCNAMETYPE("infer_handle_OR_bool", "result %d");    CYG_REPORT_FUNCARG4XV(transaction, expr, lhs, rhs);    CYG_PRECONDITION_CLASSC(transaction);    CYG_PRECONDITION_CLASSC(expr);    CYG_PRECONDITIONC(lhs != rhs);    bool result = false;        if (goal) {        // We need to try out both sides of the OR and see which one is preferable.        // An optimization would be to only try the LHS, but trying both allows        // for a more informed choice.        CdlTransaction lhs_transaction = transaction->make(transaction->get_conflict());        CdlTransaction rhs_transaction = transaction->make(transaction->get_conflict());        bool lhs_result = infer_subexpr_bool(lhs_transaction, expr, lhs, true, level);        bool rhs_result = infer_subexpr_bool(rhs_transaction, expr, rhs, true, level);        if (lhs_result && !rhs_result) {            // Only the lhs succeeded.            rhs_transaction->cancel();            lhs_transaction->commit();            result = true;        } else if (!lhs_result && rhs_result) {            // Only the rhs succeeded.            lhs_transaction->cancel();            rhs_transaction->commit();            result = true;        } else if (lhs_result && rhs_result) {            // Both sides succeeded. Next check for user_confirmation.            bool lhs_confirm_needed = lhs_transaction->user_confirmation_required();            bool rhs_confirm_needed = rhs_transaction->user_confirmation_required();            if (lhs_confirm_needed && !rhs_confirm_needed) {                lhs_transaction->cancel();                rhs_transaction->commit();                result = true;            } else if (!lhs_confirm_needed && rhs_confirm_needed) {                rhs_transaction->cancel();                lhs_transaction->commit();                result = true;            } else {                // Neither or both of the two sides need user confirmation, so they                // are equal in that respect                if (lhs_transaction->is_preferable_to(rhs_transaction)) {                    rhs_transaction->cancel();                    lhs_transaction->commit();                    result = true;                } else {                    lhs_transaction->cancel();                    rhs_transaction->commit();                    result = true;                }            }        } else {            // Neither side succeeded            lhs_transaction->cancel();            rhs_transaction->cancel();        }                // Zero or one of these transactions will have been committed,        // neither is still necessary.        delete lhs_transaction;        delete rhs_transaction;    } else {                // !(A || B) -> !A && !B        if (infer_subexpr_bool(transaction, expr, lhs, false, level) &&            infer_subexpr_bool(transaction, expr, rhs, false, level)) {            result = true;        }    }        CYG_REPORT_RETVAL(result);    return result;}static boolinfer_handle_OR_value(CdlTransaction transaction, CdlExpression expr, unsigned int lhs, unsigned int rhs,                CdlSimpleValue& goal, int level){    CYG_REPORT_FUNCNAMETYPE("infer_handle_OR_value", "result %d");    bool new_goal = true;    if (("0" == goal.get_value()) || ("" == goal.get_value())) {        new_goal = false;    }    bool result = infer_handle_OR_bool(transaction, expr, lhs, rhs, new_goal, level);    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  infer_handle_Equal()                     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -