upd: add float* str

This commit is contained in:
2023-11-10 12:38:09 +08:00
parent 0074023bd9
commit d4473c5f78

View File

@ -216,13 +216,21 @@ std::any Mul(std::any a, std::any b) {
(ptr_b_string != nullptr ? 1 : 0) == (ptr_b_string != nullptr ? 1 : 0) ==
1) { 1) {
if (ptr_a_string == nullptr) { if (ptr_a_string == nullptr) {
std::swap(ptr_a_string, ptr_b_string); std::swap(a, b);
std::swap(ptr_a_bool, ptr_b_bool); ptr_a_bool = std::any_cast<bool>(&a);
std::swap(ptr_a_int2048, ptr_b_int2048); ptr_b_bool = std::any_cast<bool>(&b);
std::swap(ptr_a_float, ptr_b_float); ptr_a_int2048 = std::any_cast<ZYM::int2048>(&a);
ptr_b_int2048 = std::any_cast<ZYM::int2048>(&b);
ptr_a_float = std::any_cast<double>(&a);
ptr_b_float = std::any_cast<double>(&b);
ptr_a_string = std::any_cast<std::string>(&a);
ptr_b_string = std::any_cast<std::string>(&b);
}
if (ptr_b_float != nullptr) {
b = Any2Int(*ptr_b_float);
ptr_b_int2048 = std::any_cast<ZYM::int2048>(&b);
goto st;
} }
if (ptr_b_float != nullptr)
throw InterpretException("Mul: string*float not allowed", 41);
if (ptr_b_bool != nullptr) { if (ptr_b_bool != nullptr) {
if (*ptr_b_bool) { if (*ptr_b_bool) {
return *ptr_a_string; return *ptr_a_string;
@ -234,6 +242,7 @@ std::any Mul(std::any a, std::any b) {
std::any_cast<NoneType>(&b) != nullptr) std::any_cast<NoneType>(&b) != nullptr)
return std::string(""); return std::string("");
if (ptr_b_int2048 != nullptr) { if (ptr_b_int2048 != nullptr) {
st:;
std::string res; std::string res;
for (int i = 0; i < (*ptr_b_int2048); i++) res += *ptr_a_string; for (int i = 0; i < (*ptr_b_int2048); i++) res += *ptr_a_string;
return res; return res;