Add field_num to gen_fetch_function_begin.
GitOrigin-RevId: a8679b71820cbd500ee489dec3a828eeec358080
This commit is contained in:
parent
26c5328b89
commit
6d53f3a85a
@ -1029,7 +1029,7 @@ class TlWriterCCommon : public tl::TL_writer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const override {
|
std::vector<tl::var_description> &vars, int parser_type) const override {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ std::string TD_TL_writer_cpp::gen_function_result_type(const tl::tl_tree *result
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_cpp::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string TD_TL_writer_cpp::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const {
|
std::vector<tl::var_description> &vars, int parser_type) const {
|
||||||
for (std::size_t i = 0; i < vars.size(); i++) {
|
for (std::size_t i = 0; i < vars.size(); i++) {
|
||||||
assert(vars[i].is_stored == false);
|
assert(vars[i].is_stored == false);
|
||||||
|
@ -77,7 +77,7 @@ class TD_TL_writer_cpp : public TD_TL_writer {
|
|||||||
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
||||||
|
|
||||||
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const override;
|
std::vector<tl::var_description> &vars, int parser_type) const override;
|
||||||
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
||||||
int parser_type) const override;
|
int parser_type) const override;
|
||||||
|
@ -471,7 +471,7 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<var_description> &vars, int parser_type) const override {
|
std::vector<var_description> &vars, int parser_type) const override {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ std::string TD_TL_writer_h::gen_function_result_type(const tl::tl_tree *result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_h::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string TD_TL_writer_h::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const {
|
std::vector<tl::var_description> &vars, int parser_type) const {
|
||||||
std::string returned_type = "object_ptr<" + parent_class_name + "> ";
|
std::string returned_type = "object_ptr<" + parent_class_name + "> ";
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class TD_TL_writer_h : public TD_TL_writer {
|
|||||||
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
||||||
|
|
||||||
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const override;
|
std::vector<tl::var_description> &vars, int parser_type) const override;
|
||||||
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
||||||
int parser_type) const override;
|
int parser_type) const override;
|
||||||
|
@ -138,7 +138,7 @@ std::string TD_TL_writer_hpp::gen_function_result_type(const tl::tl_tree *result
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_hpp::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string TD_TL_writer_hpp::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const {
|
std::vector<tl::var_description> &vars, int parser_type) const {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class TD_TL_writer_hpp : public TD_TL_writer {
|
|||||||
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
||||||
|
|
||||||
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const override;
|
std::vector<tl::var_description> &vars, int parser_type) const override;
|
||||||
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
||||||
int parser_type) const override;
|
int parser_type) const override;
|
||||||
|
@ -346,7 +346,7 @@ std::string TD_TL_writer_java::gen_function_result_type(const tl::tl_tree *resul
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_java::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string TD_TL_writer_java::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const {
|
std::vector<tl::var_description> &vars, int parser_type) const {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class TD_TL_writer_java : public tl::TL_writer {
|
|||||||
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
std::string gen_function_result_type(const tl::tl_tree *result) const override;
|
||||||
|
|
||||||
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const override;
|
std::vector<tl::var_description> &vars, int parser_type) const override;
|
||||||
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
||||||
int parser_type) const override;
|
int parser_type) const override;
|
||||||
|
@ -380,7 +380,7 @@ std::string TD_TL_writer_jni_cpp::gen_get_id(const std::string &class_name, std:
|
|||||||
std::string TD_TL_writer_jni_cpp::gen_fetch_function_begin(const std::string &parser_name,
|
std::string TD_TL_writer_jni_cpp::gen_fetch_function_begin(const std::string &parser_name,
|
||||||
const std::string &class_name,
|
const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity,
|
||||||
std::vector<tl::var_description> &vars,
|
int field_num, std::vector<tl::var_description> &vars,
|
||||||
int parser_type) const {
|
int parser_type) const {
|
||||||
for (std::size_t i = 0; i < vars.size(); i++) {
|
for (std::size_t i = 0; i < vars.size(); i++) {
|
||||||
assert(vars[i].is_stored == false);
|
assert(vars[i].is_stored == false);
|
||||||
|
@ -74,7 +74,7 @@ class TD_TL_writer_jni_cpp : public TD_TL_writer_cpp {
|
|||||||
std::string gen_get_id(const std::string &class_name, std::int32_t id, bool is_proxy) const override;
|
std::string gen_get_id(const std::string &class_name, std::int32_t id, bool is_proxy) const override;
|
||||||
|
|
||||||
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<tl::var_description> &vars, int parser_type) const override;
|
std::vector<tl::var_description> &vars, int parser_type) const override;
|
||||||
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
|
||||||
int parser_type) const override;
|
int parser_type) const override;
|
||||||
|
@ -92,7 +92,7 @@ static void write_function_fetch(tl_outputer &out, const std::string &parser_nam
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.append(w.gen_fetch_function_begin(parser_name, class_name, class_name, 0, vars, parser_type));
|
out.append(w.gen_fetch_function_begin(parser_name, class_name, class_name, 0, t->args.size(), vars, parser_type));
|
||||||
out.append(w.gen_vars(t, NULL, vars));
|
out.append(w.gen_vars(t, NULL, vars));
|
||||||
int field_num = 0;
|
int field_num = 0;
|
||||||
for (std::size_t i = 0; i < t->args.size(); i++) {
|
for (std::size_t i = 0; i < t->args.size(); i++) {
|
||||||
@ -176,7 +176,8 @@ static void write_constructor_fetch(tl_outputer &out, const std::string &parser_
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.append(w.gen_fetch_function_begin(parser_name, class_name, parent_class_name,
|
out.append(w.gen_fetch_function_begin(parser_name, class_name, parent_class_name,
|
||||||
static_cast<int>(result_type->children.size()), vars, parser_type));
|
static_cast<int>(result_type->children.size()), t->args.size(), vars,
|
||||||
|
parser_type));
|
||||||
out.append(w.gen_vars(t, result_type, vars));
|
out.append(w.gen_vars(t, result_type, vars));
|
||||||
out.append(w.gen_uni(result_type, vars, true));
|
out.append(w.gen_uni(result_type, vars, true));
|
||||||
int field_num = 0;
|
int field_num = 0;
|
||||||
@ -369,7 +370,7 @@ void write_class(tl_outputer &out, const tl_type *t, const std::set<std::string>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.append(w.gen_fetch_function_begin(parsers[i], class_name, class_name, t->arity, empty_vars, -1));
|
out.append(w.gen_fetch_function_begin(parsers[i], class_name, class_name, t->arity, -1, empty_vars, -1));
|
||||||
out.append(w.gen_fetch_switch_begin());
|
out.append(w.gen_fetch_switch_begin());
|
||||||
for (std::size_t j = 0; j < t->constructors_num; j++) {
|
for (std::size_t j = 0; j < t->constructors_num; j++) {
|
||||||
if (w.is_combinator_supported(t->constructors[j])) {
|
if (w.is_combinator_supported(t->constructors[j])) {
|
||||||
@ -652,7 +653,7 @@ void write_tl(const tl_config &config, tl_outputer &out, const TL_writer &w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.append(w.gen_fetch_function_begin(parsers[j], w.gen_base_type_class_name(i), w.gen_base_type_class_name(i), i,
|
out.append(w.gen_fetch_function_begin(parsers[j], w.gen_base_type_class_name(i), w.gen_base_type_class_name(i), i,
|
||||||
empty_vars, -1));
|
-1, empty_vars, -1));
|
||||||
out.append(w.gen_fetch_switch_begin());
|
out.append(w.gen_fetch_switch_begin());
|
||||||
for (std::size_t type = 0; type < types_n; type++) {
|
for (std::size_t type = 0; type < types_n; type++) {
|
||||||
tl_type *t = config.get_type_by_num(type);
|
tl_type *t = config.get_type_by_num(type);
|
||||||
@ -727,7 +728,7 @@ void write_tl(const tl_config &config, tl_outputer &out, const TL_writer &w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.append(w.gen_fetch_function_begin(parsers[j], w.gen_base_function_class_name(),
|
out.append(w.gen_fetch_function_begin(parsers[j], w.gen_base_function_class_name(),
|
||||||
w.gen_base_function_class_name(), 0, empty_vars, -1));
|
w.gen_base_function_class_name(), 0, -1, empty_vars, -1));
|
||||||
out.append(w.gen_fetch_switch_begin());
|
out.append(w.gen_fetch_switch_begin());
|
||||||
for (std::size_t function = 0; function < functions_n; function++) {
|
for (std::size_t function = 0; function < functions_n; function++) {
|
||||||
tl_combinator *t = config.get_function_by_num(function);
|
tl_combinator *t = config.get_function_by_num(function);
|
||||||
|
@ -120,7 +120,7 @@ class TL_writer {
|
|||||||
virtual std::string gen_function_result_type(const tl_tree *result) const = 0;
|
virtual std::string gen_function_result_type(const tl_tree *result) const = 0;
|
||||||
|
|
||||||
virtual std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
virtual std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
|
||||||
const std::string &parent_class_name, int arity,
|
const std::string &parent_class_name, int arity, int field_num,
|
||||||
std::vector<var_description> &vars, int parser_type) const = 0;
|
std::vector<var_description> &vars, int parser_type) const = 0;
|
||||||
virtual std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<var_description> &vars,
|
virtual std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<var_description> &vars,
|
||||||
int parser_type) const = 0;
|
int parser_type) const = 0;
|
||||||
|
Reference in New Issue
Block a user