Change scope_ids table to use refs.
This commit is contained in:
parent
f0772fbf11
commit
2b5be6ca49
@ -53,11 +53,11 @@ fn handle_insert_error(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_node_children(
|
fn gather_node_children<'a>(
|
||||||
node: &impl AstNode,
|
node: &'a impl AstNode,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
for child in node.children() {
|
for child in node.children() {
|
||||||
@ -65,11 +65,11 @@ fn gather_node_children(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_node(
|
fn gather_node<'a>(
|
||||||
node: AstNodeRef,
|
node: AstNodeRef<'a>,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
match node {
|
match node {
|
||||||
@ -333,11 +333,11 @@ fn gather_node(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gather_compilation_unit(
|
pub fn gather_compilation_unit<'a>(
|
||||||
compilation_unit: &mut CompilationUnit,
|
compilation_unit: &'a mut CompilationUnit,
|
||||||
file_name: &str,
|
file_name: &str,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let mut fqn_context = FqnContext::new();
|
let mut fqn_context = FqnContext::new();
|
||||||
@ -421,11 +421,11 @@ fn gather_concrete_use_symbol(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_module(
|
fn gather_module<'a>(
|
||||||
module: &Module,
|
module: &'a Module,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let module_symbol = ModuleSymbol::new(
|
let module_symbol = ModuleSymbol::new(
|
||||||
@ -462,11 +462,11 @@ fn gather_module(
|
|||||||
fqn_context.pop();
|
fqn_context.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_interface(
|
fn gather_interface<'a>(
|
||||||
interface: &Interface,
|
interface: &'a Interface,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let type_symbol = ConcreteTypeSymbol::new(
|
let type_symbol = ConcreteTypeSymbol::new(
|
||||||
@ -506,11 +506,11 @@ fn gather_interface(
|
|||||||
fqn_context.pop();
|
fqn_context.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_class(
|
fn gather_class<'a>(
|
||||||
class: &Class,
|
class: &'a Class,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let class_symbol = ConcreteTypeSymbol::new(
|
let class_symbol = ConcreteTypeSymbol::new(
|
||||||
@ -557,11 +557,11 @@ fn gather_class(
|
|||||||
fqn_context.pop();
|
fqn_context.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_function(
|
fn gather_function<'a>(
|
||||||
function: &Function,
|
function: &'a Function,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -613,11 +613,11 @@ fn gather_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_operator_function(
|
fn gather_operator_function<'a>(
|
||||||
operator_function: &OperatorFunction,
|
operator_function: &'a OperatorFunction,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -674,11 +674,11 @@ fn gather_operator_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_platform_function(
|
fn gather_platform_function<'a>(
|
||||||
platform_function: &PlatformFunction,
|
platform_function: &'a PlatformFunction,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -728,11 +728,11 @@ fn gather_platform_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_platform_operator_function(
|
fn gather_platform_operator_function<'a>(
|
||||||
platform_operator_function: &PlatformOperatorFunction,
|
platform_operator_function: &'a PlatformOperatorFunction,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -782,11 +782,11 @@ fn gather_platform_operator_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_interface_function(
|
fn gather_interface_function<'a>(
|
||||||
interface_function: &InterfaceFunction,
|
interface_function: &'a InterfaceFunction,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -836,11 +836,11 @@ fn gather_interface_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_interface_default_function(
|
fn gather_interface_default_function<'a>(
|
||||||
interface_default_function: &InterfaceDefaultFunction,
|
interface_default_function: &'a InterfaceDefaultFunction,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -897,11 +897,11 @@ fn gather_interface_default_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_interface_operator_function(
|
fn gather_interface_operator_function<'a>(
|
||||||
interface_operator_function: &InterfaceOperatorFunction,
|
interface_operator_function: &'a InterfaceOperatorFunction,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -951,11 +951,11 @@ fn gather_interface_operator_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_interface_default_operator_function(
|
fn gather_interface_default_operator_function<'a>(
|
||||||
interface_default_operator_function: &InterfaceDefaultOperatorFunction,
|
interface_default_operator_function: &'a InterfaceDefaultOperatorFunction,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
let function_symbol = FunctionSymbol::without_parameters_or_return_type(
|
||||||
@ -1032,11 +1032,11 @@ fn gather_interface_default_operator_function(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_function_body(
|
fn gather_function_body<'a>(
|
||||||
function_body: &FunctionBody,
|
function_body: &'a FunctionBody,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
symbol_table.push_scope("FunctionBodyScope");
|
symbol_table.push_scope("FunctionBodyScope");
|
||||||
@ -1050,11 +1050,11 @@ fn gather_function_body(
|
|||||||
symbol_table.pop_scope();
|
symbol_table.pop_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_member(
|
fn gather_member<'a>(
|
||||||
member: &Member,
|
member: &'a Member,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let member_symbol = ClassMemberSymbol::new(
|
let member_symbol = ClassMemberSymbol::new(
|
||||||
@ -1082,11 +1082,11 @@ fn gather_member(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_variable_declaration(
|
fn gather_variable_declaration<'a>(
|
||||||
variable_declaration: &VariableDeclaration,
|
variable_declaration: &'a VariableDeclaration,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
fqn_context: &mut FqnContext,
|
fqn_context: &mut FqnContext,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
diagnostics: &mut Vec<DmDiagnostic>,
|
diagnostics: &mut Vec<DmDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let variable_symbol = VariableSymbol::new(
|
let variable_symbol = VariableSymbol::new(
|
||||||
@ -1117,10 +1117,10 @@ fn gather_variable_declaration(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gather_variable_use(
|
fn gather_variable_use<'a>(
|
||||||
variable_use: &VariableUse,
|
variable_use: &'a VariableUse,
|
||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
scope_ids: &mut HashMap<VariableUse, usize>,
|
scope_ids: &mut HashMap<&'a VariableUse, usize>,
|
||||||
) {
|
) {
|
||||||
scope_ids.insert(variable_use.clone(), symbol_table.current_scope_id());
|
scope_ids.insert(variable_use, symbol_table.current_scope_id());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ pub fn analyze_names<'a, F: Files<'a, FileId = usize, Name = String>>(
|
|||||||
symbol_table: &mut SymbolTable,
|
symbol_table: &mut SymbolTable,
|
||||||
) -> Vec<DmDiagnostic> {
|
) -> Vec<DmDiagnostic> {
|
||||||
let mut diagnostics = vec![];
|
let mut diagnostics = vec![];
|
||||||
let mut scope_ids: HashMap<VariableUse, usize> = HashMap::new();
|
let mut scope_ids: HashMap<&VariableUse, usize> = HashMap::new();
|
||||||
|
|
||||||
// gather symbols
|
// gather symbols
|
||||||
for compilation_unit in compilation_units.iter_mut() {
|
for compilation_unit in compilation_units.iter_mut() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user