use std::collections::HashMap; use crate::ast::ast_node::AstNodeRef; use crate::ast::node::{CompilationUnit, Identifier}; use crate::ast::walk::walk_depth_first; use crate::diagnostic::DmDiagnostic; use crate::name_analysis::symbol_table::SymbolTable; fn gather_identifier(identifier: &Identifier, symbol_table: &SymbolTable, identifier_scope_ids: &mut HashMap<&Identifier, usize>) { identifier_scope_ids[identifier] = symbol_table.current_scope_id(); } pub fn gather_compilation_unit( compilation_unit: &mut CompilationUnit, symbol_table: &mut SymbolTable, identifier_scope_ids: &mut HashMap<&Identifier, usize>, diagnostics: &mut Vec, ) { walk_depth_first(compilation_unit, &mut |child| match child { AstNodeRef::Operator(_) => {} AstNodeRef::Identifier(identifier) => { gather_identifier(&identifier, symbol_table, identifier_scope_ids); } AstNodeRef::FullyQualifiedName(_) => {} AstNodeRef::TypeUseList(_) => {} AstNodeRef::IdentifierList(_) => {} AstNodeRef::ParenthesesOptionalTypeUseList(_) => {} AstNodeRef::TypeUse(_) => {} AstNodeRef::PrimitiveType(_) => {} AstNodeRef::TypedArray(_) => {} AstNodeRef::InterfaceOrClassTypeUse(_) => {} AstNodeRef::TupleTypeUse(_) => {} AstNodeRef::FunctionTypeUse(_) => {} AstNodeRef::GenericArguments(_) => {} AstNodeRef::GenericParameters(_) => {} AstNodeRef::TupleArguments(_) => {} AstNodeRef::ImplementsList(_) => {} AstNodeRef::Parameters(_) => {} AstNodeRef::Parameter(_) => {} AstNodeRef::ReturnType(_) => {} AstNodeRef::CompilationUnit(_) => {} AstNodeRef::ParentMod(_) => {} AstNodeRef::UseStatement(_) => {} AstNodeRef::UseStatementPrefix(_) => {} AstNodeRef::UseStatementSuffix(_) => {} AstNodeRef::UseList(_) => {} AstNodeRef::ModuleLevelDeclaration(_) => {} AstNodeRef::InterfaceLevelDeclaration(_) => {} AstNodeRef::ClassLevelDeclaration(_) => {} AstNodeRef::Module(_) => {} AstNodeRef::CompanionModule(_) => {} AstNodeRef::Interface(_) => {} AstNodeRef::Class(_) => {} AstNodeRef::Function(_) => {} AstNodeRef::OperatorFunction(_) => {} AstNodeRef::PlatformFunction(_) => {} AstNodeRef::InterfaceFunction(_) => {} AstNodeRef::InterfaceDefaultFunction(_) => {} AstNodeRef::InterfaceOperatorFunction(_) => {} AstNodeRef::InterfaceDefaultOperatorFunction(_) => {} AstNodeRef::FunctionBody(_) => {} AstNodeRef::FunctionEqualsBody(_) => {} AstNodeRef::FunctionAliasBody(_) => {} AstNodeRef::FunctionBlockBody(_) => {} AstNodeRef::ClassConstructor(_) => {} AstNodeRef::Member(_) => {} AstNodeRef::Statement(_) => {} AstNodeRef::VariableDeclaration(_) => {} AstNodeRef::AssignmentStatement(_) => {} AstNodeRef::ExpressionStatement(_) => {} AstNodeRef::IfStatement(_) => {} AstNodeRef::IfClause(_) => {} AstNodeRef::IfElseIf(_) => {} AstNodeRef::IfElse(_) => {} AstNodeRef::WhileStatement(_) => {} AstNodeRef::ForStatement(_) => {} AstNodeRef::Expression(_) => {} AstNodeRef::TernaryExpression(_) => {} AstNodeRef::TernaryRhs(_) => {} AstNodeRef::OrExpression(_) => {} AstNodeRef::OrRhs(_) => {} AstNodeRef::AndExpression(_) => {} AstNodeRef::AndRhs(_) => {} AstNodeRef::ComparisonExpression(_) => {} AstNodeRef::ComparisonRhs(_) => {} AstNodeRef::ComparisonOperator(_) => {} AstNodeRef::ShiftExpression(_) => {} AstNodeRef::ShiftRhs(_) => {} AstNodeRef::ShiftOperator(_) => {} AstNodeRef::AdditiveExpression(_) => {} AstNodeRef::AdditiveRhs(_) => {} AstNodeRef::AdditiveOperator(_) => {} AstNodeRef::MultiplicativeExpression(_) => {} AstNodeRef::MultiplicativeRhs(_) => {} AstNodeRef::MultiplicativeOperator(_) => {} AstNodeRef::PrefixExpression(_) => {} AstNodeRef::PrefixOperator(_) => {} AstNodeRef::SuffixExpression(_) => {} AstNodeRef::SuffixOperator(_) => {} AstNodeRef::ObjectProperty(_) => {} AstNodeRef::ObjectIndex(_) => {} AstNodeRef::ListExpression(_) => {} AstNodeRef::Call(_) => {} AstNodeRef::ParenthesesCall(_) => {} AstNodeRef::NonParenthesesCall(_) => {} AstNodeRef::TurboFish(_) => {} AstNodeRef::ExpressionList(_) => {} AstNodeRef::Closure(_) => {} AstNodeRef::ClosureParameters(_) => {} AstNodeRef::ClosureParameter(_) => {} AstNodeRef::Literal(_) => {} AstNodeRef::DString(_) => {} AstNodeRef::DStringExpression(_) => {} AstNodeRef::BacktickString(_) => {} }); }