use std::sync::Arc;
use mir_codebase::storage::{Assertion, FnParam, Location, TemplateParam, Visibility};
use mir_codebase::StubSlice;
use mir_issues::Issue;
use mir_types::Union;
#[salsa::input]
pub struct SourceFile {
pub path: Arc<str>,
pub text: Arc<str>,
}
#[derive(Clone, Debug)]
pub struct FileDefinitions {
pub slice: Arc<StubSlice>,
pub issues: Arc<Vec<Issue>>,
}
impl PartialEq for FileDefinitions {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.slice, &other.slice) && Arc::ptr_eq(&self.issues, &other.issues)
}
}
unsafe impl salsa::Update for FileDefinitions {
unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
unsafe { *old_pointer = new_value };
true
}
}
pub type ImplementsTypeArgs = Arc<[(Arc<str>, Arc<[Union]>)]>;
#[salsa::input]
pub struct ClassNode {
pub fqcn: Arc<str>,
pub active: bool,
pub is_interface: bool,
pub is_trait: bool,
pub is_enum: bool,
pub is_abstract: bool,
pub parent: Option<Arc<str>>,
pub interfaces: Arc<[Arc<str>]>,
pub traits: Arc<[Arc<str>]>,
pub extends: Arc<[Arc<str>]>,
pub template_params: Arc<[TemplateParam]>,
pub require_extends: Arc<[Arc<str>]>,
pub require_implements: Arc<[Arc<str>]>,
pub is_backed_enum: bool,
pub mixins: Arc<[Arc<str>]>,
pub deprecated: Option<Arc<str>>,
pub enum_scalar_type: Option<Union>,
pub is_final: bool,
pub is_readonly: bool,
pub location: Option<Location>,
pub extends_type_args: Arc<[Union]>,
pub implements_type_args: ImplementsTypeArgs,
}
#[salsa::input]
pub struct FunctionNode {
pub fqn: Arc<str>,
pub short_name: Arc<str>,
pub active: bool,
pub params: Arc<[FnParam]>,
pub return_type: Option<Arc<Union>>,
pub inferred_return_type: Option<Arc<Union>>,
pub template_params: Arc<[TemplateParam]>,
pub assertions: Arc<[Assertion]>,
pub throws: Arc<[Arc<str>]>,
pub deprecated: Option<Arc<str>>,
pub is_pure: bool,
pub location: Option<Location>,
}
#[salsa::input]
pub struct MethodNode {
pub fqcn: Arc<str>,
pub name: Arc<str>,
pub active: bool,
pub params: Arc<[FnParam]>,
pub return_type: Option<Arc<Union>>,
pub inferred_return_type: Option<Arc<Union>>,
pub template_params: Arc<[TemplateParam]>,
pub assertions: Arc<[Assertion]>,
pub throws: Arc<[Arc<str>]>,
pub deprecated: Option<Arc<str>>,
pub is_internal: bool,
pub visibility: Visibility,
pub is_static: bool,
pub is_abstract: bool,
pub is_final: bool,
pub is_constructor: bool,
pub is_pure: bool,
pub location: Option<Location>,
}
#[salsa::input]
pub struct PropertyNode {
pub fqcn: Arc<str>,
pub name: Arc<str>,
pub active: bool,
pub ty: Option<Union>,
pub visibility: Visibility,
pub is_static: bool,
pub is_readonly: bool,
pub location: Option<Location>,
}
#[salsa::input]
pub struct ClassConstantNode {
pub fqcn: Arc<str>,
pub name: Arc<str>,
pub active: bool,
pub ty: Union,
pub visibility: Option<Visibility>,
pub is_final: bool,
pub location: Option<Location>,
}
#[salsa::input]
pub struct GlobalConstantNode {
pub fqn: Arc<str>,
pub active: bool,
pub ty: Union,
}
#[derive(Clone, Debug, Default)]
pub struct Ancestors(pub Vec<Arc<str>>);
impl PartialEq for Ancestors {
fn eq(&self, other: &Self) -> bool {
self.0.len() == other.0.len()
&& self
.0
.iter()
.zip(&other.0)
.all(|(a, b)| a.as_ref() == b.as_ref())
}
}
unsafe impl salsa::Update for Ancestors {
unsafe fn maybe_update(old_ptr: *mut Self, new_val: Self) -> bool {
let old = unsafe { &mut *old_ptr };
if *old == new_val {
return false;
}
*old = new_val;
true
}
}