Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 95645c9

Browse files
committed
add glue_non_native into basic_non_native_policy
1 parent 1e9ceab commit 95645c9

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

include/nil/blueprint/basic_non_native_policy.hpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,24 @@ namespace nil {
7474
chopped_value_type result;
7575
for (std::size_t i = 0; i < ratio; i++) {
7676
result[i] = get_i_th_chunk(input, i);
77-
7877
}
79-
8078
return result;
79+
}
8180

81+
static non_native_field_type::value_type glue_non_native(chopped_value_type input) {
82+
non_native_field_type::value_type result;
83+
native_field_type::integral_type integral_input;
84+
result = non_native_field_type::value_type(native_field_type::integral_type(input[0].data));
85+
for (std::size_t i = 1; i < ratio; i++) {
86+
std::size_t shift = 0;
87+
for (std::size_t j = 0; j < i; j++) {
88+
shift += chunk_sizes[j];
89+
}
90+
result += non_native_field_type::value_type(native_field_type::integral_type(input[i].data) << shift);
91+
}
92+
return result;
8293
}
94+
8395
};
8496

8597
/*
@@ -132,12 +144,24 @@ namespace nil {
132144
chopped_value_type result;
133145
for (std::size_t i = 0; i < ratio; i++) {
134146
result[i] = get_i_th_chunk(input, i);
135-
136147
}
137-
138148
return result;
149+
}
139150

151+
static non_native_field_type::value_type glue_non_native(chopped_value_type input) {
152+
non_native_field_type::value_type result;
153+
native_field_type::integral_type integral_input;
154+
result = non_native_field_type::value_type(native_field_type::integral_type(input[0].data));
155+
for (std::size_t i = 1; i < ratio; i++) {
156+
std::size_t shift = 0;
157+
for (std::size_t j = 0; j < i; j++) {
158+
shift += chunk_sizes[j];
159+
}
160+
result += non_native_field_type::value_type(native_field_type::integral_type(input[i].data) << shift);
161+
}
162+
return result;
140163
}
164+
141165
};
142166

143167
/*

0 commit comments

Comments
 (0)