11#ifndef ARK_VM_DEBUGGER_HPP
12#define ARK_VM_DEBUGGER_HPP
59 Debugger(
const ExecutionContext& context,
const std::vector<std::filesystem::path>& libenv,
const std::vector<std::string>& symbols,
const std::vector<Value>& constants);
70 Debugger(
const std::vector<std::filesystem::path>& libenv,
const std::string& path_to_prompt_file, std::ostream& os,
const std::vector<std::string>& symbols,
const std::vector<Value>& constants);
95 [[nodiscard]]
inline bool isRunning() const noexcept
123 static std::optional<std::string>
getCommandArg(
const std::string& command,
const std::string& line);
125 [[nodiscard]] std::optional<std::size_t>
getArgAndParseOrError(
const std::string& command,
const std::string& line, std::size_t default_value)
const;
136 [[nodiscard]] std::optional<CompiledPrompt>
compile(
const std::string& code, std::size_t start_page_at_offset)
const;
Common code for the compiler.
Keeping track of the internal data needed by the VM.
Default value type handled by the virtual machine.
The ArkScript virtual machine, executing ArkScript bytecode.
void run(VM &vm, ExecutionContext &context, bool from_breakpoint)
Start the debugger shell.
std::string m_code
Code added while inside the debugger.
std::vector< std::unique_ptr< SavedState > > m_states
static std::optional< std::size_t > parseStringAsInt(const std::string &str)
void showStack(VM &vm, const ExecutionContext &context, std::size_t count) const
void showLocals(VM &vm, ExecutionContext &context, std::size_t count) const
bool shouldQuitVM() const noexcept
std::optional< std::string > prompt(std::size_t ip, std::size_t pp, VM &vm, ExecutionContext &context)
void resetContextToSavedState(ExecutionContext &context)
Reset a VM context to the last state saved by the debugger.
Debugger(const ExecutionContext &context, const std::vector< std::filesystem::path > &libenv, const std::vector< std::string > &symbols, const std::vector< Value > &constants)
Create a new Debugger object.
std::optional< std::size_t > getArgAndParseOrError(const std::string &command, const std::string &line, std::size_t default_value) const
bool isRunning() const noexcept
std::unique_ptr< std::istream > m_prompt_stream
std::vector< std::string > m_symbols
static std::optional< std::string > getCommandArg(const std::string &command, const std::string &line)
void showContext(const VM &vm, const ExecutionContext &context) const
void saveState(const ExecutionContext &context)
Save the current VM state, to get back to it once the debugger is done running.
std::vector< std::filesystem::path > m_libenv
std::vector< Value > m_constants
std::optional< CompiledPrompt > compile(const std::string &code, std::size_t start_page_at_offset) const
Take care of compiling new code using the existing data tables.
std::vector< Value > constants
std::vector< std::string > symbols
std::vector< bytecode_t > pages
std::vector< ScopeView > locals
std::vector< std::shared_ptr< ClosureScope > > closure_scopes