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
179 if (arr->get_element_type() != intrinsic_type_desc::type<byte_t>())179 if (arr->get_element_type() != intrinsic_type_desc::type<byte_t>())
180 throw vm_user_exception{ "Invalid array element type for string conversion" };180 throw vm_user_exception{ "Invalid array element type for string conversion" };
181 181
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)) };
183 str = new_string->get_allocation();183 str = new_string->get_allocation();
184 }184 }
185 185
@@ -202,10 +202,10 @@ namespace · 16 unmodified lines
202 auto buffer = std::array<char, sizeof("-2147483648")>{};202 auto buffer = std::array<char, sizeof("-2147483648")>{};
203 203
204 const auto w = vt_ref<word_t>(r.src);204 const auto w = vt_ref<word_t>(r.src);
205 const auto len = std::sprintf(buffer.data(), "%d", w);205 const auto len = static_cast<std::size_t>(std::sprintf(buffer.data(), "%d", w));
206 assert(static_cast<std::size_t>(len) <= buffer.size());206 assert(len <= buffer.size());
207 207
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()) };
209 auto prev = at_val<vm_alloc_t>(r.dest);209 auto prev = at_val<vm_alloc_t>(r.dest);
210 dec_ref_count_and_free(prev);210 dec_ref_count_and_free(prev);
211 211
@@ -228,10 +228,10 @@ namespace · 16 unmodified lines
228 auto buffer = std::array<char, sizeof("-2.2250738585072014e-308")>{};228 auto buffer = std::array<char, sizeof("-2.2250738585072014e-308")>{};
229 229
230 const auto real = vt_ref<real_t>(r.src);230 const auto real = vt_ref<real_t>(r.src);
231 const auto len = std::sprintf(buffer.data(), "%g", real);231 const auto len = static_cast<std::size_t>(std::sprintf(buffer.data(), "%g", real));
232 assert(static_cast<std::size_t>(len) <= buffer.size());232 assert(len <= buffer.size());
233 233
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()) };
235 235
236 auto prev = at_val<vm_alloc_t>(r.dest);236 auto prev = at_val<vm_alloc_t>(r.dest);
237 dec_ref_count_and_free(prev);237 dec_ref_count_and_free(prev);
@@ -255,10 +255,10 @@ namespace · 17 unmodified lines
255 auto buffer = std::array<char, sizeof("-9223372036854775808")>{};255 auto buffer = std::array<char, sizeof("-9223372036854775808")>{};
256 256
257 const auto b = vt_ref<big_t>(r.src);257 const auto b = vt_ref<big_t>(r.src);
258 const auto len = std::sprintf(buffer.data(), "%lld", b);258 const auto len = static_cast<std::size_t>(std::sprintf(buffer.data(), "%lld", b));
259 assert(static_cast<std::size_t>(len) <= buffer.size());259 assert(len <= buffer.size());
260 260
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()) };
262 262
263 auto prev = at_val<vm_alloc_t>(r.dest);263 auto prev = at_val<vm_alloc_t>(r.dest);
264 dec_ref_count_and_free(prev);264 dec_ref_count_and_free(prev);
@@ -762,11 +762,11 @@ namespace · 497 unmodified lines
762 if (try_append_to_s1)762 if (try_append_to_s1)
763 return nullptr;763 return nullptr;
764 764
765 return new vm_string_t(*s1, 0, s1->get_length());765 return new vm_string_t{ *s1, 0, s1->get_length() };
766 }766 }
767 767
768 if (!try_append_to_s1)768 if (!try_append_to_s1)
769 return new vm_string_t(*s1, *s2);769 return new vm_string_t{ *s1, *s2 };
770 770
771 s1->append(*s2);771 s1->append(*s2);
772 return nullptr;772 return nullptr;
@@ -805,7 +805,7 @@ namespace · 32 unmodified lines
805 805
806 if (str != nullptr)806 if (str != nullptr)
807 {807 {
808 auto new_string = new vm_string_t(*str, start, end);808 auto new_string = new vm_string_t{ *str, start, end };
809 pt_ref(r.dest) = new_string->get_allocation();809 pt_ref(r.dest) = new_string->get_allocation();
810 }810 }
811 else if (start == 0 && end == 0)811 else if (start == 0 && end == 0)