History

Bug in debugger when printing a vm_alloc Bug in vm_string - get_rune/set_rune Update all instantiations of vm_string to use {} - fixed issues

arr committed 9 years ago

Commit bd1f4931 parent 57e9d245 files · +32 −20Browse files

Showing the changes to src/vm/execution_table.cpp (1 of 5 files). Show all

Unified · Split

src/vm/execution_table.cpp+13−13
@@ -179,7 +179,7 @@ namespace · 178 unmodified lines
179179 if (arr->get_element_type() != intrinsic_type_desc::type<byte_t>())
180180 throw vm_user_exception{ "Invalid array element type for string conversion" };
181181
182− auto new_string = new vm_string_t(arr->get_length(), reinterpret_cast<uint8_t *>(arr->at(0)));
182+ auto new_string = new vm_string_t{ static_cast<std::size_t>(arr->get_length()), reinterpret_cast<uint8_t *>(arr->at(0)) };
183183 str = new_string->get_allocation();
184184 }
185185
@@ -202,10 +202,10 @@ namespace · 16 unmodified lines
202202 auto buffer = std::array<char, sizeof("-2147483648")>{};
203203
204204 const auto w = vt_ref<word_t>(r.src);
205− const auto len = std::sprintf(buffer.data(), "%d", w);
206− assert(static_cast<std::size_t>(len) <= buffer.size());
205+ const auto len = static_cast<std::size_t>(std::sprintf(buffer.data(), "%d", w));
206+ assert(len <= buffer.size());
207207
208− auto new_string = new vm_string_t(len, reinterpret_cast<uint8_t *>(buffer.data()));
208+ auto new_string = new vm_string_t{ len, reinterpret_cast<uint8_t *>(buffer.data()) };
209209 auto prev = at_val<vm_alloc_t>(r.dest);
210210 dec_ref_count_and_free(prev);
211211
@@ -228,10 +228,10 @@ namespace · 16 unmodified lines
228228 auto buffer = std::array<char, sizeof("-2.2250738585072014e-308")>{};
229229
230230 const auto real = vt_ref<real_t>(r.src);
231− const auto len = std::sprintf(buffer.data(), "%g", real);
232− assert(static_cast<std::size_t>(len) <= buffer.size());
231+ const auto len = static_cast<std::size_t>(std::sprintf(buffer.data(), "%g", real));
232+ assert(len <= buffer.size());
233233
234− auto new_string = new vm_string_t(len, reinterpret_cast<uint8_t *>(buffer.data()));
234+ auto new_string = new vm_string_t{ len, reinterpret_cast<uint8_t *>(buffer.data()) };
235235
236236 auto prev = at_val<vm_alloc_t>(r.dest);
237237 dec_ref_count_and_free(prev);
@@ -255,10 +255,10 @@ namespace · 17 unmodified lines
255255 auto buffer = std::array<char, sizeof("-9223372036854775808")>{};
256256
257257 const auto b = vt_ref<big_t>(r.src);
258− const auto len = std::sprintf(buffer.data(), "%lld", b);
259− assert(static_cast<std::size_t>(len) <= buffer.size());
258+ const auto len = static_cast<std::size_t>(std::sprintf(buffer.data(), "%lld", b));
259+ assert(len <= buffer.size());
260260
261− auto new_string = new vm_string_t(len, reinterpret_cast<uint8_t *>(buffer.data()));
261+ auto new_string = new vm_string_t{ len, reinterpret_cast<uint8_t *>(buffer.data()) };
262262
263263 auto prev = at_val<vm_alloc_t>(r.dest);
264264 dec_ref_count_and_free(prev);
@@ -762,11 +762,11 @@ namespace · 497 unmodified lines
762762 if (try_append_to_s1)
763763 return nullptr;
764764
765− return new vm_string_t(*s1, 0, s1->get_length());
765+ return new vm_string_t{ *s1, 0, s1->get_length() };
766766 }
767767
768768 if (!try_append_to_s1)
769− return new vm_string_t(*s1, *s2);
769+ return new vm_string_t{ *s1, *s2 };
770770
771771 s1->append(*s2);
772772 return nullptr;
@@ -805,7 +805,7 @@ namespace · 32 unmodified lines
805805
806806 if (str != nullptr)
807807 {
808− auto new_string = new vm_string_t(*str, start, end);
808+ auto new_string = new vm_string_t{ *str, start, end };
809809 pt_ref(r.dest) = new_string->get_allocation();
810810 }
811811 else if (start == 0 && end == 0)