Skip to content

Commit

Permalink
preparing to introduce context in tyck
Browse files Browse the repository at this point in the history
  • Loading branch information
LighghtEeloo committed May 30, 2024
1 parent 0875d06 commit f9e69c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions zydeco-lang/statics/src/tyck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl Tycker {
}

pub trait Tyck {
type In;
type Out;
type Ann;
type Mode;
Expand Down Expand Up @@ -200,6 +201,7 @@ impl SyntacticallyAnnotated for su::TermId {

pub struct SccDeclarations<'decl>(pub &'decl HashSet<su::DeclId>);
impl<'decl> Tyck for SccDeclarations<'decl> {
type In = ();
type Out = ();
type Ann = ();
type Mode = ();
Expand Down Expand Up @@ -253,7 +255,7 @@ impl<'decl> Tyck for SccDeclarations<'decl> {
let internal_or = tycker.scoped.exts.get(id).cloned();
match internal_or {
| Some((internal, def)) => {
// the extern is a internal type
// the alias head is a internal type
let syn_kd = ty.unwrap();
match internal {
| su::Internal::VType => {
Expand Down Expand Up @@ -293,7 +295,7 @@ impl<'decl> Tyck for SccDeclarations<'decl> {
}
}
| None => {
// the extern is a primitive value that needs to be linked later
// the alias head is a primitive value that needs to be linked later
let Some(ty) = ty else {
Err(TyckError::MissingAnnotation(
tycker.spans.decls[id].clone(),
Expand Down Expand Up @@ -345,6 +347,7 @@ impl<'decl> Tyck for SccDeclarations<'decl> {
}

impl Tyck for su::DefId {
type In = ();
type Out = ();
type Ann = ();
type Mode = ();
Expand All @@ -361,9 +364,10 @@ impl Tyck for su::DefId {
}

impl Tyck for su::PatId {
type In = Self;
type Out = ss::PatId;
type Ann = ss::AnnId;
type Mode = Mode<Self, Self::Out, Self::Ann>;
type Mode = Mode<Self::In, Self::Out, Self::Ann>;
type Action = SelfAction<Self::Ann>;

fn tyck(&self, tycker: &mut Tycker, action: Self::Action) -> Result<(Self::Out, Self::Ann)> {
Expand Down Expand Up @@ -404,17 +408,18 @@ impl Tyck for su::PatId {
}

impl Tyck for su::TermId {
type In = (ss::Context<ss::AnnId>, Self);
type Out = ss::TermId;
type Ann = ss::AnnId;
type Mode = Mode<Self, Self::Out, Self::Ann>;
type Mode = Mode<Self::In, Self::Out, Self::Ann>;
type Action = Action<(), Self::Ann>;

fn tyck(&self, tycker: &mut Tycker, action: Self::Action) -> Result<(Self::Out, Self::Ann)> {
todo!()
}

fn tyck_step(
&self, tycker: &mut Tycker, Action { input: target, switch }: Self::Action,
&self, tycker: &mut Tycker, Action { input, switch }: Self::Action,
) -> Result<Self::Mode> {
// Fixme: nonsense right now
let term = tycker.scoped.terms[self].clone();
Expand Down
2 changes: 1 addition & 1 deletion zydeco-lang/surface/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Uses(pub Vec<UsePath>);

/* -------------------------------- TopLevel -------------------------------- */

// Todo: turn extern into a modifier / use macro to declare externs
// Note: use macro to declare externs?
#[derive(Clone, Debug)]
pub struct Modifiers<T> {
pub public: bool,
Expand Down

0 comments on commit f9e69c2

Please sign in to comment.