Experimenting with the LSP

This commit is contained in:
Mia
2026-03-08 14:34:12 +01:00
parent 2aababbbe1
commit 45fd421e19
16 changed files with 1682 additions and 228 deletions
+2 -13
View File
@@ -1,7 +1,7 @@
use crate::{
assembly::Assembly,
types::Type,
values::{AnyConst, AnyValue, Value, ValueFlags},
values::{AnyConst, AnyValue, Value, ValueFlags, default_associated_values},
};
use derive_more::{Debug, Display};
use fxhash::FxBuildHasher;
@@ -51,21 +51,10 @@ impl<'l> Value<'l> for &'l StructT<'l> {
}
fn get_associated_value(&self, name: &str) -> Option<AnyValue<'l>> {
todo!()
default_associated_values(self, name)
}
fn as_any_value(&self) -> AnyValue<'l> {
AnyValue::Constant(AnyConst::Type(Type::Struct(self)))
}
}
struct DebugFields<'l, 'r>(&'r OnceLock<FieldMap<'l>>);
impl std::fmt::Debug for DebugFields<'_, '_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.0.get() {
Some(v) => std::fmt::Debug::fmt(v, f),
None => f.write_str("{}"),
}
}
}
+2 -3
View File
@@ -88,7 +88,6 @@ impl<'l> Value<'l> for Float {
Float::F16(v) => v.ty(),
Float::F32(v) => v.ty(),
Float::F64(v) => v.ty(),
_ => unreachable!(),
}
}
@@ -199,13 +198,13 @@ impl<'l> Value<'l> for AnyConst<'l> {
Self::Str(s) => s.ty(),
Self::Struct(t, _) => Type::Struct(t),
Self::SizeOf(_) => Type::USIZE,
_ => todo!("{self:?}"),
Self::Function(f) => Type::Func(f.ty),
}
}
fn flags(&self) -> super::ValueFlags {
match self {
AnyConst::Function(f) => ValueFlags::Function,
AnyConst::Function(_) => ValueFlags::Function,
AnyConst::Type(_) => ValueFlags::Type,
_ => ValueFlags::Const,
}