History

Various work for tool support in the VM. Update some type names (i.e. _t) and alter API signatures to be more consistent.

arr committed 10 years ago

Commit e5d3f861 parent bcb413516 files · +514 −45Browse files

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

Unified · Split

src/vm/vm.cpp+17−2
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 using namespace disvm;
2020 using namespace disvm::runtime;
2121
22−vm_t::loaded_module_t::loaded_module_t(std::unique_ptr<runtime::vm_string_t> origin, std::shared_ptr<const runtime::vm_module_t> module)
22+vm_t::loaded_module_t::loaded_module_t(std::unique_ptr<runtime::vm_string_t> origin, std::shared_ptr<runtime::vm_module_t> module)
2323 : origin{ std::move(origin) }
2424 , module{ module }
2525 {
@@ -126,7 +126,7 @@ const runtime::vm_thread_t& vm_t::fork( · 100 unmodified lines
126126 if (initial_pc < 0 || static_cast<vm_pc_t>(module_ref.code_section.size()) <= initial_pc)
127127 throw vm_system_exception{ "Invalid entry program counter" };
128128
129− auto thread = std::make_unique<vm_thread_t>(module_ref, initial_frame, initial_pc, parent.get_thread_id());
129+ auto thread = std::make_unique<vm_thread_t>(module_ref, parent.get_thread_id(), initial_frame, initial_pc);
130130 return _scheduler->schedule_thread(std::move(thread));
131131 }
132132
@@ -179,6 +179,21 @@ std::shared_ptr<const runtime::vm_module_t> vm_t::load_module(const char *path) · 46 unmodified lines
179179 return new_module;
180180 }
181181
182+std::vector<std::shared_ptr<const runtime::vm_module_t>> vm_t::get_loaded_modules() const
183+{
184+ auto result = std::vector<std::shared_ptr<const runtime::vm_module_t>>{};
185+
186+ std::lock_guard<std::mutex> lock{ _modules_lock };
187+ for (auto &m : _modules)
188+ {
189+ auto loaded_module_maybe = m.module.lock();
190+ if (loaded_module_maybe != nullptr)
191+ result.push_back(loaded_module_maybe);
192+ }
193+
194+ return result;
195+}
196+
182197 runtime::vm_scheduler_control_t &vm_t::get_scheduler_control() const
183198 {
184199 return _scheduler->get_controller();