History

Style and const updates

arr committed 10 years ago

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

Unified · Split

3 files
  1. src/asm/type_signature.cpp +3 −3
  2. src/vm/execution_table.cpp +20 −20
  3. src/vm/vm.cpp +0 −4
src/asm/type_signature.cpp+3−3
@@ -1,13 +1,13 @@
11 //
22 // Dis VM
3−// File: opcode_tokens.cpp
3+// File: type_signature.cpp
44 // Author: arr
55 //
66
77 #include <vm_asm.h>
88 #include <array>
9−#include "rfc1321\global.h"
10−#include "rfc1321\md5.h"
9+#include "rfc1321/global.h"
10+#include "rfc1321/md5.h"
1111
1212 using namespace disvm::assembly::sigkind;
1313
src/vm/execution_table.cpp+20−20
@@ -635,7 +635,7 @@ namespace · 634 unmodified lines
635635 const auto value = at_val<vm_string_t>(r.src);
636636
637637 assert(r.dest != nullptr);
638− const auto table = reinterpret_cast<const word_t *>(r.dest);
638+ auto table = reinterpret_cast<word_t *>(r.dest);
639639 const auto entry_count = table[case_op_constants::table_length_index];
640640
641641 // Initialize the target PC with the fallback value.
@@ -648,7 +648,7 @@ namespace · 6 unmodified lines
648648 // Find the matching table entry
649649 for (auto entry = word_t{ 0 }; entry < entry_count; ++entry)
650650 {
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));
652652
653653 // Compare the value against the low string
654654 int result = vm_string_t::compare(value, string_low);
@@ -662,7 +662,7 @@ namespace · 7 unmodified lines
662662 }
663663
664664 // 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));
666666 if (string_high == nullptr || vm_string_t::compare(value, string_high) != 0)
667667 {
668668 current_entry += case_op_constants::entry_length;
@@ -692,7 +692,7 @@ namespace · 23 unmodified lines
692692 EXEC_DECL(lenc)
693693 {
694694 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);
696696 if (str != nullptr)
697697 len = str->get_length();
698698
@@ -740,14 +740,14 @@ namespace · 41 unmodified lines
740740 }
741741 }
742742
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)
744744 {
745745 if (s1 == nullptr)
746746 {
747747 if (s2 == nullptr)
748− return new vm_string_t();
748+ return new vm_string_t{};
749749
750− return new vm_string_t(*s2, 0, s2->get_length());
750+ return new vm_string_t{ *s2, 0, s2->get_length() };
751751 }
752752
753753 // There are other references to this string so we will not alter it.
@@ -776,14 +776,14 @@ namespace · 22 unmodified lines
776776 EXEC_DECL(addc)
777777 {
778778 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);
780780 auto dest_maybe = at_val<vm_string_t>(r.dest);
781781
782782 // If the source is the same as the destination and the
783783 // destination is not null, append the string. This can
784784 // change during the concat process.
785785 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);
787787
788788 if (!append_to_source)
789789 {
@@ -822,7 +822,7 @@ namespace · 32 unmodified lines
822822 EXEC_DECL(lena)
823823 {
824824 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);
826826 if (arr != nullptr)
827827 len = arr->get_length();
828828
@@ -872,7 +872,7 @@ namespace · 43 unmodified lines
872872
873873 void _index_in(vm_registers_t &r)
874874 {
875− auto arr = at_val<vm_array_t>(r.src);
875+ const auto arr = at_val<vm_array_t>(r.src);
876876 if (arr == nullptr)
877877 throw dereference_nil{ "Indexing into array" };
878878
@@ -897,7 +897,7 @@ namespace · 18 unmodified lines
897897 EXEC_DECL(lenl)
898898 {
899899 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);
901901 if (list != nullptr)
902902 {
903903 assert(list->alloc_type == vm_list_t::type_desc());
@@ -983,7 +983,7 @@ namespace · 79 unmodified lines
983983 template<typename PrimitiveType>
984984 void _head(vm_registers_t &r)
985985 {
986− auto head = at_val<vm_list_t>(r.src);
986+ const auto head = at_val<vm_list_t>(r.src);
987987 if (head == nullptr)
988988 throw dereference_nil{ "Head of list" };
989989
@@ -999,7 +999,7 @@ namespace · 9 unmodified lines
999999
10001000 EXEC_DECL(headp)
10011001 {
1002− auto list = at_val<vm_list_t>(r.src);
1002+ const auto list = at_val<vm_list_t>(r.src);
10031003 if (list == nullptr)
10041004 throw dereference_nil{ "Head of list" };
10051005
@@ -1009,7 +1009,7 @@ namespace · 3 unmodified lines
10091009
10101010 EXEC_DECL(headmp)
10111011 {
1012− auto list = at_val<vm_list_t>(r.src);
1012+ const auto list = at_val<vm_list_t>(r.src);
10131013 if (list == nullptr)
10141014 throw dereference_nil{ "Head of list" };
10151015
@@ -1019,7 +1019,7 @@ namespace · 3 unmodified lines
10191019
10201020 EXEC_DECL(tail)
10211021 {
1022− auto list = at_val<vm_list_t>(r.src);
1022+ const auto list = at_val<vm_list_t>(r.src);
10231023 if (list == nullptr)
10241024 throw dereference_nil{ "Tail of list" };
10251025
@@ -1397,8 +1397,8 @@ namespace · 371 unmodified lines
13971397
13981398 EXEC_DECL(tcmp)
13991399 {
1400− auto s = at_val<vm_alloc_t>(r.src);
1401− auto d = at_val<vm_alloc_t>(r.dest);
1400+ const auto s = at_val<vm_alloc_t>(r.src);
1401+ const auto d = at_val<vm_alloc_t>(r.dest);
14021402
14031403 if (s == nullptr)
14041404 return;
@@ -1558,10 +1558,10 @@ namespace · 153 unmodified lines
15581558
15591559 EXEC_DECL(goto_)
15601560 {
1561− auto pc_index = vt_ref<word_t>(r.src);
1561+ const auto pc_index = vt_ref<word_t>(r.src);
15621562
15631563 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);
15651565
15661566 r.pc = pc_table[pc_index];
15671567 }
src/vm/vm.cpp+0−4
@@ -33,13 +33,9 @@ vm_t::vm_t( · 32 unmodified lines
3333 _gc = create_gc(*this);
3434
3535 if (create_scheduler == nullptr)
36− {
3736 _scheduler = std::make_unique<default_scheduler_t>(*this, default_system_thread_count, default_thread_quanta);
38− }
3937 else
40− {
4138 _scheduler = create_scheduler(*this);
42− }
4339 }
4440
4541 vm_t::vm_t(uint32_t system_thread_count, uint32_t thread_quanta)