diff --git a/src/asg/datatype/kind/mod.rs b/src/asg/datatype/kind/mod.rs index e48ca2a5..455fa87c 100644 --- a/src/asg/datatype/kind/mod.rs +++ b/src/asg/datatype/kind/mod.rs @@ -28,13 +28,13 @@ pub enum TypeKind { IntegerLiteral(BigInt), FloatLiteral(Option>), Floating(FloatSize), - Pointer(Box), + Ptr(Box), Void, AnonymousStruct(), AnonymousUnion(), AnonymousEnum(), FixedArray(Box), - FuncPointer(FuncPtr), + FuncPtr(FuncPtr), Enum(HumanName, EnumRef), Structure(HumanName, StructRef, Vec), TypeAlias(HumanName, TypeAliasRef), @@ -58,13 +58,13 @@ impl TypeKind { | TypeKind::IntegerLiteral(_) | TypeKind::FloatLiteral(_) | TypeKind::Floating(_) => false, - TypeKind::Pointer(inner) => inner.kind.contains_polymorph(), + TypeKind::Ptr(inner) => inner.kind.contains_polymorph(), TypeKind::Void => false, TypeKind::AnonymousStruct() => false, TypeKind::AnonymousUnion() => false, TypeKind::AnonymousEnum() => false, TypeKind::FixedArray(fixed_array) => fixed_array.inner.kind.contains_polymorph(), - TypeKind::FuncPointer(_) => todo!(), + TypeKind::FuncPtr(_) => todo!(), TypeKind::Enum(_, _) => false, TypeKind::Structure(_, _, parameters) | TypeKind::Trait(_, _, parameters) => parameters .iter() @@ -90,13 +90,13 @@ impl TypeKind { TypeKind::Unresolved => panic!(), TypeKind::Floating(_) | TypeKind::FloatLiteral(_) - | TypeKind::Pointer(_) + | TypeKind::Ptr(_) | TypeKind::Structure(_, _, _) | TypeKind::Void | TypeKind::AnonymousStruct(..) | TypeKind::AnonymousUnion(..) | TypeKind::FixedArray(..) - | TypeKind::FuncPointer(..) + | TypeKind::FuncPtr(..) | TypeKind::Enum(_, _) | TypeKind::AnonymousEnum() | TypeKind::Polymorph(_, _) @@ -152,7 +152,7 @@ impl Display for TypeKind { write!(f, "float NaN")?; } } - TypeKind::Pointer(inner) => { + TypeKind::Ptr(inner) => { write!(f, "ptr<{}>", **inner)?; } TypeKind::Void => f.write_str("void")?, @@ -166,7 +166,7 @@ impl Display for TypeKind { TypeKind::FixedArray(fixed_array) => { write!(f, "array<{}, {}>", fixed_array.size, fixed_array.inner.kind)?; } - TypeKind::FuncPointer(..) => f.write_str("function-pointer-type")?, + TypeKind::FuncPtr(..) => f.write_str("function-pointer-type")?, TypeKind::Enum(name, _) => write!(f, "{}", name)?, TypeKind::Polymorph(name, constaints) => { write!(f, "${}", name)?; diff --git a/src/asg/datatype/mod.rs b/src/asg/datatype/mod.rs index a5248054..3329ba51 100644 --- a/src/asg/datatype/mod.rs +++ b/src/asg/datatype/mod.rs @@ -20,7 +20,7 @@ impl Hash for Type { impl Type { pub fn pointer(self, source: Source) -> Self { Self { - kind: TypeKind::Pointer(Box::new(self)), + kind: TypeKind::Ptr(Box::new(self)), source, } } @@ -38,13 +38,13 @@ impl Type { TypeKind::IntegerLiteral(_) => (), TypeKind::FloatLiteral(_) => (), TypeKind::Floating(_) => (), - TypeKind::Pointer(inner) => inner.strip_constraints(), + TypeKind::Ptr(inner) => inner.strip_constraints(), TypeKind::Void => (), TypeKind::AnonymousStruct() => todo!(), TypeKind::AnonymousUnion() => todo!(), TypeKind::AnonymousEnum() => todo!(), TypeKind::FixedArray(fixed_array) => fixed_array.inner.strip_constraints(), - TypeKind::FuncPointer(_) => todo!(), + TypeKind::FuncPtr(_) => todo!(), TypeKind::Enum(_, _) => (), TypeKind::Structure(_, _, parameters) => { for parameter in parameters { diff --git a/src/ast/datatype/kind/display.rs b/src/ast/datatype/kind/display.rs index 605d23e9..4be8fc64 100644 --- a/src/ast/datatype/kind/display.rs +++ b/src/ast/datatype/kind/display.rs @@ -27,7 +27,7 @@ impl Display for &TypeKind { TypeKind::CInteger(integer, sign) => { fmt_c_integer(f, *integer, *sign)?; } - TypeKind::Pointer(inner) => { + TypeKind::Ptr(inner) => { write!(f, "ptr<{inner}>")?; } TypeKind::Void => { @@ -63,7 +63,7 @@ impl Display for &TypeKind { TypeKind::FixedArray(fixed_array) => { write!(f, "array<(amount), {}>", fixed_array.ast_type)?; } - TypeKind::FuncPointer(_function) => { + TypeKind::FuncPtr(_function) => { write!(f, "(function pointer type)")?; } TypeKind::Polymorph(polymorph, constraints) => { diff --git a/src/ast/datatype/kind/mod.rs b/src/ast/datatype/kind/mod.rs index 8dcd2c07..6c45d949 100644 --- a/src/ast/datatype/kind/mod.rs +++ b/src/ast/datatype/kind/mod.rs @@ -13,14 +13,14 @@ pub enum TypeKind { Integer(IntegerBits, IntegerSign), CInteger(CInteger, Option), Floating(FloatSize), - Pointer(Box), + Ptr(Box), FixedArray(Box), Void, Named(Name, Vec), AnonymousStruct(AnonymousStruct), AnonymousUnion(AnoymousUnion), AnonymousEnum(AnonymousEnum), - FuncPointer(FuncPtr), + FuncPtr(FuncPtr), Polymorph(String, Vec), } diff --git a/src/ast/datatype/mod.rs b/src/ast/datatype/mod.rs index 1c17415b..9a7f48ca 100644 --- a/src/ast/datatype/mod.rs +++ b/src/ast/datatype/mod.rs @@ -33,7 +33,7 @@ impl Type { pub fn pointer(self) -> Self { let source = self.source; - Type::new(TypeKind::Pointer(Box::new(self)), source) + Type::new(TypeKind::Ptr(Box::new(self)), source) } pub fn contains_polymorph(&self) -> Option { @@ -42,7 +42,7 @@ impl Type { | TypeKind::Integer(_, _) | TypeKind::CInteger(_, _) | TypeKind::Floating(_) => None, - TypeKind::Pointer(inner) => inner.contains_polymorph(), + TypeKind::Ptr(inner) => inner.contains_polymorph(), TypeKind::FixedArray(fixed_array) => fixed_array.ast_type.contains_polymorph(), TypeKind::Void => None, TypeKind::Named(_, args) => args @@ -55,7 +55,7 @@ impl Type { TypeKind::AnonymousStruct(_) => None, TypeKind::AnonymousUnion(_) => None, TypeKind::AnonymousEnum(_) => None, - TypeKind::FuncPointer(func_pointer) => func_pointer + TypeKind::FuncPtr(func_pointer) => func_pointer .parameters .iter() .flat_map(|param| param.ast_type.contains_polymorph()) diff --git a/src/c/parser/expr.rs b/src/c/parser/expr.rs index 0ef79c67..241c397f 100644 --- a/src/c/parser/expr.rs +++ b/src/c/parser/expr.rs @@ -27,7 +27,7 @@ pub enum ExprKind { Integer(Integer), Float(f64, FloatSuffix), StringLiteral(Encoding, String), - Boolean(bool), + Bool(bool), Nullptr, Character(Encoding, String), Compound(Vec), @@ -214,11 +214,11 @@ impl<'a> Parser<'a> { } if self.eat(CTokenKind::TrueKeyword) { - return Ok(ExprKind::Boolean(true).at(source)); + return Ok(ExprKind::Bool(true).at(source)); } if self.eat(CTokenKind::FalseKeyword) { - return Ok(ExprKind::Boolean(false).at(source)); + return Ok(ExprKind::Bool(false).at(source)); } if self.eat(CTokenKind::NullptrKeyword) { diff --git a/src/c/parser/mod.rs b/src/c/parser/mod.rs index 0ef4f1c8..ae81f99b 100644 --- a/src/c/parser/mod.rs +++ b/src/c/parser/mod.rs @@ -455,7 +455,7 @@ impl<'a> Parser<'a> { "va_list".into(), CTypedef { ast_type: Type::new( - TypeKind::Pointer(Box::new(Type::new(TypeKind::Void, Source::internal()))), + TypeKind::Ptr(Box::new(Type::new(TypeKind::Void, Source::internal()))), Source::internal(), ), }, diff --git a/src/c/translation/eval.rs b/src/c/translation/eval.rs index 9dbf1769..65f03467 100644 --- a/src/c/translation/eval.rs +++ b/src/c/translation/eval.rs @@ -14,7 +14,7 @@ pub fn evaluate_to_const_integer(expr: &Expr) -> Result { ExprKind::Integer(integer) => { return Ok(integer.into()); } - ExprKind::Boolean(x) => return Ok(BigInt::from(*x as i64)), + ExprKind::Bool(x) => return Ok(BigInt::from(*x as i64)), ExprKind::Nullptr => return Ok(BigInt::zero()), ExprKind::Character(encoding, s) => match encoding { Encoding::Default => return Ok(BigInt::from(s.as_bytes()[0])), diff --git a/src/c/translation/expr/mod.rs b/src/c/translation/expr/mod.rs index ea04f812..00b8400b 100644 --- a/src/c/translation/expr/mod.rs +++ b/src/c/translation/expr/mod.rs @@ -30,7 +30,7 @@ pub fn translate_expr( ExprKind::StringLiteral(encoding, content) => { translate_expr_string(encoding, content, expr.source)? } - ExprKind::Boolean(x) => ast::ExprKind::Boolean(*x).at(expr.source), + ExprKind::Bool(x) => ast::ExprKind::Boolean(*x).at(expr.source), ExprKind::Nullptr => todo!(), ExprKind::Character(_, _) => todo!(), ExprKind::Compound(_) => todo!(), diff --git a/src/c/translation/function.rs b/src/c/translation/function.rs index f1b93bab..c4431190 100644 --- a/src/c/translation/function.rs +++ b/src/c/translation/function.rs @@ -55,7 +55,7 @@ pub fn declare_function( } if is_typedef { - let ast_type = ast::TypeKind::FuncPointer(ast::FuncPtr { + let ast_type = ast::TypeKind::FuncPtr(ast::FuncPtr { parameters: required, return_type: Box::new(return_type), is_cstyle_variadic: parameter_type_list.is_variadic, diff --git a/src/c/translation/types/decorate.rs b/src/c/translation/types/decorate.rs index c410f393..e78a0cb7 100644 --- a/src/c/translation/types/decorate.rs +++ b/src/c/translation/types/decorate.rs @@ -22,7 +22,7 @@ pub fn decorate_pointer( )) } - Ok(Type::new(TypeKind::Pointer(Box::new(ast_type)), source)) + Ok(Type::new(TypeKind::Ptr(Box::new(ast_type)), source)) } pub fn decorate_array( @@ -69,7 +69,7 @@ pub fn decorate_function( function: &FunctionQualifier, source: Source, ) -> Result { - Ok(TypeKind::FuncPointer(FuncPtr { + Ok(TypeKind::FuncPtr(FuncPtr { parameters: function.parameters.clone(), return_type: Box::new(ast_type), is_cstyle_variadic: function.is_cstyle_variadic, diff --git a/src/interpreter/memory/read.rs b/src/interpreter/memory/read.rs index d90f11fa..01870f4e 100644 --- a/src/interpreter/memory/read.rs +++ b/src/interpreter/memory/read.rs @@ -15,8 +15,8 @@ impl Memory { } Ok(match ir_type { - ir::Type::Pointer(_) => self.read_u64(from), - ir::Type::Boolean => self.read_u1(from), + ir::Type::Ptr(_) => self.read_u64(from), + ir::Type::Bool => self.read_u1(from), ir::Type::S8 => self.read_s8(from), ir::Type::S16 => self.read_s16(from), ir::Type::S32 => self.read_s32(from), diff --git a/src/interpreter/size_of.rs b/src/interpreter/size_of.rs index c10e5792..a2845fc5 100644 --- a/src/interpreter/size_of.rs +++ b/src/interpreter/size_of.rs @@ -2,8 +2,8 @@ use crate::ir; pub fn size_of(ir_type: &ir::Type, ir_module: &ir::Module) -> u64 { match ir_type { - ir::Type::Pointer(_) => 8, - ir::Type::Boolean => 1, + ir::Type::Ptr(_) => 8, + ir::Type::Bool => 1, ir::Type::S8 => 1, ir::Type::S16 => 2, ir::Type::S32 => 4, diff --git a/src/interpreter_env/mod.rs b/src/interpreter_env/mod.rs index 13ac9849..ca687e91 100644 --- a/src/interpreter_env/mod.rs +++ b/src/interpreter_env/mod.rs @@ -54,7 +54,7 @@ fn thin_cstring_func( ) -> Func { let source = Source::internal(); let void = TypeKind::Void.at(Source::internal()); - let ptr_char = TypeKind::Pointer(Box::new(TypeKind::char().at(source))).at(source); + let ptr_char = TypeKind::Ptr(Box::new(TypeKind::char().at(source))).at(source); let param_name = param_name.into(); let head = FuncHead { @@ -89,7 +89,7 @@ fn thin_cstring_func( pub fn setup_build_system_interpreter_symbols(file: &mut AstFile) { let source = Source::internal(); let void = TypeKind::Void.at(Source::internal()); - let ptr_char = TypeKind::Pointer(Box::new(TypeKind::char().at(source))).at(source); + let ptr_char = TypeKind::Ptr(Box::new(TypeKind::char().at(source))).at(source); // Call to function we actually care about let call = ExprKind::Call(Box::new(Call { diff --git a/src/ir/mod.rs b/src/ir/mod.rs index 37642ddf..2601be40 100644 --- a/src/ir/mod.rs +++ b/src/ir/mod.rs @@ -307,8 +307,8 @@ impl CXXRecord { #[derive(Clone, Debug, PartialEq, Eq, IsVariant, Hash)] pub enum Type { - Pointer(Box), - Boolean, + Ptr(Box), + Bool, S8, S16, S32, @@ -348,7 +348,7 @@ impl Type { pub fn is_builtin_data(&self) -> bool { match self { - Type::Boolean + Type::Bool | Type::S8 | Type::S16 | Type::S32 @@ -359,7 +359,7 @@ impl Type { | Type::U64 | Type::F32 | Type::F64 => true, - Type::Pointer(_) + Type::Ptr(_) | Type::Void | Type::Union(_) | Type::Struct(_) @@ -393,13 +393,13 @@ pub struct Complex { impl Type { pub fn pointer(&self) -> Self { - Type::Pointer(Box::new(self.clone())) + Type::Ptr(Box::new(self.clone())) } pub fn is_integer_like(&self) -> bool { matches!( self, - Type::Boolean + Type::Bool | Type::S8 | Type::S16 | Type::S32 @@ -414,7 +414,7 @@ impl Type { pub fn is_signed(&self) -> Option { match self { Type::S8 | Type::S16 | Type::S32 | Type::S64 => Some(true), - Type::Boolean | Type::U8 | Type::U16 | Type::U32 | Type::U64 => Some(false), + Type::Bool | Type::U8 | Type::U16 | Type::U32 | Type::U64 => Some(false), _ => None, } } diff --git a/src/llvm_backend/abi/arch/x86_64/sysv/mod.rs b/src/llvm_backend/abi/arch/x86_64/sysv/mod.rs index 9963ec6a..9b8c3a21 100644 --- a/src/llvm_backend/abi/arch/x86_64/sysv/mod.rs +++ b/src/llvm_backend/abi/arch/x86_64/sysv/mod.rs @@ -501,9 +501,9 @@ impl SysV { // or C++ member pointers match ty { - ir::Type::Pointer(_) + ir::Type::Ptr(_) | ir::Type::FuncPtr - | ir::Type::Boolean + | ir::Type::Bool | ir::Type::S8 | ir::Type::S16 | ir::Type::S32 diff --git a/src/llvm_backend/abi/arch/x86_64/win64/mod.rs b/src/llvm_backend/abi/arch/x86_64/win64/mod.rs index 5fcd9365..18240558 100644 --- a/src/llvm_backend/abi/arch/x86_64/win64/mod.rs +++ b/src/llvm_backend/abi/arch/x86_64/win64/mod.rs @@ -224,7 +224,7 @@ impl Win64 { // NOTE: We don't support member pointer types here // NOTE: We don't support long doubles, or i128/u128 128-bit integers here - if ir_type.is_boolean() { + if ir_type.is_bool() { return Requirement::new( ABIType::new_extend(ir_type, None, ExtendOptions::default()), 0, diff --git a/src/llvm_backend/abi/mod.rs b/src/llvm_backend/abi/mod.rs index 6dffb996..8f1b87ac 100644 --- a/src/llvm_backend/abi/mod.rs +++ b/src/llvm_backend/abi/mod.rs @@ -9,8 +9,8 @@ mod homo_aggregate; pub fn has_scalar_evaluation_kind(ty: &ir::Type) -> bool { match ty { - ir::Type::Pointer(_) - | ir::Type::Boolean + ir::Type::Ptr(_) + | ir::Type::Bool | ir::Type::S8 | ir::Type::S16 | ir::Type::S32 @@ -42,14 +42,14 @@ pub fn is_promotable_integer_type_for_abi(ty: &ir::Type) -> bool { // NOTE: Arbitrarily sized integers and `char32` should be, but we don't support those yet match ty { - ir::Type::Boolean | ir::Type::S8 | ir::Type::S16 | ir::Type::U8 | ir::Type::U16 => true, + ir::Type::Bool | ir::Type::S8 | ir::Type::S16 | ir::Type::U8 | ir::Type::U16 => true, ir::Type::S32 | ir::Type::S64 | ir::Type::U32 | ir::Type::U64 | ir::Type::F32 | ir::Type::F64 - | ir::Type::Pointer(_) + | ir::Type::Ptr(_) | ir::Type::Void | ir::Type::Union(_) | ir::Type::Struct(_) diff --git a/src/llvm_backend/backend_type.rs b/src/llvm_backend/backend_type.rs index dc707b82..574beccc 100644 --- a/src/llvm_backend/backend_type.rs +++ b/src/llvm_backend/backend_type.rs @@ -32,14 +32,14 @@ pub unsafe fn to_backend_type<'a>( Ok(match ir_type { ir::Type::Void => LLVMVoidType(), - ir::Type::Boolean => LLVMInt1Type(), + ir::Type::Bool => LLVMInt1Type(), ir::Type::S8 | ir::Type::U8 => LLVMInt8Type(), ir::Type::S16 | ir::Type::U16 => LLVMInt16Type(), ir::Type::S32 | ir::Type::U32 => LLVMInt32Type(), ir::Type::S64 | ir::Type::U64 => LLVMInt64Type(), ir::Type::F32 => LLVMFloatType(), ir::Type::F64 => LLVMDoubleType(), - ir::Type::Pointer(to) => LLVMPointerType(to_backend_type(ctx, to)?, 0), + ir::Type::Ptr(to) => LLVMPointerType(to_backend_type(ctx, to)?, 0), ir::Type::Union(_) => todo!("to_backend_type for ir::Type::Union"), ir::Type::AnonymousComposite(composite) => { let mut subtypes = @@ -90,7 +90,7 @@ pub unsafe fn get_unabi_function_type<'a>( ctx: impl Borrow>, function: &ir::Func, ) -> Result { - get_function_pointer_type( + get_func_ptr_type( ctx.borrow(), &function.params[..], &function.return_type, @@ -241,21 +241,21 @@ unsafe fn expand_types( Ok(()) } -pub unsafe fn get_function_pointer_type<'a>( +pub unsafe fn get_func_ptr_type<'a>( ctx: impl Borrow>, - parameters: &[ir::Type], + params: &[ir::Type], return_type: &ir::Type, is_cstyle_variadic: bool, ) -> Result { let ctx = ctx.borrow(); let return_type = to_backend_type(ctx, return_type)?; - let mut parameters = to_backend_types(ctx, parameters.iter())?; + let mut params = to_backend_types(ctx, params.iter())?; let is_vararg = if is_cstyle_variadic { 1 } else { 0 }; Ok(LLVMFunctionType( return_type, - parameters.as_mut_ptr(), - parameters.len().try_into().unwrap(), + params.as_mut_ptr(), + params.len().try_into().unwrap(), is_vararg, )) } @@ -276,7 +276,7 @@ pub unsafe fn to_backend_mem_type<'a>( // NOTE: We don't support vector types yet assert!(ir_type.is_vector()); - if ir_type.is_boolean() { + if ir_type.is_bool() { return Ok(LLVMTypeRef::new_int(type_layout_cache.get(ir_type).width)); } diff --git a/src/llvm_backend/functions/block.rs b/src/llvm_backend/functions/block.rs index 57413ee1..7709db8e 100644 --- a/src/llvm_backend/functions/block.rs +++ b/src/llvm_backend/functions/block.rs @@ -756,7 +756,7 @@ fn promote_variadic_argument_type( match ir_type { // Promote integers to 32-bit - ir::Type::Boolean | ir::Type::S8 | ir::Type::S16 => ir::Type::S32, + ir::Type::Bool | ir::Type::S8 | ir::Type::S16 => ir::Type::S32, ir::Type::U8 | ir::Type::U16 | ir::Type::U32 => ir::Type::U32, // Promote floats to 64-bit diff --git a/src/llvm_backend/functions/helpers.rs b/src/llvm_backend/functions/helpers.rs index 684924d3..07992269 100644 --- a/src/llvm_backend/functions/helpers.rs +++ b/src/llvm_backend/functions/helpers.rs @@ -482,7 +482,7 @@ fn is_thread_local(value: LLVMValueRef) -> bool { pub fn emit_from_mem(builder: &Builder, value: LLVMValueRef, ir_type: &ir::Type) -> LLVMValueRef { match ir_type { - ir::Type::Boolean => unsafe { + ir::Type::Bool => unsafe { LLVMBuildTruncOrBitCast(builder.get(), value, LLVMInt1Type(), cstr!("").as_ptr()) }, _ => value, diff --git a/src/lower/datatype.rs b/src/lower/datatype.rs index a29503b9..db2ccda2 100644 --- a/src/lower/datatype.rs +++ b/src/lower/datatype.rs @@ -28,7 +28,7 @@ pub fn lower_type( name: name.to_string(), } .at(ty.source)), - asg::TypeKind::Boolean => Ok(ir::Type::Boolean), + asg::TypeKind::Boolean => Ok(ir::Type::Bool), asg::TypeKind::Integer(bits, sign) => Ok(match (bits, sign) { (Bits::Bits8, Sign::Signed) => ir::Type::S8, (Bits::Bits8, Sign::Unsigned) => ir::Type::U8, @@ -60,7 +60,7 @@ pub fn lower_type( FloatSize::Bits32 => ir::Type::F32, FloatSize::Bits64 => ir::Type::F64, }), - asg::TypeKind::Pointer(inner) => Ok(ir::Type::Pointer(Box::new(lower_type( + asg::TypeKind::Ptr(inner) => Ok(ir::Type::Ptr(Box::new(lower_type( ir_module, &ConcreteType(Cow::Borrowed(inner)), asg, @@ -107,7 +107,7 @@ pub fn lower_type( inner, }))) } - asg::TypeKind::FuncPointer(_func_pointer) => Ok(ir::Type::FuncPtr), + asg::TypeKind::FuncPtr(_func_pointer) => Ok(ir::Type::FuncPtr), asg::TypeKind::Enum(_human_name, enum_ref) => { let enum_definition = asg.enums.get(*enum_ref).expect("referenced enum to exist"); diff --git a/src/lower/expr/short_circuit.rs b/src/lower/expr/short_circuit.rs index 02822263..e1bc9b7e 100644 --- a/src/lower/expr/short_circuit.rs +++ b/src/lower/expr/short_circuit.rs @@ -50,7 +50,7 @@ pub fn lower_short_circuiting_binary_operation( builder.use_block(merge_block_id); Ok(builder.push(ir::Instr::Phi(ir::Phi { - ir_type: ir::Type::Boolean, + ir_type: ir::Type::Bool, incoming: vec![ ir::PhiIncoming { basicblock_id: short_circuit.left_done_block_id, diff --git a/src/parser/parse_type.rs b/src/parser/parse_type.rs index 84889d04..7c69fed4 100644 --- a/src/parser/parse_type.rs +++ b/src/parser/parse_type.rs @@ -124,7 +124,7 @@ impl<'a, I: Inflow> Parser<'a, I> { Some("ptr") => { if generics.len() == 1 { if let CompileTimeArgument::Type(inner) = generics.into_iter().next().unwrap() { - Ok(TypeKind::Pointer(Box::new(inner))) + Ok(TypeKind::Ptr(Box::new(inner))) } else { Err(ParseError { kind: ParseErrorKind::ExpectedTypeParameterToBeAType { diff --git a/src/resolve/conform/from_pointer.rs b/src/resolve/conform/from_pointer.rs index 64d1b0f9..80d1eb30 100644 --- a/src/resolve/conform/from_pointer.rs +++ b/src/resolve/conform/from_pointer.rs @@ -1,7 +1,7 @@ use super::{warn_type_alias_depth_exceeded, ConformMode, Objective, ObjectiveResult}; use crate::{ - resolve::expr::ResolveExprCtx, asg::{Expr, Type, TypeKind, TypedExpr}, + resolve::expr::ResolveExprCtx, }; pub fn from_pointer( @@ -16,7 +16,7 @@ pub fn from_pointer( return O::fail(); }; - let TypeKind::Pointer(to_inner_type) = &to_type.kind else { + let TypeKind::Ptr(to_inner_type) = &to_type.kind else { return O::fail(); }; diff --git a/src/resolve/conform/mod.rs b/src/resolve/conform/mod.rs index 25284284..87c339d6 100644 --- a/src/resolve/conform/mod.rs +++ b/src/resolve/conform/mod.rs @@ -17,8 +17,8 @@ use super::{ expr::ResolveExprCtx, }; use crate::{ - ast::ConformBehavior, asg::{Type, TypeKind, TypedExpr}, + ast::ConformBehavior, source_files::Source, }; pub use mode::ConformMode; @@ -105,9 +105,7 @@ pub fn conform_expr( ), TypeKind::FloatLiteral(from) => from_float_literal::(*from, to_type, conform_source), TypeKind::Floating(from_size) => from_float::(&expr.expr, mode, *from_size, to_type), - TypeKind::Pointer(from_inner) => { - from_pointer::(ctx, &expr.expr, mode, from_inner, to_type) - } + TypeKind::Ptr(from_inner) => from_pointer::(ctx, &expr.expr, mode, from_inner, to_type), TypeKind::CInteger(from_size, from_sign) => from_c_integer::( &expr.expr, from_type, diff --git a/src/resolve/expr/array_access.rs b/src/resolve/expr/array_access.rs index 84e6bc94..d1b854bf 100644 --- a/src/resolve/expr/array_access.rs +++ b/src/resolve/expr/array_access.rs @@ -1,12 +1,12 @@ use super::{resolve_expr, PreferredType, ResolveExprCtx}; use crate::{ + asg::{self, TypedExpr}, ast, resolve::{ conform::to_default::conform_expr_to_default_or_error, error::{ResolveError, ResolveErrorKind}, Initialized, }, - asg::{self, TypedExpr}, source_files::Source, }; use ast::{IntegerBits, IntegerSign}; @@ -41,7 +41,7 @@ pub fn resolve_array_access_expr( )?; let item_type = match &subject.ty.kind { - asg::TypeKind::Pointer(inner) => Ok((**inner).clone()), + asg::TypeKind::Ptr(inner) => Ok((**inner).clone()), bad_type => Err(ResolveErrorKind::CannotAccessMemberOf { bad_type: bad_type.to_string(), } diff --git a/src/resolve/expr/mod.rs b/src/resolve/expr/mod.rs index 222913c1..155eaacf 100644 --- a/src/resolve/expr/mod.rs +++ b/src/resolve/expr/mod.rs @@ -199,7 +199,7 @@ pub fn resolve_expr( ), )), ast::ExprKind::NullTerminatedString(value) => Ok(TypedExpr::new( - asg::TypeKind::Pointer(Box::new( + asg::TypeKind::Ptr(Box::new( asg::TypeKind::CInteger(CInteger::Char, None).at(source), )) .at(source), @@ -288,7 +288,7 @@ pub fn resolve_expr( )?; let result_type = match &resolved_expr.ty.kind { - TypeKind::Pointer(inner) if !resolved_expr.ty.kind.is_ambiguous() => { + TypeKind::Ptr(inner) if !resolved_expr.ty.kind.is_ambiguous() => { (**inner).clone() } _ => { diff --git a/src/resolve/func_head.rs b/src/resolve/func_head.rs index 8879e746..35f16b11 100644 --- a/src/resolve/func_head.rs +++ b/src/resolve/func_head.rs @@ -220,13 +220,13 @@ pub fn collect_constraints_into(map: &mut HashMap>, | asg::TypeKind::IntegerLiteral(_) | asg::TypeKind::FloatLiteral(_) | asg::TypeKind::Floating(_) => (), - asg::TypeKind::Pointer(inner) => collect_constraints_into(map, inner.as_ref()), + asg::TypeKind::Ptr(inner) => collect_constraints_into(map, inner.as_ref()), asg::TypeKind::Void => (), asg::TypeKind::AnonymousStruct() => todo!(), asg::TypeKind::AnonymousUnion() => todo!(), asg::TypeKind::AnonymousEnum() => todo!(), asg::TypeKind::FixedArray(fixed_array) => collect_constraints_into(map, &fixed_array.inner), - asg::TypeKind::FuncPointer(_) => todo!(), + asg::TypeKind::FuncPtr(_) => todo!(), asg::TypeKind::Enum(_, _) => (), asg::TypeKind::Structure(_, _, parameters) => { for parameter in parameters { diff --git a/src/resolve/polymorph.rs b/src/resolve/polymorph.rs index 3917beb5..9e35e827 100644 --- a/src/resolve/polymorph.rs +++ b/src/resolve/polymorph.rs @@ -85,8 +85,8 @@ impl PolyRecipe { | asg::TypeKind::FloatLiteral(_) | asg::TypeKind::Void | asg::TypeKind::Floating(_) => ty.clone(), - asg::TypeKind::Pointer(inner) => { - asg::TypeKind::Pointer(Box::new(self.resolve_type(inner)?)).at(ty.source) + asg::TypeKind::Ptr(inner) => { + asg::TypeKind::Ptr(Box::new(self.resolve_type(inner)?)).at(ty.source) } asg::TypeKind::AnonymousStruct() => todo!(), asg::TypeKind::AnonymousUnion() => todo!(), @@ -98,7 +98,7 @@ impl PolyRecipe { })) .at(ty.source) } - asg::TypeKind::FuncPointer(_) => todo!(), + asg::TypeKind::FuncPtr(_) => todo!(), asg::TypeKind::Enum(_, _) => ty.clone(), asg::TypeKind::Structure(human_name, struct_ref, poly_args) => { let args = poly_args @@ -235,8 +235,8 @@ impl PolyCatalog { } _ => Err(None), }, - asg::TypeKind::Pointer(pattern_inner) => match &concrete_type.kind { - asg::TypeKind::Pointer(concrete_inner) => { + asg::TypeKind::Ptr(pattern_inner) => match &concrete_type.kind { + asg::TypeKind::Ptr(concrete_inner) => { self.match_type(ctx, pattern_inner, concrete_inner) } _ => Err(None), @@ -250,7 +250,7 @@ impl PolyCatalog { } _ => Err(None), }, - asg::TypeKind::FuncPointer(_) => todo!(), + asg::TypeKind::FuncPtr(_) => todo!(), asg::TypeKind::Polymorph(name, constraints) => { self.put_type(name, concrete_type).map_err(Some)?; diff --git a/src/resolve/type_ctx/resolve_type.rs b/src/resolve/type_ctx/resolve_type.rs index 4223ecd6..f8a93f2f 100644 --- a/src/resolve/type_ctx/resolve_type.rs +++ b/src/resolve/type_ctx/resolve_type.rs @@ -27,9 +27,9 @@ impl<'a> ResolveTypeCtx<'a> { ast::TypeKind::Boolean => Ok(asg::TypeKind::Boolean), ast::TypeKind::Integer(bits, sign) => Ok(asg::TypeKind::Integer(*bits, *sign)), ast::TypeKind::CInteger(integer, sign) => Ok(asg::TypeKind::CInteger(*integer, *sign)), - ast::TypeKind::Pointer(inner) => { + ast::TypeKind::Ptr(inner) => { let inner = self.resolve_or_undeclared(inner)?; - Ok(asg::TypeKind::Pointer(Box::new(inner))) + Ok(asg::TypeKind::Ptr(Box::new(inner))) } ast::TypeKind::Void => Ok(asg::TypeKind::Void), ast::TypeKind::Named(name, arguments) => match self.find(name, arguments) { @@ -83,7 +83,7 @@ impl<'a> ResolveTypeCtx<'a> { todo!("resolve fixed array type with variable size") } } - ast::TypeKind::FuncPointer(function_pointer) => { + ast::TypeKind::FuncPtr(function_pointer) => { let mut parameters = Vec::with_capacity(function_pointer.parameters.len()); for parameter in function_pointer.parameters.iter() { @@ -97,7 +97,7 @@ impl<'a> ResolveTypeCtx<'a> { let return_type = Box::new(self.resolve(&function_pointer.return_type)?); - Ok(asg::TypeKind::FuncPointer(asg::FuncPtr { + Ok(asg::TypeKind::FuncPtr(asg::FuncPtr { parameters, return_type, is_cstyle_variadic: function_pointer.is_cstyle_variadic, diff --git a/src/target/type_layout.rs b/src/target/type_layout.rs index 2b8b487b..8ca8844e 100644 --- a/src/target/type_layout.rs +++ b/src/target/type_layout.rs @@ -82,8 +82,8 @@ impl<'a> TypeLayoutCache<'a> { fn get_impl(&self, ir_type: &ir::Type) -> TypeLayout { match ir_type { - ir::Type::Pointer(_) | ir::Type::FuncPtr => self.target.pointer_layout(), - ir::Type::Boolean => self.target.bool_layout(), + ir::Type::Ptr(_) | ir::Type::FuncPtr => self.target.pointer_layout(), + ir::Type::Bool => self.target.bool_layout(), ir::Type::S8 | ir::Type::U8 => TypeLayout::basic(ByteUnits::of(1)), ir::Type::S16 | ir::Type::U16 => TypeLayout::basic(ByteUnits::of(2)), ir::Type::S32 | ir::Type::U32 => TypeLayout::basic(ByteUnits::of(4)),