mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
feat: implement expression checker (#714)
* feat: implements expression checker * dev: resolve information * dev: delete def_use * stage * stage * stage * stage concurrent * stage concurrent * dev: better concurrency * dev: final constant evaluation improvement * dev: change reference site * dev: handle comments * dev: remove indirect import structure * dev: adjust linked_def impl * dev: finalize goto definition impl * dev: replace all old import and def_use analyses with expr analysis * dev: update expr_of snapshots * dev: split def/expr, refactor definition * dev: more consistent definition solver * dev: rename definition crate * dev: references work again * dev: resolve root decl * dev: resolve root decl * dev: resolve global definitions * dev: resolve tokens with world * feat: render semantic tokens with expression information * dev: loop detection * dev: recover type checking * dev: recover more type checking * dev: refactor analysis context * fix: process case of spread left * dev: label inference * dev: recover more signature checking * dev: recover more ident reference checking * dev: pass all tests * Revert "dev: dirty changes" This reverts commit 9ae2dacd0c96851e088feea76c61c184a1cf9722. * test: update snapshot * fix: bad cached signatures * fix: slash problem
This commit is contained in:
parent
136b162360
commit
81ebc8a635
173 changed files with 5529 additions and 4370 deletions
|
@ -46,3 +46,53 @@ pub fn bind_ty_ctx(input: TokenStream) -> TokenStream {
|
|||
// Hand the output tokens back to the compiler
|
||||
TokenStream::from(expanded)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(DeclEnum)]
|
||||
pub fn gen_decl_enum(input: TokenStream) -> TokenStream {
|
||||
// In form of
|
||||
// ```
|
||||
// pub enum Decl {
|
||||
// Sub1(X),
|
||||
// Sub2(Y),
|
||||
// }
|
||||
// ```
|
||||
|
||||
// Parse the input tokens into a list of variants
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
let variants = match input.data {
|
||||
syn::Data::Enum(data) => data.variants,
|
||||
_ => panic!("only enums are supported"),
|
||||
};
|
||||
|
||||
let names = variants.iter().map(|v| &v.ident).collect::<Vec<_>>();
|
||||
|
||||
let input_name = &input.ident;
|
||||
|
||||
let expanded = quote! {
|
||||
impl #input_name {
|
||||
pub fn name(&self) -> &Interned<str> {
|
||||
match self {
|
||||
#(Self::#names(x) => x.name()),*
|
||||
}
|
||||
}
|
||||
|
||||
pub fn span(&self) -> Span {
|
||||
match self {
|
||||
#(Self::#names(x) => x.span()),*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Decl {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
#(Self::#names(x) => write!(f, concat!(stringify!(#names), "({:?})"), x)),*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TokenStream::from(expanded)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue