Skip to content

Commit

Permalink
Renamed additional codebase symbols for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacShelton committed Dec 29, 2024
1 parent da46161 commit feec994
Show file tree
Hide file tree
Showing 32 changed files with 85 additions and 87 deletions.
16 changes: 8 additions & 8 deletions src/asg/datatype/kind/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub enum TypeKind {
IntegerLiteral(BigInt),
FloatLiteral(Option<NotNan<f64>>),
Floating(FloatSize),
Pointer(Box<Type>),
Ptr(Box<Type>),
Void,
AnonymousStruct(),
AnonymousUnion(),
AnonymousEnum(),
FixedArray(Box<FixedArray>),
FuncPointer(FuncPtr),
FuncPtr(FuncPtr),
Enum(HumanName, EnumRef),
Structure(HumanName, StructRef, Vec<Type>),
TypeAlias(HumanName, TypeAliasRef),
Expand All @@ -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()
Expand All @@ -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(_, _)
Expand Down Expand Up @@ -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")?,
Expand All @@ -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)?;
Expand Down
6 changes: 3 additions & 3 deletions src/asg/datatype/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/ast/datatype/kind/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/ast/datatype/kind/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ pub enum TypeKind {
Integer(IntegerBits, IntegerSign),
CInteger(CInteger, Option<IntegerSign>),
Floating(FloatSize),
Pointer(Box<Type>),
Ptr(Box<Type>),
FixedArray(Box<FixedArray>),
Void,
Named(Name, Vec<CompileTimeArgument>),
AnonymousStruct(AnonymousStruct),
AnonymousUnion(AnoymousUnion),
AnonymousEnum(AnonymousEnum),
FuncPointer(FuncPtr),
FuncPtr(FuncPtr),
Polymorph(String, Vec<Type>),
}

Expand Down
6 changes: 3 additions & 3 deletions src/ast/datatype/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Source> {
Expand All @@ -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
Expand All @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions src/c/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expr>),
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/c/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
},
Expand Down
2 changes: 1 addition & 1 deletion src/c/translation/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn evaluate_to_const_integer(expr: &Expr) -> Result<BigInt, ParseError> {
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])),
Expand Down
2 changes: 1 addition & 1 deletion src/c/translation/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
Expand Down
2 changes: 1 addition & 1 deletion src/c/translation/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/c/translation/types/decorate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn decorate_function(
function: &FunctionQualifier,
source: Source,
) -> Result<Type, ParseError> {
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,
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter/memory/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter/size_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter_env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions src/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ impl CXXRecord {

#[derive(Clone, Debug, PartialEq, Eq, IsVariant, Hash)]
pub enum Type {
Pointer(Box<Type>),
Boolean,
Ptr(Box<Type>),
Bool,
S8,
S16,
S32,
Expand Down Expand Up @@ -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
Expand All @@ -359,7 +359,7 @@ impl Type {
| Type::U64
| Type::F32
| Type::F64 => true,
Type::Pointer(_)
Type::Ptr(_)
| Type::Void
| Type::Union(_)
| Type::Struct(_)
Expand Down Expand Up @@ -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
Expand All @@ -414,7 +414,7 @@ impl Type {
pub fn is_signed(&self) -> Option<bool> {
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,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/llvm_backend/abi/arch/x86_64/sysv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/llvm_backend/abi/arch/x86_64/win64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/llvm_backend/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(_)
Expand Down
Loading

0 comments on commit feec994

Please sign in to comment.