More work on resolution

This commit is contained in:
2026-05-06 14:52:43 -06:00
parent 0af9989323
commit aef0f83961

View File

@@ -74,7 +74,7 @@ pub fn rule<'db>(db: &'db dyn Database, ast: ast::Rule<'db>) -> Rule<'db> {
// if a body is present, resolve separately
Some(body) => rule_body(db, body),
// if a body is absent, create an explicit rule body by hand
// if a body is absent, create an implicit rule body by hand
None => RuleBody {
meta: ast.ast(db),
vars: Default::default(),
@@ -86,7 +86,7 @@ pub fn rule<'db>(db: &'db dyn Database, ast: ast::Rule<'db>) -> Rule<'db> {
},
};
// the head is empty for now because it is untyped
// the head is empty for now because types are unknown
let head = Default::default();
// resolve the name of the target relation
@@ -104,7 +104,15 @@ pub fn rule<'db>(db: &'db dyn Database, ast: ast::Rule<'db>) -> Rule<'db> {
/// Resolves all references in an [ast::Assumption].
#[salsa::tracked]
pub fn assumption<'db>(db: &'db dyn Database, ast: ast::Assumption<'db>) -> Assumption<'db> {
todo!()
// resolve the body
let body = rule_body(db, ast.body(db));
// assemble the completed assumption
Assumption {
meta: ast,
weight: todo!(),
body,
}
}
/// Resolves all references in an [ast::RuleBody].
@@ -192,7 +200,11 @@ pub fn expr<'db>(
Variable(vars.insert_full(VariableMeta::Named(name.clone())).0)
}
ast::ExprExtra::Apply(apply) => todo!(),
// application resolves the head and recursively resolves the body
ast::ExprExtra::Apply(apply) => Extra(Arc::new(ExprExtra::Apply(Apply {
body: resolve(&apply.body),
relation: loaded.insert_full(relation_name(db, apply.head.clone())).0,
}))),
ast::ExprExtra::Aggregate(aggregate) => todo!(),
},
@@ -241,7 +253,7 @@ impl<'db> ir::ProgramInfo for ProgramInfo<'db> {
/// [RelationLabel] fallibly identifies relations after the resolution stage.
type RelationLabel = RelationLabel<'db>;
type AssumptionMeta = Infallible;
type AssumptionMeta = ast::Assumption<'db>;
type RuleMeta = ast::Rule<'db>;
@@ -301,7 +313,7 @@ pub enum VariableMeta {
Hole(AstNode),
}
/// A high-level application operation.
/// A high-level, resolved application operation.
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct Apply<'db> {
/// The source relation's index in the parent [RuleBody].