Simplify True fetching.

This commit is contained in:
levlam 2024-02-05 14:10:19 +03:00
parent d2680fff48
commit d11e88c9eb
2 changed files with 13 additions and 10 deletions

View File

@ -230,14 +230,25 @@ std::string TD_TL_writer_cpp::gen_field_fetch(int field_num, const tl::arg &a, s
} }
assert(!(a.flags & tl::FLAG_EXCL)); assert(!(a.flags & tl::FLAG_EXCL));
assert(!(a.flags & tl::FLAG_OPT_VAR)); assert(!(a.flags & tl::FLAG_OPT_VAR));
std::string res = " ";
if (a.exist_var_num != -1) { if (a.exist_var_num != -1) {
assert(0 <= a.exist_var_num && a.exist_var_num < static_cast<int>(vars.size())); assert(0 <= a.exist_var_num && a.exist_var_num < static_cast<int>(vars.size()));
assert(vars[a.exist_var_num].is_stored); assert(vars[a.exist_var_num].is_stored);
if (a.var_num == -1 && parser_type != 0) {
assert(a.type->get_type() == tl::NODE_TYPE_TYPE);
const tl::tl_tree_type *tree_type = static_cast<tl::tl_tree_type *>(a.type);
if (tree_type->flags & tl::FLAG_BARE && tree_type->type->name == "True") {
assert(is_type_bare(tree_type->type));
return " " + field_name + " = (" + gen_var_name(vars[a.exist_var_num]) + " & " +
int_to_string(1 << a.exist_var_bit) + ") != 0;\n";
}
}
}
std::string res = " ";
if (a.exist_var_num != -1) {
res += "if (" + gen_var_name(vars[a.exist_var_num]) + " & " + int_to_string(1 << a.exist_var_bit) + ") { "; res += "if (" + gen_var_name(vars[a.exist_var_num]) + " & " + int_to_string(1 << a.exist_var_bit) + ") { ";
} }

View File

@ -32,14 +32,6 @@ class TlFetchBoxed {
} }
}; };
class TlFetchTrue {
public:
template <class ParserT>
static bool parse(ParserT &parser) {
return true;
}
};
class TlFetchBool { class TlFetchBool {
public: public:
template <class ParserT> template <class ParserT>