History

Create specific exception when index is out of range. Update thread class to print out exception details. Throw exception when an invalid op-code is detected. Enforce mspawn instruction cannot start from a built-in module.

arr committed 10 years ago

Commit 266fad61 parent 9af409310 files · +63 −40Browse files

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

Unified · Split

src/vm/string.cpp+4−4
@@ -264,10 +264,10 @@ vm_string_t::vm_string_t(const vm_string_t &other, word_t begin_index, word_t en · 263 unmodified lines
264 throw out_of_range_memory{};264 throw out_of_range_memory{};
265 265
266 if (begin_index < 0)266 if (begin_index < 0)
267 throw out_of_range_memory{ 0, other._length, begin_index };267 throw index_out_of_range_memory{ 0, other._length, begin_index };
268 268
269 if (other._length < end_index)269 if (other._length < end_index)
270 throw out_of_range_memory{ 0, other._length, end_index };270 throw index_out_of_range_memory{ 0, other._length, end_index };
271 271
272 // Allocate memory based on character count and size272 // Allocate memory based on character count and size
273 auto src = other._mem.local;273 auto src = other._mem.local;
@@ -384,7 +384,7 @@ word_t vm_string_t::get_length() const · 110 unmodified lines
384rune_t vm_string_t::get_rune(word_t index) const384rune_t vm_string_t::get_rune(word_t index) const
385{385{
386 if (index < 0 && _length <= index)386 if (index < 0 && _length <= index)
387 throw out_of_range_memory{ 0, _length - 1, index };387 throw index_out_of_range_memory{ 0, _length - 1, index };
388 388
389 // Determine if local or allocated memory389 // Determine if local or allocated memory
390 auto source = reinterpret_cast<const char *>(_mem.local);390 auto source = reinterpret_cast<const char *>(_mem.local);
@@ -410,7 +410,7 @@ void vm_string_t::set_rune(word_t index, rune_t value) · 19 unmodified lines
410 410
411 // Index equal to length is allowed to grow the string411 // Index equal to length is allowed to grow the string
412 if (index < 0 && _length <= index)412 if (index < 0 && _length <= index)
413 throw out_of_range_memory{ 0, _length, index };413 throw index_out_of_range_memory{ 0, _length, index };
414 414
415 // Determine if local or allocated memory415 // Determine if local or allocated memory
416 auto source = static_cast<uint8_t *>(_mem.local);416 auto source = static_cast<uint8_t *>(_mem.local);