From 726251e39cdbeb611fe36185d6d914663b13100d Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 28 Jul 2025 18:22:51 +0300 Subject: [PATCH] Fix warnings, cleanup --- reid-llvm-lib/src/compile.rs | 36 ------------------------- reid-llvm-lib/src/debug_information.rs | 6 +---- reid-llvm-lib/src/lib.rs | 2 +- reid/src/ast/mod.rs | 9 +++---- reid/src/ast/parse.rs | 4 +-- reid/src/ast/process.rs | 4 +-- reid/src/codegen/intrinsics.rs | 2 -- reid/src/mir/typecheck/typecheck.rs | 6 ++--- reid/src/mir/typecheck/typeinference.rs | 2 +- 9 files changed, 13 insertions(+), 58 deletions(-) diff --git a/reid-llvm-lib/src/compile.rs b/reid-llvm-lib/src/compile.rs index 3e03a9e..7f5e7f2 100644 --- a/reid-llvm-lib/src/compile.rs +++ b/reid-llvm-lib/src/compile.rs @@ -569,42 +569,6 @@ impl TypeHolder { } impl FunctionHolder { - unsafe fn compile_debug_info( - &self, - di_builder: LLVMDIBuilderRef, - parent: LLVMMetadataRef, - file: LLVMMetadataRef, - types: &mut HashMap, - func: LLVMFunction, - scope: DebugScopeHolder, - ) -> LLVMMetadataRef { - unsafe { - let DebugScopeKind::Subprogram(subprogram) = scope.data.kind else { - panic!(); - }; - - let mangled_length_ptr = &mut 0; - let mangled_name = LLVMGetValueName2(func.value_ref, mangled_length_ptr); - let mangled_length = *mangled_length_ptr; - LLVMDIBuilderCreateFunction( - di_builder, - parent, - into_cstring(subprogram.name.clone()).as_ptr(), - subprogram.name.clone().len(), - mangled_name, - mangled_length, - file, - subprogram.location.pos.line, - *types.get(&subprogram.ty).unwrap(), - subprogram.opts.is_local as i32, - subprogram.opts.is_definition as i32, - subprogram.opts.scope_line, - subprogram.opts.flags.as_llvm(), - subprogram.opts.is_optimized as i32, - ) - } - } - unsafe fn compile_signature( &self, context: &LLVMContext, diff --git a/reid-llvm-lib/src/debug_information.rs b/reid-llvm-lib/src/debug_information.rs index 8f66036..e0b8b21 100644 --- a/reid-llvm-lib/src/debug_information.rs +++ b/reid-llvm-lib/src/debug_information.rs @@ -208,11 +208,7 @@ impl DebugInformation { self.metadata.clone() } - // pub fn get_scopes(&self) -> Rc> { - // self.scope.clone() - // } - - pub fn get_scope(&self) -> Rc> { + pub(crate) fn get_scope(&self) -> Rc> { self.scope.clone() } diff --git a/reid-llvm-lib/src/lib.rs b/reid-llvm-lib/src/lib.rs index e231647..b762338 100644 --- a/reid-llvm-lib/src/lib.rs +++ b/reid-llvm-lib/src/lib.rs @@ -546,7 +546,7 @@ impl ConstValue { } #[derive(PartialEq, Eq, PartialOrd, Ord, Debug)] -enum TypeCategory { +pub enum TypeCategory { SignedInteger, UnsignedInteger, Void, diff --git a/reid/src/ast/mod.rs b/reid/src/ast/mod.rs index a0b48d3..b60ce9a 100644 --- a/reid/src/ast/mod.rs +++ b/reid/src/ast/mod.rs @@ -122,8 +122,8 @@ pub enum BinaryOperator { And, Or, Xor, - BWAnd, - BWOr, + BitAnd, + BitOr, LT, LE, GT, @@ -141,9 +141,8 @@ impl BinaryOperator { Mult => 15, Div => 20, Mod => 20, - BWAnd => 90, - BWOr => 90, - BWXor => 90, + BitAnd => 90, + BitOr => 90, BitshiftLeft => 100, BitshiftRight => 100, And => 150, diff --git a/reid/src/ast/parse.rs b/reid/src/ast/parse.rs index 5f96e74..a4ba0d7 100644 --- a/reid/src/ast/parse.rs +++ b/reid/src/ast/parse.rs @@ -518,8 +518,8 @@ impl Parse for BinaryOperator { } (Some(Token::Hat), _) => BinaryOperator::Xor, - (Some(Token::Et), _) => BinaryOperator::BWAnd, - (Some(Token::Pipe), _) => BinaryOperator::BWOr, + (Some(Token::Et), _) => BinaryOperator::BitAnd, + (Some(Token::Pipe), _) => BinaryOperator::BitOr, (Some(Token::LessThan), _) => BinaryOperator::LT, (Some(Token::GreaterThan), _) => BinaryOperator::GT, diff --git a/reid/src/ast/process.rs b/reid/src/ast/process.rs index 8153295..e527bce 100644 --- a/reid/src/ast/process.rs +++ b/reid/src/ast/process.rs @@ -459,8 +459,8 @@ impl ast::BinaryOperator { ast::BinaryOperator::BitshiftRight => mir::BinaryOperator::BitshiftRight, ast::BinaryOperator::BitshiftLeft => mir::BinaryOperator::BitshiftLeft, ast::BinaryOperator::Xor => mir::BinaryOperator::Xor, - ast::BinaryOperator::BWAnd => mir::BinaryOperator::BitAnd, - ast::BinaryOperator::BWOr => mir::BinaryOperator::BitOr, + ast::BinaryOperator::BitAnd => mir::BinaryOperator::BitAnd, + ast::BinaryOperator::BitOr => mir::BinaryOperator::BitOr, } } } diff --git a/reid/src/codegen/intrinsics.rs b/reid/src/codegen/intrinsics.rs index f1a9e4c..0689c67 100644 --- a/reid/src/codegen/intrinsics.rs +++ b/reid/src/codegen/intrinsics.rs @@ -1,5 +1,3 @@ -use std::ops::BitAnd; - use reid_lib::{builder::InstructionValue, CmpPredicate, ConstValue, Instr, Type}; use crate::{ diff --git a/reid/src/mir/typecheck/typecheck.rs b/reid/src/mir/typecheck/typecheck.rs index 2810ec5..b73af26 100644 --- a/reid/src/mir/typecheck/typecheck.rs +++ b/reid/src/mir/typecheck/typecheck.rs @@ -1,6 +1,6 @@ //! This module contains code relevant to doing a type checking pass on the MIR. //! During typechecking relevant types are also coerced if possible. -use std::{collections::HashSet, convert::Infallible, hint, iter}; +use std::{collections::HashSet, convert::Infallible, iter}; use crate::{mir::*, util::try_all}; use VagueType as Vague; @@ -750,9 +750,7 @@ impl Expression { .into_iter() .chain(iter::repeat(TypeKind::Vague(Vague::Unknown))); - for (i, (param, true_param_t)) in - function_call.parameters.iter_mut().zip(true_params_iter).enumerate() - { + for (param, true_param_t) in function_call.parameters.iter_mut().zip(true_params_iter) { // Typecheck every param separately let param_res = param.typecheck(state, &typerefs, HintKind::Coerce(true_param_t.clone())); let param_t = state.or_else(param_res, TypeKind::Vague(Vague::Unknown), param.1); diff --git a/reid/src/mir/typecheck/typeinference.rs b/reid/src/mir/typecheck/typeinference.rs index 795b2bf..babb656 100644 --- a/reid/src/mir/typecheck/typeinference.rs +++ b/reid/src/mir/typecheck/typeinference.rs @@ -285,7 +285,7 @@ impl Block { let rhs_ref = state.ok(rhs_infer, rhs.1); // Try to narrow the lhs with rhs - if let (Some(mut lhs_ref), Some(mut rhs_ref)) = (lhs_ref, rhs_ref) { + if let (Some(lhs_ref), Some(mut rhs_ref)) = (lhs_ref, rhs_ref) { rhs_ref.narrow(&lhs_ref); } }