Showing the changes to src/vm/array.cpp (1 of 5 files). Show all
Unified · Split
| @@ -166,7 +166,7 @@ void vm_array_t::copy_from(const vm_array_t &source, word_t this_begin_index) · 165 unmodified lines | |||
| 166 | if (this_begin_index < 0 || _length < (this_begin_index + source._length)) | 166 | if (this_begin_index < 0 || _length < (this_begin_index + source._length)) |
| 167 | throw out_of_range_memory{}; | 167 | throw out_of_range_memory{}; |
| 168 | 168 | ||
| 169 | if (source._element_type != _element_type) | 169 | if (!source._element_type->is_equal(_element_type.get())) |
| 170 | throw type_violation{}; | 170 | throw type_violation{}; |
| 171 | 171 | ||
| 172 | auto dest_arr = _arr + (this_begin_index * _element_type->size_in_bytes); | 172 | auto dest_arr = _arr + (this_begin_index * _element_type->size_in_bytes); |
| @@ -174,15 +174,15 @@ void vm_array_t::copy_from(const vm_array_t &source, word_t this_begin_index) · 1 unmodified line | |||
| 174 | // Increment all pointers if we have reference types. | 174 | // Increment all pointers if we have reference types. |
| 175 | if (_element_type->map_in_bytes != 0) | 175 | if (_element_type->map_in_bytes != 0) |
| 176 | { | 176 | { |
| 177 | assert(false && "Not implemented"); | 177 | auto &type_desc = *_element_type; |
| 178 | //auto &type_desc = *_element_type; | 178 | auto source_array_element = source._arr; |
| 179 | //auto source_array_element = source->_arr; | 179 | for (auto i = word_t{ 0 }; i < source._length; ++i) |
| 180 | //for (word_t i = 0; i < source->_length; ++i) | 180 | { |
| 181 | //{ | 181 | source_array_element += (i * type_desc.size_in_bytes); |
| 182 | // source_array_element += (i * type_desc.size_in_bytes); | 182 | inc_ref_count_in_memory(type_desc, source_array_element); |
| 183 | // inc_ref_count_in_alloc(type_desc, source_array_element); | 183 | } |
| 184 | //} | ||
| 185 | } | 184 | } |
| 186 | 185 | ||
| 187 | std::memcpy(dest_arr, source._arr, (source._length * _element_type->size_in_bytes)); | 186 | // Moving data within the same array is permitted so use memmove(). |
| 187 | std::memmove(dest_arr, source._arr, (source._length * _element_type->size_in_bytes)); | ||
| 188 | } | 188 | } |