diff --git a/examples/float.reid b/examples/float.reid index d5c134c..ebf0393 100644 --- a/examples/float.reid +++ b/examples/float.reid @@ -1,9 +1,9 @@ // Arithmetic, function calls and imports! -pub fn OneHalf(var1: f32) -> f32 { - return var1 * 1.5; +pub fn test() -> u8 { + return 5; } pub fn main() -> bool { - return 7.5 > 5.001; + return 7.5 > (test() as f16); } diff --git a/reid-llvm-lib/examples/libtest.rs b/reid-llvm-lib/examples/libtest.rs index 85afd97..32e4584 100644 --- a/reid-llvm-lib/examples/libtest.rs +++ b/reid-llvm-lib/examples/libtest.rs @@ -61,5 +61,5 @@ fn main() { dbg!(&context); - context.compile(); + context.compile(None, Vec::new()); } diff --git a/reid-llvm-lib/src/compile.rs b/reid-llvm-lib/src/compile.rs index 521fb94..c699c95 100644 --- a/reid-llvm-lib/src/compile.rs +++ b/reid-llvm-lib/src/compile.rs @@ -8,7 +8,7 @@ use std::{ }; use llvm_sys::{ - LLVMAttributeIndex, LLVMIntPredicate, LLVMLinkage, LLVMRealPredicate, LLVMValueKind, + LLVMIntPredicate, LLVMLinkage, LLVMRealPredicate, LLVMValueKind, analysis::LLVMVerifyModule, core::*, debuginfo::*, diff --git a/reid-llvm-lib/src/debug_information.rs b/reid-llvm-lib/src/debug_information.rs index 0efb7d8..c9f2a40 100644 --- a/reid-llvm-lib/src/debug_information.rs +++ b/reid-llvm-lib/src/debug_information.rs @@ -1,4 +1,4 @@ -use std::{cell::RefCell, collections::hash_map::Values, rc::Rc}; +use std::{cell::RefCell, rc::Rc}; use crate::builder::InstructionValue; diff --git a/reid/src/allocator.rs b/reid/src/allocator.rs index 64e7a39..839d7b3 100644 --- a/reid/src/allocator.rs +++ b/reid/src/allocator.rs @@ -6,8 +6,8 @@ use reid_lib::{ }; use crate::mir::{ - self, CustomTypeKey, FunctionCall, FunctionDefinition, FunctionDefinitionKind, IfExpression, - SourceModuleId, TypeDefinition, TypeKind, WhileStatement, + self, CustomTypeKey, FunctionCall, FunctionDefinitionKind, IfExpression, SourceModuleId, + TypeKind, WhileStatement, }; #[derive(Debug)] diff --git a/reid/src/ast/process.rs b/reid/src/ast/process.rs index c27a6e5..071b461 100644 --- a/reid/src/ast/process.rs +++ b/reid/src/ast/process.rs @@ -8,8 +8,6 @@ use crate::{ }, }; -use super::TypeKind; - impl mir::Context { pub fn from(modules: Vec, base: PathBuf) -> mir::Context { let mut map = ModuleMap::new(); diff --git a/reid/src/codegen.rs b/reid/src/codegen.rs index ee0f259..bb5182c 100644 --- a/reid/src/codegen.rs +++ b/reid/src/codegen.rs @@ -1,4 +1,4 @@ -use std::{cell::RefCell, collections::HashMap, hash::Hash, mem, rc::Rc}; +use std::{cell::RefCell, collections::HashMap, mem, rc::Rc}; use reid_lib::{ builder::{InstructionValue, TypeValue}, diff --git a/reid/src/intrinsics.rs b/reid/src/intrinsics.rs index c137c86..4cc42c3 100644 --- a/reid/src/intrinsics.rs +++ b/reid/src/intrinsics.rs @@ -2,42 +2,9 @@ use reid_lib::{builder::InstructionValue, Instr}; use crate::{ codegen::{ErrorKind, Scope, StackValue, StackValueKind}, - mir::{BinaryOperator, BinopDefinition, FunctionDefinition, FunctionDefinitionKind, TypeKind}, + mir::{BinopDefinition, FunctionDefinition, TypeKind}, }; -fn intrinsic( - name: &str, - ret_ty: TypeKind, - params: Vec<(&str, TypeKind)>, - fun: impl IntrinsicFunction + 'static, -) -> FunctionDefinition { - FunctionDefinition { - name: name.into(), - is_pub: false, - is_imported: false, - return_type: ret_ty, - parameters: params.into_iter().map(|(n, ty)| (n.into(), ty)).collect(), - kind: FunctionDefinitionKind::Intrinsic(Box::new(fun)), - } -} - -fn intrinsic_binop( - op: BinaryOperator, - lhs: TypeKind, - rhs: TypeKind, - ret_ty: TypeKind, - fun: impl IntrinsicFunction + 'static, -) -> BinopDefinition { - BinopDefinition { - lhs: ("lhs".to_string(), lhs), - op, - rhs: ("rhs".to_owned(), rhs), - return_type: ret_ty, - fn_kind: FunctionDefinitionKind::Intrinsic(Box::new(fun)), - meta: Default::default(), - } -} - pub fn form_intrinsics() -> Vec { let intrinsics = Vec::new(); diff --git a/reid/src/lexer.rs b/reid/src/lexer.rs index df426dd..777f5a8 100644 --- a/reid/src/lexer.rs +++ b/reid/src/lexer.rs @@ -1,8 +1,4 @@ -use std::{ - fmt::Debug, - ops::{Add, AddAssign}, - str::Chars, -}; +use std::{fmt::Debug, ops::AddAssign, str::Chars}; static BINARY_NUMERICS: &[char] = &['0', '1']; static OCTAL_NUMERICS: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7']; diff --git a/reid/src/mir/pass.rs b/reid/src/mir/pass.rs index 9f085c6..a258a53 100644 --- a/reid/src/mir/pass.rs +++ b/reid/src/mir/pass.rs @@ -1,7 +1,7 @@ //! This module contains relevant code for [`Pass`] and shared code between //! passes. Passes can be performed on Reid MIR to e.g. typecheck the code. -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::convert::Infallible; use std::error::Error as STDError; diff --git a/reid/src/mir/typeinference.rs b/reid/src/mir/typeinference.rs index d67bf98..6cec876 100644 --- a/reid/src/mir/typeinference.rs +++ b/reid/src/mir/typeinference.rs @@ -13,7 +13,7 @@ use std::{ use crate::{mir::TypeKind, util::try_all}; use super::{ - pass::{self, Pass, PassResult, PassState, ScopeBinopDef, ScopeBinopKey}, + pass::{Pass, PassResult, PassState, ScopeBinopKey}, typecheck::{ErrorKind, ErrorTypedefKind}, typerefs::{ScopeTypeRefs, TypeRef, TypeRefs}, BinopDefinition, Block, CustomTypeKey, ExprKind, Expression, FunctionDefinition,