Remove useless DiagnosticsContainer struct; params_seen failing because unresolved types.
This commit is contained in:
parent
4f74136d97
commit
dcb261fd84
@ -3,9 +3,9 @@ use crate::ast::*;
|
||||
use crate::name_analysis::fqn_context::FqnContext;
|
||||
use crate::name_analysis::symbol::*;
|
||||
use crate::name_analysis::symbol_table::{ScopeLevel, SymbolInsertError, SymbolTable};
|
||||
use crate::name_analysis::DiagnosticsContainer;
|
||||
use codespan_reporting::diagnostic::{Diagnostic, Label};
|
||||
use std::range::Range;
|
||||
use crate::diagnostic::DmDiagnostic;
|
||||
|
||||
fn handle_insert_error(
|
||||
err: SymbolInsertError,
|
||||
@ -13,13 +13,12 @@ fn handle_insert_error(
|
||||
error_file_id: usize,
|
||||
error_range: Range<usize>,
|
||||
symbol_types: &str,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
match err {
|
||||
SymbolInsertError::SymbolAlreadyDefined(s) => {
|
||||
let already_defined_definition = s.definition();
|
||||
|
||||
diagnostics.add(
|
||||
diagnostics.push(
|
||||
Diagnostic::error()
|
||||
.with_message(format!(
|
||||
"{} symbol '{}' already defined in the current scope.",
|
||||
@ -52,7 +51,7 @@ fn gather_type_use(
|
||||
type_use: &mut TypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
match type_use {
|
||||
TypeUse::Void => {}
|
||||
@ -77,7 +76,7 @@ fn gather_interface_or_class_type_use(
|
||||
interface_or_class_type_use: &mut InterfaceOrClassTypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_fully_qualified_name(&mut interface_or_class_type_use.fqn, symbol_table);
|
||||
gather_generic_arguments(
|
||||
@ -92,7 +91,7 @@ fn gather_tuple_type_use(
|
||||
tuple_type_use: &mut TupleTypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for generic_argument in &mut tuple_type_use.arguments.0 {
|
||||
gather_type_use(generic_argument, symbol_table, fqn_context, diagnostics);
|
||||
@ -103,7 +102,7 @@ fn gather_function_type_use(
|
||||
function_type_use: &mut FunctionTypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
@ -112,7 +111,7 @@ fn gather_generic_arguments(
|
||||
generic_arguments: &mut GenericArguments,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for argument in &mut generic_arguments.0 {
|
||||
gather_type_use(argument, symbol_table, fqn_context, diagnostics);
|
||||
@ -122,7 +121,7 @@ fn gather_generic_arguments(
|
||||
pub(super) fn gather_compilation_unit(
|
||||
compilation_unit: &mut CompilationUnit,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
let mut fqn_context = FqnContext::new();
|
||||
if let Some(namespace) = &compilation_unit.namespace {
|
||||
@ -147,7 +146,7 @@ fn gather_use_statement(
|
||||
use_statement: &mut UseStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
if use_statement.is_star() {
|
||||
todo!()
|
||||
@ -190,7 +189,7 @@ fn gather_module_level_declaration(
|
||||
declaration: &mut ModuleLevelDeclaration,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use ModuleLevelDeclaration::*;
|
||||
match declaration {
|
||||
@ -219,7 +218,7 @@ fn gather_module_declaration(
|
||||
declaration: &mut ModuleDeclaration,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
// 1. Add mod identifier symbol
|
||||
// 2. Update fqn context
|
||||
@ -266,7 +265,7 @@ fn gather_class_declaration(
|
||||
class_declaration: &mut ClassDeclaration,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
let declared_name = class_declaration.identifier.name();
|
||||
let resolved_name = fqn_context.resolve(&declared_name);
|
||||
@ -298,7 +297,7 @@ fn gather_function_definition(
|
||||
function: &mut FunctionDefinition,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
let declared_name = function.identifier.name();
|
||||
let resolved_name = fqn_context.resolve(&declared_name);
|
||||
@ -347,7 +346,7 @@ fn gather_platform_function_definition(
|
||||
platform_function_declaration: &mut PlatformFunctionDeclaration,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
let declared_name = platform_function_declaration.identifier.name();
|
||||
let fully_qualified_name = fqn_context.resolve(&declared_name);
|
||||
@ -397,7 +396,7 @@ fn gather_parameters(
|
||||
parameters: &mut Parameters,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for parameter in &mut parameters.0 {
|
||||
gather_parameter(parameter, symbol_table, fqn_context, diagnostics);
|
||||
@ -408,7 +407,7 @@ fn gather_parameter(
|
||||
parameter: &mut Parameter,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
let parameter_name = parameter.identifier.name();
|
||||
|
||||
@ -448,7 +447,7 @@ fn gather_function_body(
|
||||
function_body: &mut FunctionBody,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use crate::ast::FunctionBody::*;
|
||||
match function_body {
|
||||
@ -461,7 +460,7 @@ fn gather_block_statement(
|
||||
block: &mut BlockStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
symbol_table.push_scope("BlockStatementScope", ScopeLevel::Function);
|
||||
gather_block_statement_inner(block, symbol_table, fqn_context, diagnostics);
|
||||
@ -472,7 +471,7 @@ fn gather_block_statement_inner(
|
||||
block: &mut BlockStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for statement in &mut block.statements {
|
||||
gather_statement(statement, symbol_table, fqn_context, diagnostics);
|
||||
@ -486,7 +485,7 @@ fn gather_statement(
|
||||
statement: &mut Statement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use crate::ast::Statement::*;
|
||||
match statement {
|
||||
@ -509,7 +508,7 @@ fn gather_statement(
|
||||
fn gather_variable_declaration(
|
||||
variable_declaration: &mut VariableDeclarationStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
let variable_name = variable_declaration.identifier.name();
|
||||
|
||||
@ -546,7 +545,7 @@ fn gather_assign_statement(
|
||||
assign_statement: &mut AssignStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
fqn_context: &mut FqnContext,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut assign_statement.lhs, symbol_table, diagnostics);
|
||||
gather_expression(&mut assign_statement.rhs, symbol_table, diagnostics);
|
||||
@ -555,7 +554,7 @@ fn gather_assign_statement(
|
||||
fn gather_call_statement(
|
||||
call_statement: &mut CallStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut call_statement.0, symbol_table, diagnostics);
|
||||
}
|
||||
@ -563,7 +562,7 @@ fn gather_call_statement(
|
||||
fn gather_expression(
|
||||
expression: &mut Expression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use crate::ast::Expression::*;
|
||||
match expression {
|
||||
@ -600,7 +599,7 @@ fn gather_expression(
|
||||
fn gather_ternary_expression(
|
||||
ternary_expression: &mut TernaryExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut ternary_expression.condition, symbol_table, diagnostics);
|
||||
gather_expression(
|
||||
@ -618,7 +617,7 @@ fn gather_ternary_expression(
|
||||
fn gather_binary_expression(
|
||||
binary_expression: &mut BinaryExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut binary_expression.left, symbol_table, diagnostics);
|
||||
gather_expression(&mut binary_expression.right, symbol_table, diagnostics);
|
||||
@ -627,7 +626,7 @@ fn gather_binary_expression(
|
||||
fn gather_prefix_expression(
|
||||
prefix_expression: &mut PrefixExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut prefix_expression.expression, symbol_table, diagnostics);
|
||||
}
|
||||
@ -635,7 +634,7 @@ fn gather_prefix_expression(
|
||||
fn gather_suffix_expression(
|
||||
suffix_expression: &mut SuffixExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut suffix_expression.expression, symbol_table, diagnostics);
|
||||
}
|
||||
@ -643,7 +642,7 @@ fn gather_suffix_expression(
|
||||
fn gather_call_expression(
|
||||
call_expression: &mut CallExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut call_expression.callee, symbol_table, diagnostics);
|
||||
if let Some(turbo_fish) = &mut call_expression.turbo_fish {
|
||||
@ -657,7 +656,7 @@ fn gather_call_expression(
|
||||
fn gather_turbo_fish(
|
||||
turbo_fish: &mut TurboFish,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
@ -665,7 +664,7 @@ fn gather_turbo_fish(
|
||||
fn gather_closure(
|
||||
closure: &mut Closure,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
@ -673,7 +672,7 @@ fn gather_closure(
|
||||
fn gather_object_access(
|
||||
object_access: &mut ObjectAccess,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
gather_expression(&mut object_access.receiver, symbol_table, diagnostics);
|
||||
for object_navigation in &mut object_access.navigations.0 {
|
||||
@ -691,7 +690,7 @@ fn gather_object_access(
|
||||
fn gather_literal(
|
||||
literal: &mut Literal,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
match literal {
|
||||
Literal::DString(d_string) => todo!(),
|
||||
|
@ -11,33 +11,11 @@ mod resolve;
|
||||
pub mod symbol;
|
||||
pub mod symbol_table;
|
||||
|
||||
pub(self) struct DiagnosticsContainer {
|
||||
diagnostics: Vec<DmDiagnostic>,
|
||||
}
|
||||
|
||||
impl DiagnosticsContainer {
|
||||
pub fn new() -> DiagnosticsContainer {
|
||||
DiagnosticsContainer {
|
||||
diagnostics: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add(&mut self, diagnostic: DmDiagnostic) {
|
||||
self.diagnostics.push(diagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<DmDiagnostic>> for DiagnosticsContainer {
|
||||
fn into(self) -> Vec<DmDiagnostic> {
|
||||
self.diagnostics
|
||||
}
|
||||
}
|
||||
|
||||
pub fn analyze_names(
|
||||
compilation_units: &mut Vec<CompilationUnit>,
|
||||
symbol_table: &mut SymbolTable,
|
||||
) -> Vec<DmDiagnostic> {
|
||||
let mut diagnostics = DiagnosticsContainer::new();
|
||||
let mut diagnostics = vec![];
|
||||
|
||||
// gather symbols
|
||||
for compilation_unit in compilation_units.iter_mut() {
|
||||
@ -97,7 +75,7 @@ mod tests {
|
||||
eprintln!("{}", symbol_table);
|
||||
panic!("Diagnostics was not empty!");
|
||||
}
|
||||
|
||||
|
||||
for compilation_unit in &compilation_units {
|
||||
dbg!(compilation_unit);
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
use crate::ast::named::Named;
|
||||
use crate::ast::*;
|
||||
use crate::name_analysis::symbol_table::{SymbolLookupError, SymbolTable};
|
||||
use crate::name_analysis::DiagnosticsContainer;
|
||||
use codespan_reporting::diagnostic::{Diagnostic, Label};
|
||||
use crate::diagnostic::DmDiagnostic;
|
||||
|
||||
fn resolve_fully_qualified_name(
|
||||
fully_qualified_name: &mut FullyQualifiedName,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
let lookup_result = symbol_table.lookup(
|
||||
fully_qualified_name.name().as_ref(),
|
||||
@ -20,7 +20,7 @@ fn resolve_fully_qualified_name(
|
||||
Ok(symbol) => {
|
||||
fully_qualified_name.set_symbol(symbol.clone());
|
||||
}
|
||||
Err(e) => diagnostics.add(
|
||||
Err(e) => diagnostics.push(
|
||||
Diagnostic::error()
|
||||
.with_message(format!(
|
||||
"No symbol with name '{}' found in current scope.",
|
||||
@ -37,7 +37,7 @@ fn resolve_fully_qualified_name(
|
||||
fn resolve_type_use(
|
||||
type_use: &mut TypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
match type_use {
|
||||
TypeUse::Void => {}
|
||||
@ -60,7 +60,7 @@ fn resolve_type_use(
|
||||
fn resolve_interface_or_class_type_use(
|
||||
interface_or_class_type_use: &mut InterfaceOrClassTypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_fully_qualified_name(
|
||||
&mut interface_or_class_type_use.fqn,
|
||||
@ -77,7 +77,7 @@ fn resolve_interface_or_class_type_use(
|
||||
fn resolve_tuple_type_use(
|
||||
tuple_type_use: &mut TupleTypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_tuple_arguments(&mut tuple_type_use.arguments, symbol_table, diagnostics);
|
||||
}
|
||||
@ -85,7 +85,7 @@ fn resolve_tuple_type_use(
|
||||
fn resolve_function_type_use(
|
||||
function_type_use: &mut FunctionTypeUse,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_parameters(&mut function_type_use.parameters, symbol_table, diagnostics);
|
||||
resolve_return_type(
|
||||
@ -98,7 +98,7 @@ fn resolve_function_type_use(
|
||||
fn resolve_generic_arguments(
|
||||
generic_arguments: &mut GenericArguments,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for generic_argument in &mut generic_arguments.0 {
|
||||
resolve_type_use(generic_argument, symbol_table, diagnostics);
|
||||
@ -108,7 +108,7 @@ fn resolve_generic_arguments(
|
||||
fn resolve_tuple_arguments(
|
||||
tuple_type_use: &mut TupleArguments,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for type_use in &mut tuple_type_use.0 {
|
||||
resolve_type_use(type_use, symbol_table, diagnostics);
|
||||
@ -118,7 +118,7 @@ fn resolve_tuple_arguments(
|
||||
fn resolve_implements_list(
|
||||
implements_list: &mut ImplementsList,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
@ -126,7 +126,7 @@ fn resolve_implements_list(
|
||||
fn resolve_parameters(
|
||||
parameters: &mut Parameters,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for parameter in &mut parameters.0 {
|
||||
resolve_type_use(&mut parameter.type_use, symbol_table, diagnostics);
|
||||
@ -136,7 +136,7 @@ fn resolve_parameters(
|
||||
fn resolve_return_type(
|
||||
return_type: &mut ReturnType,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_type_use(&mut return_type.declared_type, symbol_table, diagnostics);
|
||||
resolve_references(&mut return_type.references, symbol_table, diagnostics);
|
||||
@ -145,7 +145,7 @@ fn resolve_return_type(
|
||||
fn resolve_references(
|
||||
references: &mut References,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for reference in &mut references.0 {
|
||||
todo!()
|
||||
@ -155,7 +155,7 @@ fn resolve_references(
|
||||
fn resolve_use_statement(
|
||||
use_statement: &mut UseStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
if use_statement.is_star() {
|
||||
todo!()
|
||||
@ -173,7 +173,7 @@ fn resolve_use_statement(
|
||||
}
|
||||
Err(err) => match err {
|
||||
SymbolLookupError::NoDefinition => {
|
||||
diagnostics.add(
|
||||
diagnostics.push(
|
||||
Diagnostic::error()
|
||||
.with_message(&format!(
|
||||
"No definition found for symbol '{}'",
|
||||
@ -190,7 +190,7 @@ fn resolve_use_statement(
|
||||
pub(super) fn resolve_compilation_unit(
|
||||
compilation_unit: &mut CompilationUnit,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for use_statement in &mut compilation_unit.use_statements {
|
||||
resolve_use_statement(use_statement, symbol_table, diagnostics);
|
||||
@ -203,7 +203,7 @@ pub(super) fn resolve_compilation_unit(
|
||||
pub(super) fn resolve_module_level_declaration(
|
||||
declaration: &mut ModuleLevelDeclaration,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use crate::ast::ModuleLevelDeclaration::*;
|
||||
match declaration {
|
||||
@ -225,7 +225,7 @@ pub(super) fn resolve_module_level_declaration(
|
||||
fn resolve_function_definition(
|
||||
function_definition: &mut FunctionDefinition,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_parameters(
|
||||
&mut function_definition.parameters,
|
||||
@ -243,7 +243,7 @@ fn resolve_function_definition(
|
||||
fn resolve_platform_function_declaration(
|
||||
platform_function_declaration: &mut PlatformFunctionDeclaration,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_parameters(
|
||||
&mut platform_function_declaration.parameters,
|
||||
@ -260,7 +260,7 @@ fn resolve_platform_function_declaration(
|
||||
fn resolve_function_body(
|
||||
function_body: &mut FunctionBody,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use crate::ast::FunctionBody::*;
|
||||
match function_body {
|
||||
@ -272,7 +272,7 @@ fn resolve_function_body(
|
||||
fn resolve_block(
|
||||
block_statement: &mut BlockStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for statement in block_statement.statements.iter_mut() {
|
||||
resolve_statement(statement, symbol_table, diagnostics);
|
||||
@ -285,7 +285,7 @@ fn resolve_block(
|
||||
fn resolve_statement(
|
||||
statement: &mut Statement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use crate::ast::Statement::*;
|
||||
match statement {
|
||||
@ -306,7 +306,7 @@ fn resolve_statement(
|
||||
fn resolve_variable_declaration(
|
||||
variable_declaration: &mut VariableDeclarationStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
if let Some(initializer) = &mut variable_declaration.initializer {
|
||||
resolve_expression(initializer, symbol_table, diagnostics)
|
||||
@ -316,7 +316,7 @@ fn resolve_variable_declaration(
|
||||
fn resolve_assign_statement(
|
||||
assign_statement: &mut AssignStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut assign_statement.lhs, symbol_table, diagnostics);
|
||||
resolve_expression(&mut assign_statement.rhs, symbol_table, diagnostics);
|
||||
@ -325,7 +325,7 @@ fn resolve_assign_statement(
|
||||
fn resolve_call_statement(
|
||||
call_statement: &mut CallStatement,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut call_statement.0, symbol_table, diagnostics)
|
||||
}
|
||||
@ -333,7 +333,7 @@ fn resolve_call_statement(
|
||||
fn resolve_expression(
|
||||
expression: &mut Expression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
use crate::ast::Expression::*;
|
||||
match expression {
|
||||
@ -368,7 +368,7 @@ fn resolve_expression(
|
||||
fn resolve_ternary_expression(
|
||||
ternary_expression: &mut TernaryExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut ternary_expression.condition, symbol_table, diagnostics);
|
||||
resolve_expression(
|
||||
@ -386,7 +386,7 @@ fn resolve_ternary_expression(
|
||||
fn resolve_binary_expression(
|
||||
binary_expression: &mut BinaryExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut binary_expression.left, symbol_table, diagnostics);
|
||||
resolve_expression(&mut binary_expression.right, symbol_table, diagnostics);
|
||||
@ -395,7 +395,7 @@ fn resolve_binary_expression(
|
||||
fn resolve_prefix_expression(
|
||||
prefix_expression: &mut PrefixExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut prefix_expression.expression, symbol_table, diagnostics);
|
||||
}
|
||||
@ -403,7 +403,7 @@ fn resolve_prefix_expression(
|
||||
fn resolve_suffix_expression(
|
||||
suffix_expression: &mut SuffixExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut suffix_expression.expression, symbol_table, diagnostics);
|
||||
}
|
||||
@ -411,7 +411,7 @@ fn resolve_suffix_expression(
|
||||
fn resolve_call_expression(
|
||||
call_expression: &mut CallExpression,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut call_expression.callee, symbol_table, diagnostics);
|
||||
if let Some(turbo_fish) = &mut call_expression.turbo_fish {
|
||||
@ -423,7 +423,7 @@ fn resolve_call_expression(
|
||||
fn resolve_turbo_fish(
|
||||
turbo_fish: &mut TurboFish,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
@ -431,7 +431,7 @@ fn resolve_turbo_fish(
|
||||
fn resolve_call_arguments(
|
||||
call_arguments: &mut CallArguments,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
for argument in &mut call_arguments.0 {
|
||||
resolve_call_argument(argument, symbol_table, diagnostics);
|
||||
@ -441,7 +441,7 @@ fn resolve_call_arguments(
|
||||
fn resolve_call_argument(
|
||||
call_argument: &mut CallArgument,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
resolve_expression(&mut call_argument.0, symbol_table, diagnostics);
|
||||
}
|
||||
@ -449,7 +449,7 @@ fn resolve_call_argument(
|
||||
fn resolve_closure(
|
||||
closure: &mut Closure,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
@ -457,7 +457,7 @@ fn resolve_closure(
|
||||
fn resolve_object_access(
|
||||
object_access: &mut ObjectAccess,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
@ -465,7 +465,7 @@ fn resolve_object_access(
|
||||
fn resolve_literal(
|
||||
literal: &mut Literal,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
match literal {
|
||||
Literal::DString(d_string) => resolve_d_string(d_string, symbol_table, diagnostics),
|
||||
@ -477,7 +477,7 @@ fn resolve_literal(
|
||||
fn resolve_d_string(
|
||||
d_string: &mut DString,
|
||||
symbol_table: &mut SymbolTable,
|
||||
diagnostics: &mut DiagnosticsContainer,
|
||||
diagnostics: &mut Vec<DmDiagnostic>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user