mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
tbv2: add a repeat instruction
This commit is contained in:
parent
6f3580143e
commit
5daed4cc72
@ -32,8 +32,10 @@ namespace oi::exporters::inst {
|
||||
|
||||
struct PopTypePath;
|
||||
struct Field;
|
||||
struct Repeat;
|
||||
|
||||
using Inst = std::variant<PopTypePath, std::reference_wrapper<const Field>>;
|
||||
using Inst =
|
||||
std::variant<PopTypePath, Repeat, std::reference_wrapper<const Field>>;
|
||||
using Processor = void (*)(result::Element&,
|
||||
std::function<void(Inst)>,
|
||||
ParsedData);
|
||||
@ -41,6 +43,14 @@ using ProcessorInst = std::pair<types::dy::Dynamic, Processor>;
|
||||
|
||||
struct PopTypePath {};
|
||||
|
||||
struct Repeat {
|
||||
constexpr Repeat(size_t n_, const Field& field_) : n(n_), field(field_) {
|
||||
}
|
||||
|
||||
size_t n;
|
||||
std::reference_wrapper<const Field> field;
|
||||
};
|
||||
|
||||
struct Field {
|
||||
template <size_t N0, size_t N1, size_t N2>
|
||||
constexpr Field(size_t static_size_,
|
||||
|
@ -44,6 +44,12 @@ IntrospectionResult::const_iterator::operator++() {
|
||||
type_path_.pop_back();
|
||||
dynamic_type_path_.pop_back();
|
||||
return operator++();
|
||||
} else if constexpr (std::is_same_v<U, exporters::inst::Repeat>) {
|
||||
if (r.n-- != 0) {
|
||||
stack_.emplace(r);
|
||||
stack_.emplace(r.field);
|
||||
}
|
||||
return operator++();
|
||||
} else {
|
||||
// reference wrapper
|
||||
auto ty = r.get();
|
||||
|
@ -101,6 +101,5 @@ auto list = std::get<ParsedData::List>(d.val);
|
||||
el.container_stats->length = list.length;
|
||||
el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(T0);
|
||||
|
||||
for (size_t i = 0; i < list.length; i++)
|
||||
stack_ins(childField);
|
||||
stack_ins(inst::Repeat{ list.length, childField });
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user