fix: roller2/roller3 中 init_hold_exp_str/exp_messy_code_check 改用 ExpressionEngine
This commit is contained in:
parent
367802fc71
commit
06ebc21dd6
@ -125,27 +125,15 @@ int Roller2::init_X_exp() {
|
|||||||
rule_json_.at("function").at(exp_stri).at("value").get<std::string>();
|
rule_json_.at("function").at(exp_stri).at("value").get<std::string>();
|
||||||
exp_str_ = get_macro_replaced_exp(tmp_exp);
|
exp_str_ = get_macro_replaced_exp(tmp_exp);
|
||||||
var_exp_str_[exp_stri] = exp_str_;
|
var_exp_str_[exp_stri] = exp_str_;
|
||||||
res += init_hold_exp_str(exp_str_);
|
|
||||||
feedback_mode_ = true;
|
feedback_mode_ = true;
|
||||||
auto messy_code = exp_messy_code_check(exp_str_);
|
int reg_ret = expr_engine_->registerExpression(exp_stri, exp_str_);
|
||||||
if (messy_code == -1) {
|
if (reg_ret != 0) {
|
||||||
this->error_code_list_.push_back(
|
|
||||||
{ErrorType::EnCodeError, ErrorLocation::ActExp});
|
|
||||||
res += messy_code;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
var_exp_[exp_stri] =
|
|
||||||
std::make_unique<mix_cc::matheval::Expression>(exp_str_, &mm_vars);
|
|
||||||
logger_->Debug() << "exp_stri:" << exp_str_ << "="
|
|
||||||
<< var_exp_[exp_stri]->evaluate() << endl;
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
logger_->Error() << "exp_stri:" << exp_str_ << "计算出错:" << e.what()
|
|
||||||
<< ",location:" << BOOST_CURRENT_LOCATION << endl;
|
|
||||||
this->error_code_list_.push_back(
|
this->error_code_list_.push_back(
|
||||||
{ErrorType::CalError, ErrorLocation::FBExp});
|
{ErrorType::CalError, ErrorLocation::FBExp});
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
logger_->Debug() << "exp_stri:" << exp_str_ << "="
|
||||||
|
<< expr_engine_->evaluate(exp_stri) << endl;
|
||||||
if (rule_json_.at("function").at(exp_stri).at("param").contains("name")) {
|
if (rule_json_.at("function").at(exp_stri).at("param").contains("name")) {
|
||||||
var_name_[exp_stri] = rule_json_.at("function")
|
var_name_[exp_stri] = rule_json_.at("function")
|
||||||
.at(exp_stri)
|
.at(exp_stri)
|
||||||
@ -182,11 +170,11 @@ int Roller2::init_X_exp() {
|
|||||||
|
|
||||||
void Roller2::refresh_var_result() {
|
void Roller2::refresh_var_result() {
|
||||||
try {
|
try {
|
||||||
for (auto& expi : var_exp_) {
|
for (auto& expi : var_exp_str_) {
|
||||||
if (expi.first == "pre_exp") {
|
if (expi.first == "pre_exp") {
|
||||||
pre_exp_flag_ = expi.second->evaluate();
|
pre_exp_flag_ = expr_engine_->evaluateBool(expi.first);
|
||||||
} else {
|
} else {
|
||||||
var_Xdouble_[expi.first] = expi.second->evaluate();
|
var_Xdouble_[expi.first] = expr_engine_->evaluate(expi.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|||||||
@ -229,16 +229,14 @@ int Roller3::init_X_exp() {
|
|||||||
rule_json_.at("function").at("pre_exp").at("value").get<std::string>();
|
rule_json_.at("function").at("pre_exp").at("value").get<std::string>();
|
||||||
|
|
||||||
exp_str_ = get_macro_replaced_exp(tmp_exp);
|
exp_str_ = get_macro_replaced_exp(tmp_exp);
|
||||||
res += init_hold_exp_str(exp_str_);
|
int reg_ret = expr_engine_->registerExpression("pre_exp", exp_str_);
|
||||||
|
if (reg_ret != 0) {
|
||||||
// ExpressionEngine::registerExpression() now handles FunVars processing internally.
|
|
||||||
feedback_mode_ = false;
|
|
||||||
auto messy_code = exp_messy_code_check(exp_str_);
|
|
||||||
if (messy_code == -1) {
|
|
||||||
this->error_code_list_.push_back(
|
this->error_code_list_.push_back(
|
||||||
{ErrorType::EnCodeError, ErrorLocation::ActExp});
|
{ErrorType::CalError, ErrorLocation::ActExp});
|
||||||
res += messy_code;
|
res += reg_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feedback_mode_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule_json_.at("function").contains("input")) {
|
if (rule_json_.at("function").contains("input")) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user