/
githubmirror
/
sway
Обзор
Документация
Войти
/
githubmirror
/
sway
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
forc-plugins/forc-debug/src/server/util.rs
44 строки
1 KB
Joshua Batty
refactor: Improve DAP server code organisation and readability (#6770)
04 дек 2024, 01:17
Не верифицирован
04 дек 2024, 01:17
48f633d
Код
Авторство
О чём код?
use crate::types::Instruction; use dap::types::Source; use fuel_vm::fuel_asm::RegId; use std::path::Path; #[derive(Debug, Clone)] /// Utility for generating unique, incremental IDs. pub(crate) struct IdGenerator { next_id: i64, } impl Default for IdGenerator { fn default() -> Self { Self::new() } } impl IdGenerator { pub(crate) fn new() -> Self { Self { next_id: 0 } } pub(crate) fn next(&mut self) -> i64 { let id = self.next_id; self.next_id += 1; id } } /// Converts a filesystem path into a DAP Source object, which is used by the debug adapter /// to identify source locations. Only sets the path field, leaving other Source fields at /// their default values. pub(crate) fn path_into_source(path: &Path) -> Source { Source { path: Some(path.to_string_lossy().into_owned()), ..Default::default() } } pub(crate) fn current_instruction(registers: &[u64]) -> Instruction { let pc = registers[RegId::PC]; let is = registers[RegId::IS]; pc - is }