Added support for defining macros in Rust within the macro system

Also fixed a lot of bugs
This commit is contained in:
2025-09-30 21:23:16 +02:00
parent 7971a2b4eb
commit b77653f841
52 changed files with 849 additions and 502 deletions

View File

@@ -11,23 +11,25 @@ use orchid_base::reqnot::Requester;
use crate::api;
use crate::system::{SysCtx, SysCtxEntry, WeakSysCtx};
#[derive(Debug)]
pub struct ReflMemData {
// None for inferred steps
public: OnceCell<bool>,
kind: ReflMemKind,
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct ReflMem(Rc<ReflMemData>);
impl ReflMem {
pub fn kind(&self) -> ReflMemKind { self.0.kind.clone() }
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum ReflMemKind {
Const,
Mod(ReflMod),
}
#[derive(Debug)]
pub struct ReflModData {
inferred: Mutex<bool>,
path: VPath,
@@ -35,7 +37,7 @@ pub struct ReflModData {
members: MemoMap<Tok<String>, ReflMem>,
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct ReflMod(Rc<ReflModData>);
impl ReflMod {
fn ctx(&self) -> SysCtx {
@@ -116,8 +118,8 @@ impl ReflMod {
Err(api::LsModuleError::InvalidPath) => Err(InvalidPathError { keep_ancestry: false }),
Err(api::LsModuleError::IsConstant) => {
let const_mem = default_member(self.is_root(), ReflMemKind::Const);
self.0.members.insert(next.clone(), const_mem);
Err(InvalidPathError { keep_ancestry: true })
self.0.members.insert(next.clone(), const_mem.clone());
Ok(const_mem)
},
Err(api::LsModuleError::TreeUnavailable) => unreachable!(),
};
@@ -136,6 +138,7 @@ impl ReflMod {
struct ReflRoot(ReflMod);
impl SysCtxEntry for ReflRoot {}
#[derive(Clone, Debug)]
pub struct InvalidPathError {
keep_ancestry: bool,
}