WIP redoing name analysis.
This commit is contained in:
parent
d6faa37515
commit
c32ae72beb
@ -44,9 +44,30 @@ pub fn make_ast_node_impl(build_spec: &BuildSpec) -> Option<TokenStream> {
|
||||
pub fn make_ast_enum_member(build_spec: &BuildSpec) -> Option<TokenStream> {
|
||||
match build_spec {
|
||||
BuildSpec::Struct(struct_spec) => {
|
||||
let type_ident = format_ident!("{}", struct_spec.build());
|
||||
Some(quote! { #type_ident(#type_ident) })
|
||||
Some(format_ident!("{}", struct_spec.build()))
|
||||
}
|
||||
_ => None,
|
||||
BuildSpec::LeafStruct(leaf_struct) => {
|
||||
Some(format_ident!("{}", leaf_struct.build()))
|
||||
}
|
||||
BuildSpec::Enum(enum_spec) => {
|
||||
Some(format_ident!("{}", enum_spec.build()))
|
||||
}
|
||||
BuildSpec::LeafEnum(leaf_enum) => {
|
||||
Some(format_ident!("{}", leaf_enum.build()))
|
||||
}
|
||||
BuildSpec::PolymorphicType(polymorphic_type) => {
|
||||
Some(format_ident!("{}", polymorphic_type.name()))
|
||||
},
|
||||
BuildSpec::PolymorphicEnumLoop(polymorphic_enum_loop) => {
|
||||
Some(format_ident!("{}", polymorphic_enum_loop.name()))
|
||||
}
|
||||
BuildSpec::PolymorphicPassThrough(_) => None,
|
||||
BuildSpec::Production(_) => None,
|
||||
BuildSpec::NodeProduction(_) => None,
|
||||
}
|
||||
.map(|type_ident| {
|
||||
quote! {
|
||||
#type_ident(#type_ident)
|
||||
}
|
||||
})
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
1320
src/name_analysis/gather.rs.bak
Normal file
1320
src/name_analysis/gather.rs.bak
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,15 +19,16 @@ The resolve phase has one main responsibility: resolve all references based on t
|
||||
`scope_id` property.
|
||||
*/
|
||||
|
||||
use crate::ast::node::CompilationUnit;
|
||||
use crate::ast::node::{CompilationUnit, Identifier};
|
||||
use crate::diagnostic::DmDiagnostic;
|
||||
use crate::name_analysis::gather::gather_compilation_unit;
|
||||
use crate::name_analysis::resolve::resolve_compilation_unit;
|
||||
// use crate::name_analysis::resolve::resolve_compilation_unit;
|
||||
use crate::name_analysis::symbol_table::SymbolTable;
|
||||
use std::collections::HashMap;
|
||||
|
||||
mod fqn_context;
|
||||
mod gather;
|
||||
mod resolve;
|
||||
// mod resolve;
|
||||
pub mod symbol;
|
||||
pub mod symbol_table;
|
||||
|
||||
@ -36,15 +37,21 @@ pub fn analyze_names(
|
||||
symbol_table: &mut SymbolTable,
|
||||
) -> Vec<DmDiagnostic> {
|
||||
let mut diagnostics = vec![];
|
||||
let mut identifier_scope_ids: HashMap<&Identifier, usize> = HashMap::new();
|
||||
|
||||
// gather symbols
|
||||
for compilation_unit in compilation_units.iter_mut() {
|
||||
gather_compilation_unit(compilation_unit, symbol_table, &mut diagnostics);
|
||||
gather_compilation_unit(
|
||||
compilation_unit,
|
||||
symbol_table,
|
||||
&mut identifier_scope_ids,
|
||||
&mut diagnostics,
|
||||
);
|
||||
}
|
||||
|
||||
// resolve symbols
|
||||
for compilation_unit in compilation_units.iter_mut() {
|
||||
resolve_compilation_unit(compilation_unit, symbol_table, &mut diagnostics);
|
||||
// resolve_compilation_unit(compilation_unit, symbol_table, &mut diagnostics);
|
||||
}
|
||||
|
||||
diagnostics.into()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user