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

📄 func.cxx

📁 ecos实时嵌入式操作系统
💻 CXX
📖 第 1 页 / 共 3 页
字号:
    CYG_REPORT_FUNCNAME("is_active_eval");    CYG_REPORT_FUNCARG4XV(&context, expr, &subexpr, &result);    CYG_PRECONDITION_CLASSOC(context);    CYG_PRECONDITION_CLASSC(expr);    CdlSubexpression arg0 = expr->sub_expressions[subexpr.args[0]];    CYG_ASSERTC(CdlExprOp_Reference == arg0.op);    CdlNode node = context.resolve_reference(expr, arg0.reference_index);    if (0 != node) {        result = node->is_active(context.transaction);    } else {        result = false;    }    CYG_REPORT_RETURN();}static boolis_active_infer_bool(CdlTransaction transaction, CdlExpression expr, unsigned int index, bool goal, int level){    CYG_REPORT_FUNCNAMETYPE("is_active_infer_bool", "result %d");    CYG_REPORT_FUNCARG5XV(transaction, expr, index, goal, level);    bool result = false;    CdlSubexpression subexpr    = expr->sub_expressions[index];    CdlSubexpression arg0       = expr->sub_expressions[subexpr.args[0]];    CYG_ASSERTC(CdlExprOp_Reference == arg0.op);    CdlNode node = expr->references[arg0.reference_index].get_destination();    if (0 != node) {        if (goal) {            result = CdlInfer::make_active(transaction, node, level);        } else {            result = CdlInfer::make_inactive(transaction, node, level);        }    }        CYG_REPORT_RETVAL(result);    return result;}static CdlFunction is_active("is_active", 1, &is_active_check, &is_active_eval,                             &is_active_infer_bool, CdlFunction::null_infer_value);//}}}//{{{  is_enabled()                     // ----------------------------------------------------------------------------// is_enabled(x)// Check whether or not a particular configuration option is loaded// and enabled. The active/inactive state is ignored. This function// takes a single argument which must be a reference.static voidis_enabled_check(CdlExpression expr, const CdlSubexpression& subexpr){    CYG_REPORT_FUNCNAME("is_enabled_check");    CYG_REPORT_FUNCARG2XV(expr, &subexpr);    CdlSubexpression& arg0 = expr->sub_expressions[subexpr.args[0]];    if (CdlExprOp_Reference != arg0.op) {        throw CdlParseException(std::string("The argument to is_enabled() should be a reference to a configuration option.\n") +                                CdlParse::get_expression_error_location());    }        CYG_REPORT_RETURN();}static voidis_enabled_eval(CdlEvalContext& context, CdlExpression expr, const CdlSubexpression& subexpr, CdlSimpleValue& result){    CYG_REPORT_FUNCNAME("is_enabled_eval");    CYG_REPORT_FUNCARG4XV(&context, expr, &subexpr, &result);    CYG_PRECONDITION_CLASSOC(context);    CYG_PRECONDITION_CLASSC(expr);    CdlSubexpression arg0 = expr->sub_expressions[subexpr.args[0]];    CYG_ASSERTC(CdlExprOp_Reference == arg0.op);    CdlValuable valuable = context.resolve_valuable_reference(expr, arg0.reference_index);    if (0 != valuable) {        if (0 != context.transaction) {            result = valuable->is_enabled(context.transaction);        } else {            result = valuable->is_enabled();        }    } else {        result = false;    }    CYG_REPORT_RETURN();}static boolis_enabled_infer_bool(CdlTransaction transaction, CdlExpression expr, unsigned int index, bool goal, int level){    CYG_REPORT_FUNCNAMETYPE("is_enabled_infer_bool", "result %d");    CYG_REPORT_FUNCARG5XV(transaction, expr, index, goal, level);    bool result = false;    CdlSubexpression subexpr    = expr->sub_expressions[index];    CdlSubexpression arg0       = expr->sub_expressions[subexpr.args[0]];    CYG_ASSERTC(CdlExprOp_Reference == arg0.op);    CdlNode node = expr->references[arg0.reference_index].get_destination();    if (0 != node) {        CdlValuable valuable    = dynamic_cast<CdlValuable>(node);        if (0 != valuable) {            // OK, we have found a valuable. Is it already enabled?            // Does it have a boolean component? Is it modifiable? Has            // it already been modified by the user in this transaction?            if (goal == valuable->is_enabled()) {                result = true;            } else {                CdlValueFlavor flavor = valuable->get_flavor();                if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) {                    if (valuable->is_modifiable()) {                        if (!transaction->changed_by_user(valuable)) {                            // We have a modifiable option and want to set the enabled flag.                            // However we do not want to lose the current data part - unless                            // some other constraint has caused that to be set.                            const CdlValue& old_value   = transaction->get_whole_value(valuable);                            CdlValue        new_value   = old_value;                            if (!old_value.has_source(CdlValueSource_Inferred)) {                                CdlSimpleValue simple_value = old_value.get_simple_value(CdlValueSource_Current);                                new_value.set_value(simple_value, CdlValueSource_Inferred);                            }                            new_value.set_enabled(goal, CdlValueSource_Inferred);                            new_value.set_source(CdlValueSource_Inferred);                            transaction->set_whole_value(valuable, old_value, new_value);                            result = transaction->resolve_recursion(level);                        }                    }                }            }        }    }        CYG_REPORT_RETVAL(result);    return result;}static CdlFunction is_enabled("is_enabled", 1, &is_enabled_check, &is_enabled_eval,                              &is_enabled_infer_bool, CdlFunction::null_infer_value);//}}}//{{{  get_data()                       // ----------------------------------------------------------------------------// get_data(x)// Returns "0" if the specified option is not enabled, otherwise// the current data part fo the value. The active/inactive and the// enabled states are ignored. This function takes a single argument// which must be a reference.static voidget_data_check(CdlExpression expr, const CdlSubexpression& subexpr){    CYG_REPORT_FUNCNAME("get_data_check");    CYG_REPORT_FUNCARG2XV(expr, &subexpr);    CdlSubexpression& arg0 = expr->sub_expressions[subexpr.args[0]];    if (CdlExprOp_Reference != arg0.op) {        throw CdlParseException(std::string("The argument to get_data() should be a reference to a configuration option.\n") +                                CdlParse::get_expression_error_location());    }        CYG_REPORT_RETURN();}static voidget_data_eval(CdlEvalContext& context, CdlExpression expr, const CdlSubexpression& subexpr, CdlSimpleValue& result){    CYG_REPORT_FUNCNAME("get_data_eval");    CYG_REPORT_FUNCARG4XV(&context, expr, &subexpr, &result);    CYG_PRECONDITION_CLASSOC(context);    CYG_PRECONDITION_CLASSC(expr);    CdlSubexpression arg0 = expr->sub_expressions[subexpr.args[0]];    CYG_ASSERTC(CdlExprOp_Reference == arg0.op);    CdlValuable valuable = context.resolve_valuable_reference(expr, arg0.reference_index);    if (0 != valuable) {        if (0 != context.transaction) {            result = valuable->get_value(context.transaction);        } else {            result = valuable->get_value();        }    } else {        result = false;    }    CYG_REPORT_RETURN();}static boolget_data_infer_value(CdlTransaction transaction, CdlExpression expr, unsigned int index,  CdlSimpleValue& goal, int level){    CYG_REPORT_FUNCNAMETYPE("get_data_infer_value", "result %d");    CYG_REPORT_FUNCARG5XV(transaction, expr, index, &goal, level);    bool result = false;    CdlSubexpression subexpr    = expr->sub_expressions[index];    CdlSubexpression arg0       = expr->sub_expressions[subexpr.args[0]];    CYG_ASSERTC(CdlExprOp_Reference == arg0.op);    CdlNode node = expr->references[arg0.reference_index].get_destination();    if (0 != node) {        CdlValuable valuable    = dynamic_cast<CdlValuable>(node);        if (0 != valuable) {            // OK, we have found a valuable. Does it have a data component?            // Does it already have the right value. Is it modifiable? Has            // it already been modified by the user in this transaction?            CdlValueFlavor flavor = valuable->get_flavor();            if ((CdlValueFlavor_Data == flavor) || (CdlValueFlavor_BoolData == flavor)) {                CdlSimpleValue current_value = valuable->get_simple_value(transaction);                if (goal != current_value) {                    if (valuable->is_modifiable()) {                        if (!transaction->changed_by_user(valuable)) {                            // We have a modifiable option and want to set the data part.                            // However we do not want to lose the enabled part - unless                            // some other constraint has caused that to be set.                            const CdlValue& old_value   = transaction->get_whole_value(valuable);                            CdlValue        new_value   = old_value;                            if (!old_value.has_source(CdlValueSource_Inferred)) {                                new_value.set_enabled(old_value.is_enabled(), CdlValueSource_Inferred);                            }                            new_value.set_value(goal, CdlValueSource_Inferred);                            new_value.set_source(CdlValueSource_Inferred);                            transaction->set_whole_value(valuable, old_value, new_value);                            result = transaction->resolve_recursion(level);                        }                    }                }            }        }    }        CYG_REPORT_RETVAL(result);    return result;}static CdlFunction get_data("get_data", 1, &get_data_check, &get_data_eval,                            CdlFunction::null_infer_bool, &get_data_infer_value);//}}}//{{{  version_cmp()                    // ----------------------------------------------------------------------------// version_cmp(a, b)// Evaluate both arguments, interpret them as version strings, and then// return -1, 0 or 1.static voidversion_cmp_eval(CdlEvalContext& context, CdlExpression expr, const CdlSubexpression& subexpr, CdlSimpleValue& result){    CYG_REPORT_FUNCNAME("version_cmp_eval");    CYG_REPORT_FUNCARG4XV(&context, expr, &subexpr, &result);    CYG_PRECONDITION_CLASSOC(context);    CYG_PRECONDITION_CLASSC(expr);    CdlSimpleValue      arg0;    CdlSimpleValue      arg1;    expr->eval_subexpression(context, subexpr.args[0], arg0);    expr->eval_subexpression(context, subexpr.args[1], arg1);    result = (cdl_int) Cdl::compare_versions(arg0.get_value(), arg1.get_value());        CYG_REPORT_RETURN();}static CdlFunction version_cmp("version_cmp", 2, CdlFunction::null_check, &version_cmp_eval,                               CdlFunction::null_infer_bool, CdlFunction::null_infer_value);//}}}

⌨️ 快捷键说明

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