History

Style and const updates

arr committed 10 years ago

Commit 9c1abd61 parent 28f98c33 files · +23 −27Browse files

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

Unified · Split

src/vm/execution_table.cpp+20−20
@@ -635,7 +635,7 @@ namespace · 634 unmodified lines
635 const auto value = at_val<vm_string_t>(r.src);635 const auto value = at_val<vm_string_t>(r.src);
636 636
637 assert(r.dest != nullptr);637 assert(r.dest != nullptr);
638 const auto table = reinterpret_cast<const word_t *>(r.dest);638 auto table = reinterpret_cast<word_t *>(r.dest);
639 const auto entry_count = table[case_op_constants::table_length_index];639 const auto entry_count = table[case_op_constants::table_length_index];
640 640
641 // Initialize the target PC with the fallback value. 641 // Initialize the target PC with the fallback value.
@@ -648,7 +648,7 @@ namespace · 6 unmodified lines
648 // Find the matching table entry648 // Find the matching table entry
649 for (auto entry = word_t{ 0 }; entry < entry_count; ++entry)649 for (auto entry = word_t{ 0 }; entry < entry_count; ++entry)
650 {650 {
651 auto string_low = at_val<vm_string_t>(reinterpret_cast<pointer_t>(const_cast<word_t *>(current_entry + case_op_constants::entry_low_index)));651 auto string_low = at_val<vm_string_t>(reinterpret_cast<pointer_t>(current_entry + case_op_constants::entry_low_index));
652 652
653 // Compare the value against the low string653 // Compare the value against the low string
654 int result = vm_string_t::compare(value, string_low);654 int result = vm_string_t::compare(value, string_low);
@@ -662,7 +662,7 @@ namespace · 7 unmodified lines
662 }662 }
663 663
664 // Compare the value against the high string664 // Compare the value against the high string
665 auto string_high = at_val<vm_string_t>(reinterpret_cast<pointer_t>(const_cast<word_t *>(current_entry + case_op_constants::entry_high_index)));665 auto string_high = at_val<vm_string_t>(reinterpret_cast<pointer_t>(current_entry + case_op_constants::entry_high_index));
666 if (string_high == nullptr || vm_string_t::compare(value, string_high) != 0)666 if (string_high == nullptr || vm_string_t::compare(value, string_high) != 0)
667 {667 {
668 current_entry += case_op_constants::entry_length;668 current_entry += case_op_constants::entry_length;
@@ -692,7 +692,7 @@ namespace · 23 unmodified lines
692 EXEC_DECL(lenc)692 EXEC_DECL(lenc)
693 {693 {
694 auto len = word_t{ 0 };694 auto len = word_t{ 0 };
695 auto str = at_val<vm_string_t>(r.src);695 const auto str = at_val<vm_string_t>(r.src);
696 if (str != nullptr)696 if (str != nullptr)
697 len = str->get_length();697 len = str->get_length();
698 698
@@ -740,14 +740,14 @@ namespace · 41 unmodified lines
740 }740 }
741 }741 }
742 742
743 vm_string_t *_addc(vm_string_t *s1, vm_string_t *s2, /* in out */ bool &append_to_s1)743 vm_string_t *_addc(vm_string_t *s1, const vm_string_t *s2, /* in out */ bool &append_to_s1)
744 {744 {
745 if (s1 == nullptr)745 if (s1 == nullptr)
746 {746 {
747 if (s2 == nullptr)747 if (s2 == nullptr)
748 return new vm_string_t();748 return new vm_string_t{};
749 749
750 return new vm_string_t(*s2, 0, s2->get_length());750 return new vm_string_t{ *s2, 0, s2->get_length() };
751 }751 }
752 752
753 // There are other references to this string so we will not alter it.753 // There are other references to this string so we will not alter it.
@@ -776,14 +776,14 @@ namespace · 22 unmodified lines
776 EXEC_DECL(addc)776 EXEC_DECL(addc)
777 {777 {
778 auto s1 = at_val<vm_string_t>(r.mid);778 auto s1 = at_val<vm_string_t>(r.mid);
779 auto s2 = at_val<vm_string_t>(r.src);779 const auto s2 = at_val<vm_string_t>(r.src);
780 auto dest_maybe = at_val<vm_string_t>(r.dest);780 auto dest_maybe = at_val<vm_string_t>(r.dest);
781 781
782 // If the source is the same as the destination and the782 // If the source is the same as the destination and the
783 // destination is not null, append the string. This can 783 // destination is not null, append the string. This can
784 // change during the concat process.784 // change during the concat process.
785 auto append_to_source = dest_maybe != nullptr && s1 == dest_maybe;785 auto append_to_source = dest_maybe != nullptr && s1 == dest_maybe;
786 auto str = _addc(s1, s2, append_to_source);786 const auto str = _addc(s1, s2, append_to_source);
787 787
788 if (!append_to_source)788 if (!append_to_source)
789 {789 {
@@ -822,7 +822,7 @@ namespace · 32 unmodified lines
822 EXEC_DECL(lena)822 EXEC_DECL(lena)
823 {823 {
824 auto len = word_t{ 0 };824 auto len = word_t{ 0 };
825 auto arr = at_val<vm_array_t>(r.src);825 const auto arr = at_val<vm_array_t>(r.src);
826 if (arr != nullptr)826 if (arr != nullptr)
827 len = arr->get_length();827 len = arr->get_length();
828 828
@@ -872,7 +872,7 @@ namespace · 43 unmodified lines
872 872
873 void _index_in(vm_registers_t &r)873 void _index_in(vm_registers_t &r)
874 {874 {
875 auto arr = at_val<vm_array_t>(r.src);875 const auto arr = at_val<vm_array_t>(r.src);
876 if (arr == nullptr)876 if (arr == nullptr)
877 throw dereference_nil{ "Indexing into array" };877 throw dereference_nil{ "Indexing into array" };
878 878
@@ -897,7 +897,7 @@ namespace · 18 unmodified lines
897 EXEC_DECL(lenl)897 EXEC_DECL(lenl)
898 {898 {
899 auto len = word_t{ 0 };899 auto len = word_t{ 0 };
900 auto list = at_val<vm_list_t>(r.src);900 const auto list = at_val<vm_list_t>(r.src);
901 if (list != nullptr)901 if (list != nullptr)
902 {902 {
903 assert(list->alloc_type == vm_list_t::type_desc());903 assert(list->alloc_type == vm_list_t::type_desc());
@@ -983,7 +983,7 @@ namespace · 79 unmodified lines
983 template<typename PrimitiveType>983 template<typename PrimitiveType>
984 void _head(vm_registers_t &r)984 void _head(vm_registers_t &r)
985 {985 {
986 auto head = at_val<vm_list_t>(r.src);986 const auto head = at_val<vm_list_t>(r.src);
987 if (head == nullptr)987 if (head == nullptr)
988 throw dereference_nil{ "Head of list" };988 throw dereference_nil{ "Head of list" };
989 989
@@ -999,7 +999,7 @@ namespace · 9 unmodified lines
999 999
1000 EXEC_DECL(headp)1000 EXEC_DECL(headp)
1001 {1001 {
1002 auto list = at_val<vm_list_t>(r.src);1002 const auto list = at_val<vm_list_t>(r.src);
1003 if (list == nullptr)1003 if (list == nullptr)
1004 throw dereference_nil{ "Head of list" };1004 throw dereference_nil{ "Head of list" };
1005 1005
@@ -1009,7 +1009,7 @@ namespace · 3 unmodified lines
1009 1009
1010 EXEC_DECL(headmp)1010 EXEC_DECL(headmp)
1011 {1011 {
1012 auto list = at_val<vm_list_t>(r.src);1012 const auto list = at_val<vm_list_t>(r.src);
1013 if (list == nullptr)1013 if (list == nullptr)
1014 throw dereference_nil{ "Head of list" };1014 throw dereference_nil{ "Head of list" };
1015 1015
@@ -1019,7 +1019,7 @@ namespace · 3 unmodified lines
1019 1019
1020 EXEC_DECL(tail)1020 EXEC_DECL(tail)
1021 {1021 {
1022 auto list = at_val<vm_list_t>(r.src);1022 const auto list = at_val<vm_list_t>(r.src);
1023 if (list == nullptr)1023 if (list == nullptr)
1024 throw dereference_nil{ "Tail of list" };1024 throw dereference_nil{ "Tail of list" };
1025 1025
@@ -1397,8 +1397,8 @@ namespace · 371 unmodified lines
1397 1397
1398 EXEC_DECL(tcmp)1398 EXEC_DECL(tcmp)
1399 {1399 {
1400 auto s = at_val<vm_alloc_t>(r.src);1400 const auto s = at_val<vm_alloc_t>(r.src);
1401 auto d = at_val<vm_alloc_t>(r.dest);1401 const auto d = at_val<vm_alloc_t>(r.dest);
1402 1402
1403 if (s == nullptr)1403 if (s == nullptr)
1404 return;1404 return;
@@ -1558,10 +1558,10 @@ namespace · 153 unmodified lines
1558 1558
1559 EXEC_DECL(goto_)1559 EXEC_DECL(goto_)
1560 {1560 {
1561 auto pc_index = vt_ref<word_t>(r.src);1561 const auto pc_index = vt_ref<word_t>(r.src);
1562 1562
1563 assert(r.dest != nullptr);1563 assert(r.dest != nullptr);
1564 auto pc_table = reinterpret_cast<vm_pc_t *>(r.dest);1564 const auto pc_table = reinterpret_cast<vm_pc_t *>(r.dest);
1565 1565
1566 r.pc = pc_table[pc_index];1566 r.pc = pc_table[pc_index];
1567 }1567 }