Fix some warnings, remove unused code

This commit is contained in:
Sofia 2025-07-16 21:14:07 +03:00
parent 1eb3e8c095
commit 79c98a18f7
3 changed files with 3 additions and 64 deletions

View File

@ -512,11 +512,6 @@ impl mir::Expression {
} }
} }
pub enum IndexKind {
Array(u32),
Struct(u32),
}
impl IndexedVariableReference { impl IndexedVariableReference {
fn get_stack_value(&self, scope: &mut Scope, load_after_gep: bool) -> Option<StackValue> { fn get_stack_value(&self, scope: &mut Scope, load_after_gep: bool) -> Option<StackValue> {
match &self.kind { match &self.kind {

View File

@ -13,9 +13,8 @@ use super::{
typecheck::ErrorKind, typecheck::ErrorKind,
typerefs::{ScopeTypeRefs, TypeRef, TypeRefs}, typerefs::{ScopeTypeRefs, TypeRef, TypeRefs},
types::{pick_return, ReturnType}, types::{pick_return, ReturnType},
Block, ExprKind, Expression, FunctionDefinition, FunctionDefinitionKind, IfExpression, Block, ExprKind, Expression, FunctionDefinition, FunctionDefinitionKind, IfExpression, Module,
IndexedVariableReference, IndexedVariableReferenceKind, Module, NamedVariableRef, ReturnKind, ReturnKind, StmtKind,
StmtKind, TypeDefinitionKind,
TypeKind::*, TypeKind::*,
VagueType::*, VagueType::*,
}; };
@ -148,61 +147,6 @@ impl Block {
} }
} }
impl IndexedVariableReference {
fn find_hint<'s>(
&self,
state: &PassState<ErrorKind>,
hints: &'s ScopeTypeRefs,
) -> Result<Option<(bool, TypeRef<'s>)>, ErrorKind> {
match &self.kind {
IndexedVariableReferenceKind::Named(NamedVariableRef(_, name, _)) => {
Ok(hints.find_var(&name))
}
IndexedVariableReferenceKind::ArrayIndex(inner, _) => {
if let Some((mutable, inner_ref)) = inner.find_hint(state, hints)? {
// Check that the resolved type is at least an array, no
// need for further resolution.
let inner_ty = inner_ref.resolve_weak().unwrap();
match inner_ty {
Array(type_kind, _) => Ok(hints
.from_type(&type_kind)
.clone()
.map(|t_ref| (mutable, t_ref))),
_ => Err(ErrorKind::TriedIndexingNonArray(inner_ty.clone())),
}
} else {
Ok(None)
}
}
IndexedVariableReferenceKind::StructIndex(inner, field_name) => {
if let Some((mutable, inner_ref)) = inner.find_hint(state, hints)? {
// Check that the resolved type is at least an array, no
// need for further resolution.
let inner_ty = inner_ref.resolve_weak().unwrap();
match &inner_ty {
CustomType(struct_name) => match state.scope.types.get(&struct_name) {
Some(kind) => match kind {
TypeDefinitionKind::Struct(struct_ty) => Ok(hints
.from_type(
&struct_ty
.get_field_ty(field_name)
.cloned()
.ok_or(ErrorKind::NoSuchField(self.get_name()))?,
)
.map(|v| (mutable, v))),
},
None => Err(ErrorKind::TriedAccessingNonStruct(inner_ty.clone())),
},
_ => Err(ErrorKind::TriedAccessingNonStruct(inner_ty)),
}
} else {
Ok(None)
}
}
}
}
}
impl Expression { impl Expression {
fn infer_types<'s>( fn infer_types<'s>(
&mut self, &mut self,

View File

@ -1,5 +1,5 @@
use super::{ use super::{
typecheck::{Collapsable, ErrorKind}, typecheck::ErrorKind,
typerefs::{ScopeTypeRefs, TypeRef, TypeRefs}, typerefs::{ScopeTypeRefs, TypeRef, TypeRefs},
VagueType as Vague, *, VagueType as Vague, *,
}; };