|
10 | 10 | #include "decimal_ref.h" |
11 | 11 | #include "nested_message_ref.h" |
12 | 12 |
|
| 13 | +#include <type_traits> |
| 14 | + |
13 | 15 | namespace mfast { |
14 | 16 | template <int V> struct fast_operator_tag : std::integral_constant<int, V> {}; |
15 | 17 |
|
@@ -147,6 +149,13 @@ class ext_cref<sequence_cref, LengthExtRef, ElementExtRef> { |
147 | 149 | explicit ext_cref(const field_cref &other) : base_(other) {} |
148 | 150 | cref_type get() const { return base_; } |
149 | 151 | length_type get_length(value_storage &storage) const { |
| 152 | + if (std::is_same<typename LengthExtRef::operator_category, constant_operator_tag>::value) |
| 153 | + storage = base_.instruction()->length_instruction()->initial_value(); |
| 154 | + else if (std::is_same<typename LengthExtRef::operator_category, copy_operator_tag>::value) |
| 155 | + storage = base_.instruction()->length_instruction()->prev_value(); |
| 156 | + else if (std::is_same<typename LengthExtRef::operator_category, default_operator_tag>::value) |
| 157 | + storage = base_.instruction()->length_instruction()->initial_or_default_value(); |
| 158 | + |
150 | 159 | uint32_mref length_mref(nullptr, &storage, |
151 | 160 | base_.instruction()->length_instruction()); |
152 | 161 | length_mref.as(base_.size()); |
@@ -327,6 +336,13 @@ class ext_mref<sequence_mref, LengthExtRef, ElementExtRef> { |
327 | 336 | cref_type get() const { return base_; } |
328 | 337 | is_optional_type optional() const { return is_optional_type(); } |
329 | 338 | length_type set_length(value_storage &storage) const { |
| 339 | + if (std::is_same<typename LengthExtRef::operator_category, constant_operator_tag>::value) |
| 340 | + storage = base_.instruction()->length_instruction()->initial_value(); |
| 341 | + else if (std::is_same<typename LengthExtRef::operator_category, copy_operator_tag>::value) |
| 342 | + storage = base_.instruction()->length_instruction()->prev_value(); |
| 343 | + else if (std::is_same<typename LengthExtRef::operator_category, default_operator_tag>::value) |
| 344 | + storage = base_.instruction()->length_instruction()->initial_or_default_value(); |
| 345 | + |
330 | 346 | field_mref_base length_mref(nullptr, &storage, |
331 | 347 | base_.instruction()->length_instruction()); |
332 | 348 | return length_type(length_mref); |
|
0 commit comments