diff --git a/reid/src/ast/process.rs b/reid/src/ast/process.rs index 4c87d28..8c60cc3 100644 --- a/reid/src/ast/process.rs +++ b/reid/src/ast/process.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use crate::{ - ast::{self, FunctionCallExpression}, + ast::{self}, mir::{ self, CustomTypeKey, ModuleMap, NamedVariableRef, ReturnKind, SourceModuleId, StmtKind, StructField, StructType, WhileStatement, diff --git a/reid/src/codegen/allocator.rs b/reid/src/codegen/allocator.rs index 26dbfe9..c4cf301 100644 --- a/reid/src/codegen/allocator.rs +++ b/reid/src/codegen/allocator.rs @@ -5,9 +5,7 @@ use reid_lib::{ Block, }; -use mir::{ - CustomTypeKey, FunctionCall, FunctionDefinitionKind, IfExpression, SourceModuleId, TypeKind, WhileStatement, -}; +use mir::{CustomTypeKey, FunctionCall, FunctionDefinitionKind, IfExpression, TypeKind, WhileStatement}; use crate::mir; @@ -18,17 +16,10 @@ pub struct Allocator { pub struct AllocatorScope<'ctx, 'a> { pub(super) block: &'a mut Block<'ctx>, - pub(super) module_id: SourceModuleId, pub(super) type_values: &'a HashMap, } impl Allocator { - pub fn empty() -> Allocator { - Allocator { - allocations: Vec::new(), - } - } - pub fn from( func: &FunctionDefinitionKind, params: &Vec<(String, TypeKind)>, @@ -183,7 +174,11 @@ impl mir::Expression { mir::ExprKind::CastTo(expression, _) => { allocated.extend(expression.allocate(scope)); } - mir::ExprKind::AssociatedFunctionCall(type_kind, function_call) => todo!(), + mir::ExprKind::AssociatedFunctionCall(_, FunctionCall { parameters, .. }) => { + for param in parameters { + allocated.extend(param.allocate(scope)); + } + } } allocated diff --git a/reid/src/codegen/intrinsics.rs b/reid/src/codegen/intrinsics.rs index bdb8180..9da734c 100644 --- a/reid/src/codegen/intrinsics.rs +++ b/reid/src/codegen/intrinsics.rs @@ -1,5 +1,3 @@ -use std::marker::PhantomData; - use reid_lib::{builder::InstructionValue, CmpPredicate, Instr}; use crate::{ diff --git a/reid/src/codegen/mod.rs b/reid/src/codegen/mod.rs index 8e3a31b..4e334e9 100644 --- a/reid/src/codegen/mod.rs +++ b/reid/src/codegen/mod.rs @@ -227,7 +227,7 @@ impl mir::Module { parameters: (binop.lhs.clone(), binop.rhs.clone()), return_ty: binop.return_type.clone(), kind: match &binop.fn_kind { - FunctionDefinitionKind::Local(block, metadata) => { + FunctionDefinitionKind::Local(..) => { let ir_function = module.function( &binop_fn_name, binop.return_type.get_type(&type_values), @@ -246,7 +246,6 @@ impl mir::Module { &vec![binop.lhs.clone(), binop.rhs.clone()], &mut AllocatorScope { block: &mut entry, - module_id: self.module_id, type_values: &type_values, }, ); @@ -320,7 +319,6 @@ impl mir::Module { &mir_function.parameters, &mut AllocatorScope { block: &mut entry, - module_id: self.module_id, type_values: &type_values, }, ); diff --git a/reid/src/mir/fmt.rs b/reid/src/mir/fmt.rs index 3b0fda2..387e22a 100644 --- a/reid/src/mir/fmt.rs +++ b/reid/src/mir/fmt.rs @@ -2,7 +2,7 @@ use std::fmt::{Debug, Display, Write}; use crate::pad_adapter::PadAdapter; -use super::{typecheck::typerefs::TypeRefs, *}; +use super::*; impl Display for Context { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/reid/src/mir/implement.rs b/reid/src/mir/implement.rs index 36acda1..0dfa202 100644 --- a/reid/src/mir/implement.rs +++ b/reid/src/mir/implement.rs @@ -1,6 +1,6 @@ use crate::util::maybe; -use super::{pass::ScopeBinopDef, typecheck::typerefs::TypeRefs, *}; +use super::{typecheck::typerefs::TypeRefs, *}; #[derive(Debug, Clone)] pub enum ReturnTypeOther { diff --git a/reid/src/mir/linker.rs b/reid/src/mir/linker.rs index ffee5bd..695e319 100644 --- a/reid/src/mir/linker.rs +++ b/reid/src/mir/linker.rs @@ -8,7 +8,6 @@ use std::{ }; use crate::{ - codegen::scope, compile_module, error_raporting::{ErrorModules, ReidError}, mir::{ @@ -254,7 +253,7 @@ impl<'map> Pass for LinkerPass<'map> { binop.exported = true; already_imported_binops.insert(binop_key); match &binop.fn_kind { - FunctionDefinitionKind::Local(block, metadata) => { + FunctionDefinitionKind::Local(..) => { importer_module.binop_defs.push(BinopDefinition { lhs: binop.lhs.clone(), op: binop.op, diff --git a/reid/src/mir/typecheck/mod.rs b/reid/src/mir/typecheck/mod.rs index f4ee267..59fd6a7 100644 --- a/reid/src/mir/typecheck/mod.rs +++ b/reid/src/mir/typecheck/mod.rs @@ -170,7 +170,7 @@ impl TypeKind { return self.clone(); } match (self, other) { - (TypeKind::Vague(Vague::Unknown), other) | (other, TypeKind::Vague(Vague::Unknown)) => { + (TypeKind::Vague(Vague::Unknown), _) | (_, TypeKind::Vague(Vague::Unknown)) => { TypeKind::Vague(VagueType::Unknown) } (TypeKind::Vague(Vague::Integer), other) | (other, TypeKind::Vague(Vague::Integer)) => match other { diff --git a/reid/src/mir/typecheck/typeinference.rs b/reid/src/mir/typecheck/typeinference.rs index bfc367d..3522b5a 100644 --- a/reid/src/mir/typecheck/typeinference.rs +++ b/reid/src/mir/typecheck/typeinference.rs @@ -20,7 +20,7 @@ use crate::{ use super::{ super::{ - pass::{BinopKey, Pass, PassResult, PassState}, + pass::{BinopKey, Pass, PassResult}, TypeKind::*, VagueType::*, }, diff --git a/reid/src/mir/typecheck/typerefs.rs b/reid/src/mir/typecheck/typerefs.rs index 1e7ca80..3b0d695 100644 --- a/reid/src/mir/typecheck/typerefs.rs +++ b/reid/src/mir/typecheck/typerefs.rs @@ -4,15 +4,9 @@ use std::{ rc::Rc, }; -use crate::{ - ast::BinopDefinition, - mir::{pass::BinopMap, BinaryOperator, TypeKind, VagueType}, -}; +use crate::mir::{pass::BinopMap, BinaryOperator, TypeKind, VagueType}; -use super::{ - super::pass::{BinopKey, ScopeBinopDef, Storage}, - ErrorKind, -}; +use super::{super::pass::ScopeBinopDef, ErrorKind}; #[derive(Clone)] pub struct TypeRef<'scope>(pub(super) TypeIdRef, pub(super) &'scope ScopeTypeRefs<'scope>); diff --git a/reid/tests/e2e.rs b/reid/tests/e2e.rs index 0439ff7..34eb344 100644 --- a/reid/tests/e2e.rs +++ b/reid/tests/e2e.rs @@ -1,10 +1,4 @@ -use std::{ - alloc::System, - path::PathBuf, - process::Command, - thread, - time::{Duration, SystemTime}, -}; +use std::{path::PathBuf, process::Command, time::SystemTime}; use reid::{ compile_module,