refactor(ir): use u64 directly instead of spans for instructions

This commit is contained in:
multisn8 2024-01-19 14:26:20 +01:00
parent 87343f0a38
commit cdf42417da
Signed by: multisamplednight
GPG key ID: 6D525AA147CBDAE2
3 changed files with 10 additions and 46 deletions

View file

@ -1,4 +1,4 @@
use std::{num::NonZeroUsize, ops::RangeInclusive};
use std::num::NonZeroUsize;
use instruction::SocketCount;
use serde::{Deserialize, Serialize};
@ -268,26 +268,6 @@ impl<'ir> Instruction<'ir> {
}
}
/// Some part referred to in source code.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Span {
// would love to use an actual [`std::ops::RangeInclusive`], but those don't implement
// `PartialOrd` and `Ord` unfortunately
/// At which byte this span starts, inclusively.
pub from: usize,
/// At which byte this span ends, inclusively.
pub to: usize,
}
impl From<RangeInclusive<usize>> for Span {
fn from(range: RangeInclusive<usize>) -> Self {
Self {
from: *range.start(),
to: *range.end(),
}
}
}
/// Constructs an [`id::Socket`] a bit more tersely.
fn socket(id: &id::Instruction, idx: u16) -> id::Socket {
id::Socket {