From ae6796acfccf80f50140fafb7560ea41e94ac741 Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 4 Aug 2025 16:00:01 +0300 Subject: [PATCH] Fix calling convention for integers/real-numbers --- reid/src/codegen/intrinsics.rs | 2 +- reid/src/lib.rs | 2 -- reid/src/mir/typecheck/typeinference.rs | 7 +++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/reid/src/codegen/intrinsics.rs b/reid/src/codegen/intrinsics.rs index 759ea7b..af08835 100644 --- a/reid/src/codegen/intrinsics.rs +++ b/reid/src/codegen/intrinsics.rs @@ -491,7 +491,7 @@ impl IntrinsicFunction for IntrinsicLLVM { )) .unwrap(); - Ok(StackValue(StackValueKind::Literal(value), self.1)) + Ok(StackValue(StackValueKind::Literal(value), self.1.clone())) } } diff --git a/reid/src/lib.rs b/reid/src/lib.rs index 587777a..37610c4 100644 --- a/reid/src/lib.rs +++ b/reid/src/lib.rs @@ -134,8 +134,6 @@ pub fn compile_module<'map>( is_main, }; - dbg!(&ast_module); - if errors.len() > 0 { // dbg!(&ast_module); return Ok(Err(( diff --git a/reid/src/mir/typecheck/typeinference.rs b/reid/src/mir/typecheck/typeinference.rs index 2827540..91552f7 100644 --- a/reid/src/mir/typecheck/typeinference.rs +++ b/reid/src/mir/typecheck/typeinference.rs @@ -12,6 +12,7 @@ use std::{ use crate::{ mir::{ + implement::TypeCategory, pass::{AssociatedFunctionKey, ScopeVariable}, BinopDefinition, Block, CustomTypeKey, ExprKind, Expression, FunctionDefinition, FunctionDefinitionKind, IfExpression, Module, ReturnKind, StmtKind, TypeKind, VagueType, WhileStatement, @@ -627,12 +628,18 @@ impl Expression { if backing_var.is_some() { if let TypeKind::Borrow(inner, _) = type_kind { + let ty_cat = inner.category(); if let TypeKind::Borrow(..) = *inner.clone() { *type_kind = type_kind.unroll_borrow(); let ExprKind::Borrow(val, _) = &first_param.0 else { panic!() }; *first_param = *val.clone(); + } else if ty_cat == TypeCategory::Integer || ty_cat == TypeCategory::Real { + if let ExprKind::Borrow(val, _) = &first_param.0 { + *first_param = *val.clone(); + } + *type_kind = *inner.clone(); } } } else {