lift-core 0.4.4

LIFT compiler framework core: unified SSA intermediate representation (IR) for AI and quantum — types, values, operations, blocks, regions, verifier
Documentation
use crate::interning::StringId;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Location {
    pub file: Option<StringId>,
    pub line: u32,
    pub column: u32,
}

impl Location {
    pub fn unknown() -> Self {
        Self {
            file: None,
            line: 0,
            column: 0,
        }
    }

    pub fn new(file: StringId, line: u32, column: u32) -> Self {
        Self {
            file: Some(file),
            line,
            column,
        }
    }
}

impl std::fmt::Display for Location {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        if let Some(_file) = self.file {
            write!(f, "<file>:{}:{}", self.line, self.column)
        } else {
            write!(f, "<unknown>:{}:{}", self.line, self.column)
        }
    }
}